Documentation ¶
Overview ¶
Package clientinfo provides some tools useful for gathering and exposing system metrics and diagnostics for external monitoring tools.
Currently, this package is intended to use with Prometheus but can be easily extended if needed. Also, not all Prometheus metric types are implemented.
Following specifications were used as reference: - https://prometheus.io/docs/instrumenting/writing_clientlibs/ - https://prometheus.io/docs/instrumenting/exposition_formats/
Index ¶
- type Gauge
- type Info
- type Label
- type MetricObserver
- type MetricObserverInput
- type MetricObserverOutput
- type Registry
- func (r *Registry) EnableServer(port int)
- func (r *Registry) NewMetricGauge(name string, labels ...Label) (*Gauge, error)
- func (r *Registry) NewMetricGaugeObserver(name string, input MetricObserverInput, labels ...Label) (*MetricObserver, error)
- func (r *Registry) NewMetricInfo(name string, labels []Label) (*Info, error)
- func (r *Registry) RegisterDiagnosticSource(name string, source func() string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Gauge ¶
type Gauge struct {
// contains filtered or unexported fields
}
Gauge is a metric type that represents a single numerical value that can arbitrarily go up and down.
type Info ¶
type Info struct {
// contains filtered or unexported fields
}
Info is a metric type that represents a constant information that cannot change in the time.
type Label ¶
type Label struct {
// contains filtered or unexported fields
}
Label represents an arbitrary information attached to the metrics.
type MetricObserver ¶
type MetricObserver struct {
// contains filtered or unexported fields
}
MetricObserver represent a definition of a cyclic metric observation process.
type MetricObserverInput ¶
type MetricObserverInput func() float64
MetricObserverInput defines a source of metric data.
type MetricObserverOutput ¶
type MetricObserverOutput interface {
Set(value float64)
}
MetricObserverOutput defines a destination of collected metric data.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry performs all management of metrics and diagnostics. Specifically, it allows registering and exposing them through the HTTP server.
func (*Registry) EnableServer ¶
EnableServer enables the client info server on the given port. Data will be exposed on `/metrics` and `/diagnostics` paths.
func (*Registry) NewMetricGauge ¶
NewMetricGauge creates and registers a new gauge metric which will be exposed through the metrics server. In case a metric already exists, an error will be returned.
func (*Registry) NewMetricGaugeObserver ¶
func (r *Registry) NewMetricGaugeObserver( name string, input MetricObserverInput, labels ...Label, ) (*MetricObserver, error)
NewMetricGaugeObserver creates and registers a gauge just like `NewMetricGauge` method and wraps it with a ready to use observer of the provided input. This allows to easily create self-refreshing metrics.
func (*Registry) NewMetricInfo ¶
NewMetricInfo creates and registers a new info metric which will be exposed through the metrics server. In case a metric already exists, an error will be returned.
func (*Registry) RegisterDiagnosticSource ¶
RegisterDiagnosticSource registers diagnostics source callback with a given name. Name will be used as a key and callback result as a value in JSON object during composing diagnostics JSON. Note: function will override existing diagnostics source on attempt to register another one with the same name.