metrics

package
v1.0.25 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DbFlag map[string]bool = make(map[string]bool)
View Source
var Stats *stats.Stats

Stats provide response time, status code count, etc.

Functions

func GetCurTick

func GetCurTick() int

GetCurTics returns the number of times that a timeout has saved the data.

func SetupRoutes

func SetupRoutes(router *gin.Engine)

func SqlRunStmt

func SqlRunStmt(stmt string, data ...interface{}) (rv []map[string]interface{}, err error)

SqlRunStmt will run a single statemt and return the data as an array of maps

func StatMiddleware

func StatMiddleware() gin.HandlerFunc

StatMiddleware response time, status code count, etc.

func XData

func XData(x ...interface{}) (rv string)

XData convers a list of parameters to a JSON data showing what the list contains. This is returned as a string.

Types

type MetricsData

type MetricsData struct {
	Data map[string]float64

	Safe            sync.Mutex
	SaveRateSeconds int
	SaveKey         string
	// contains filtered or unexported fields
}

func NewMetricsData

func NewMetricsData(saveKey string, validKeys []MetricsTypeInfo, saveRateSeconds int, xgCfg *data.BaseConfigType, xdb map[string]bool, xlfp *os.File, xconn *pgxpool.Pool, xctx context.Context) (md *MetricsData)

func (*MetricsData) AddCounter

func (md *MetricsData) AddCounter(CounterName string, count int) (err error)

func (*MetricsData) AddFloatCounter

func (md *MetricsData) AddFloatCounter(CounterName string, count float64) (err error)

func (*MetricsData) AddMetricsKeys

func (md *MetricsData) AddMetricsKeys(validKeys []MetricsTypeInfo)

AddMetricsKeys add additional keys later in processing

func (*MetricsData) Close

func (md *MetricsData) Close() error

func (*MetricsData) Collect

func (md *MetricsData) Collect(ch chan<- prometheus.Metric)

Collect returns the metrics with values

func (*MetricsData) Describe

func (md *MetricsData) Describe(ch chan<- *prometheus.Desc)

Describe returns all possible prometheus.Desc

func (*MetricsData) GetCounter

func (md *MetricsData) GetCounter(CounterName string) (rv float64)

func (*MetricsData) GetData

func (md *MetricsData) GetData()

func (*MetricsData) GetDataJson

func (md *MetricsData) GetDataJson() (rv string)

Convert all of the data to JSON format and return as a string. This is for periodic saves

func (*MetricsData) ResetCounters

func (md *MetricsData) ResetCounters()

ResetCounters starts all counters back at 0

func (*MetricsData) SaveData

func (md *MetricsData) SaveData()

func (*MetricsData) SetFloatCounter

func (md *MetricsData) SetFloatCounter(CounterName string, count float64) (err error)

type MetricsTypeInfo

type MetricsTypeInfo struct {
	Key  string
	Desc string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL