Documentation
¶
Index ¶
- type Metric
- type MetricType
- type Monitor
- func (m *Monitor) AddMetric(metric *Metric) error
- func (m *Monitor) ApiExpose(r *ghttp.Request)
- func (m *Monitor) GetMetric(name string) *Metric
- func (m *Monitor) InitMetrics() *Monitor
- func (m *Monitor) MetricHandle(r *ghttp.Request, start time.Time)
- func (m *Monitor) Middleware(r *ghttp.Request)
- func (m *Monitor) SetDuration(duration []float64)
- func (m *Monitor) SetMetricPath(path string)
- func (m *Monitor) SetMetricPrefix(prefix string)
- func (m *Monitor) SetMetricSuffix(suffix string)
- func (m *Monitor) SetSlowTime(slowTime int32)
- func (m *Monitor) Use(s *ghttp.Server)
- func (m *Monitor) UseWithoutExposingEndpoint(s *ghttp.Server)
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 ¶
Add adds the given value to the Metric object. Only for Counter/Gauge type metric.
type MetricType ¶
type MetricType int
const ( None MetricType = iota Counter Gauge Histogram Summary DefaultMetricPath = "/metrics" DefaultSlowTime = int32(5) )
type Monitor ¶
type Monitor struct {
// contains filtered or unexported fields
}
Monitor is an object that uses to set Gf server monitor.
func GetMonitor ¶
func GetMonitor() *Monitor
GetMonitor used to get global Monitor object, this function returns a singleton object.
func (*Monitor) ApiExpose ¶
ApiExpose adds metric path to a given router. The router can be different with the one passed to UseWithoutExposingEndpoint. This allows to expose metrics on different port.
func (*Monitor) InitMetrics ¶
InitMetrics used to init Gf metrics
func (*Monitor) Middleware ¶
Middleware as Gf monitor middleware.
func (*Monitor) SetDuration ¶
SetDuration set reqDuration property. reqDuration is used to ginRequestDuration metric buckets.
func (*Monitor) SetMetricPath ¶
SetMetricPath set metricPath property. metricPath is used for Prometheus to get Gf server monitoring data.
func (*Monitor) SetMetricPrefix ¶
func (*Monitor) SetMetricSuffix ¶
func (*Monitor) SetSlowTime ¶
SetSlowTime set slowTime property. slowTime is used to determine whether the request is slow. For "gf_slow_request_total" metric.
func (*Monitor) UseWithoutExposingEndpoint ¶
UseWithoutExposingEndpoint is used to add monitor interceptor to Gf router It can be called multiple times to intercept from multiple gin.IRoutes http path is not set, to do that use Expose function