ginmetrics

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: MIT Imports: 8 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 float64) error

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

func (*Metric) Inc

func (m *Metric) Inc(labelValues []string) error

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

func (*Metric) Observe

func (m *Metric) Observe(labelValues []string, value float64) error

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

func (*Metric) SetGaugeValue

func (m *Metric) SetGaugeValue(labelValues []string, value float64) error

SetGaugeValue set data for Gauge type Metric.

type MetricType

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

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) Expose added in v0.1.8

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

Pass router to expose /metrics

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) 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

func (*Monitor) UseWithoutExposingEndpoint added in v0.1.8

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

Pass endpoints to monitor

Jump to

Keyboard shortcuts

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