ginmetrics

package
v0.0.0-...-822a212 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metric

type Metric struct {
	Type        MetricType
	Name        string
	Description string
	Labels      []string
	Buckets     []float64
	Objectives  map[float64]float64
	// contains filtered or unexported fields
}

Metric defines a metric object. Users can use it to save metric data. Every metric should be globally unique by name.

func (*Metric) Add

func (m *Metric) Add(labelValues []string, value int64) error

Add adds the given value to the Metric object. Only for Counter/Gauge type metric.

func (*Metric) Inc

func (m *Metric) Inc() error

Inc increases value for Counter/Gauge type metric, increments the counter by 1

func (*Metric) Observe

func (m *Metric) Observe(value int64) error

Observe is used by Histogram and Summary type metric to add observations.

func (*Metric) SetGaugeValue

func (m *Metric) SetGaugeValue(value int64) error

SetGaugeValue set data for Gauge type Metric.

type MetricType

type MetricType int
const (
	None MetricType = iota
	Counter
	Gauge
	Histogram
)

type Monitor

type Monitor struct {
	// contains filtered or unexported fields
}

Monitor is an object that uses to set gin server monitor.

func GetMonitor

func GetMonitor() *Monitor

GetMonitor used to get global Monitor object, this function returns a singleton object.

func (*Monitor) AddMetric

func (m *Monitor) AddMetric(metric *Metric) error

AddMetric add custom monitor metric.

func (*Monitor) GetMetric

func (m *Monitor) GetMetric(name string) *Metric

GetMetric used to get metric object by metric_name.

func (*Monitor) SetDuration

func (m *Monitor) SetDuration(duration []float64)

SetDuration set reqDuration property. reqDuration is used to ginRequestDuration metric buckets.

func (*Monitor) SetMetricPath

func (m *Monitor) SetMetricPath(path string)

SetMetricPath set metricPath property. metricPath is used for Prometheus to get gin server monitoring data.

func (*Monitor) SetMetricPrefix

func (m *Monitor) SetMetricPrefix(prefix string)

func (*Monitor) SetMetricSuffix

func (m *Monitor) SetMetricSuffix(suffix string)

func (*Monitor) SetSlowTime

func (m *Monitor) SetSlowTime(slowTime int32)

SetSlowTime set slowTime property. slowTime is used to determine whether the request is slow. For "gin_slow_request_total" metric.

func (*Monitor) Use

func (m *Monitor) Use(r gin.IRoutes)

Use set gin metrics middleware

Jump to

Keyboard shortcuts

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