Documentation ¶
Index ¶
- type Counter
- type Gauge
- type Histogram
- type MetricOption
- type Registry
- func (p *Registry) NewCounter(name, helpText string, opts ...MetricOption) Counter
- func (p *Registry) NewGauge(name, helpText string, opts ...MetricOption) Gauge
- func (p *Registry) NewHistogram(name, helpText string, buckets []float64, opts ...MetricOption) Histogram
- func (p *Registry) Port() string
- func (p *Registry) RegisterDebugMetrics()
- func (p *Registry) RemoveCounter(c Counter)
- func (p *Registry) RemoveGauge(g Gauge)
- func (p *Registry) RemoveHistogram(h Histogram)
- type RegistryOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Counter ¶
type Counter interface {
Add(float64)
}
A cumulative metric that represents a single monotonically increasing counter whose value can only increase or be reset to zero on restart
type Histogram ¶
type Histogram interface {
Observe(float64)
}
A histogram counts observations into buckets.
type MetricOption ¶
type MetricOption func(o *prometheus.Opts)
Options applied to metrics on creation
func WithMetricLabels ¶
func WithMetricLabels(labels map[string]string) MetricOption
Add these tags to the metrics
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
The Registry keeps track of registered counters and gauges. Optionally, it can provide a server on a Prometheus-formatted endpoint.
func NewRegistry ¶
func NewRegistry(logger *log.Logger, opts ...RegistryOption) *Registry
Registry will register the metrics route with the default http mux but will not start an http server. This is intentional so that we can combine metrics with other things like pprof into one server. To start a server just for metrics, use the WithServer RegistryOption
func (*Registry) NewCounter ¶
func (p *Registry) NewCounter(name, helpText string, opts ...MetricOption) Counter
Creates new counter. When a duplicate is registered, the Registry will return the previously created metric.
func (*Registry) NewGauge ¶
func (p *Registry) NewGauge(name, helpText string, opts ...MetricOption) Gauge
Creates new gauge. When a duplicate is registered, the Registry will return the previously created metric.
func (*Registry) NewHistogram ¶
func (p *Registry) NewHistogram(name, helpText string, buckets []float64, opts ...MetricOption) Histogram
Creates new histogram. When a duplicate is registered, the Registry will return the previously created metric.
func (*Registry) RegisterDebugMetrics ¶
func (p *Registry) RegisterDebugMetrics()
func (*Registry) RemoveCounter ¶
func (*Registry) RemoveGauge ¶
func (*Registry) RemoveHistogram ¶
type RegistryOption ¶
type RegistryOption func(r *Registry)
Options for registry initialization
func WithPublicServer ¶
func WithPublicServer(port int) RegistryOption
Starts an http server on the given port to host metrics.
func WithServer ¶
func WithServer(port int) RegistryOption
Starts an http server on localhost at the given port to host metrics.
func WithTLSServer ¶
func WithTLSServer(port int, certFile, keyFile, caFile string) RegistryOption
Starts an https server on localhost at the given port to host metrics.