Documentation ¶
Index ¶
- func TagValueToString(vI interface{}) string
- type Count
- type CounterVec
- type Fields
- type Gauge
- type GaugeVec
- type IntGauge
- type Metrics
- func (m *Metrics) Count(key string) metrics.Count
- func (m *Metrics) Gauge(key string) metrics.Gauge
- func (m *Metrics) IntGauge(key string) metrics.IntGauge
- func (m *Metrics) List() []prometheus.Collector
- func (m *Metrics) Registerer() prometheus.Registerer
- func (m *Metrics) WithTag(key string, value interface{}) metrics.Metrics
- func (m *Metrics) WithTags(tags Fields) metrics.Metrics
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TagValueToString ¶
func TagValueToString(vI interface{}) string
TagValueToString converts any value to a string, which could be used as label value in prometheus.
Types ¶
type Count ¶
type Count struct { sync.Mutex *Metrics Key string *CounterVec io_prometheus_client.Metric prometheus.Counter }
Count is an implementation of metrics.Count.
type CounterVec ¶
type CounterVec struct { *prometheus.CounterVec Key string PossibleLabels []string }
func (*CounterVec) AddPossibleLabels ¶
func (v *CounterVec) AddPossibleLabels(newLabels []string)
func (*CounterVec) GetMetricWith ¶
func (v *CounterVec) GetMetricWith(labels prometheus.Labels) (prometheus.Counter, error)
type Gauge ¶
type Gauge struct { sync.Mutex *Metrics Key string *GaugeVec io_prometheus_client.Metric prometheus.Gauge }
Gauge is an implementation of metrics.Gauge.
type GaugeVec ¶
type GaugeVec struct { *prometheus.GaugeVec Key string PossibleLabels []string }
func (*GaugeVec) AddPossibleLabels ¶
func (*GaugeVec) GetMetricWith ¶
func (v *GaugeVec) GetMetricWith(labels prometheus.Labels) (prometheus.Gauge, error)
type IntGauge ¶
type IntGauge struct { sync.Mutex *Metrics Key string *GaugeVec io_prometheus_client.Metric prometheus.Gauge }
IntGauge is an implementation of metrics.IntGauge.
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics implements a wrapper of prometheus metrics to implement metrics.Metrics.
Pretty slow and naive implementation. Could be improved by on-need basis. If you need a faster implementation, then try `tsmetrics`.
Warning! This implementation does not remove automatically metrics, thus if a metric was created once, it will be kept in memory forever. If you need a version of metrics which automatically removes metrics non-used for a long time, then try `tsmetrics`.
Warning! Prometheus does not support changing amount of labels for a metric, therefore we delete and create a metric from scratch if it is required to extend the set of labels. This procedure leads to a reset of the metric value. If you need a version of metrics which does not have such flaw, then try `tsmetrics` or `simplemetrics`.
func New ¶
func New(registerer prometheus.Registerer) *Metrics
New returns a new instance of Metrics
func (*Metrics) IntGauge ¶
IntGauge implements context.Metrics (see the description in the interface).
func (*Metrics) List ¶
func (m *Metrics) List() []prometheus.Collector
func (*Metrics) Registerer ¶
func (m *Metrics) Registerer() prometheus.Registerer