Documentation ¶
Index ¶
- Constants
- Variables
- type CounterDefinition
- type GaugeDefinition
- type Opts
- type PushSink
- type Sink
- func (p *Sink) AddSample(parts string, val float64, labels []metrics.Tag)
- func (p *Sink) Collect(c chan<- prometheus.Metric)
- func (p *Sink) Describe(c chan<- *prometheus.Desc)
- func (p *Sink) IncrCounter(parts string, val float64, labels []metrics.Tag)
- func (p *Sink) SetGauge(parts string, val float64, labels []metrics.Tag)
- type SummaryDefinition
Constants ¶
const ObservationMaxAge = 10 * time.Minute
ObservationMaxAge defines the duration for which an observation stays relevant for the summary. Only applies to pre-calculated quantiles, does not apply to _sum and _count. Must be positive. The default value is DefMaxAge.
Variables ¶
var ( // DefaultPrometheusOpts is the default set of options used when creating a // Sink. DefaultPrometheusOpts = Opts{ Expiration: 60 * time.Second, Name: "default_prometheus_sink", } )
Functions ¶
This section is empty.
Types ¶
type CounterDefinition ¶
CounterDefinition can be provided to PrometheusOpts to declare a constant counter that is not deleted on expiry.
type GaugeDefinition ¶
GaugeDefinition can be provided to PrometheusOpts to declare a constant gauge that is not deleted on expiry.
type Opts ¶
type Opts struct { // Expiration is the duration a metric is valid for, after which it will be // untracked. If the value is zero, a metric is never expired. Expiration time.Duration Registerer prometheus.Registerer // Gauges, Summaries, and Counters allow us to pre-declare metrics by giving // their Name, Help, and ConstLabels to the Sink when it is created. // Metrics declared in this way will be initialized at zero and will not be // deleted or altered when their expiry is reached. // // Ex: PrometheusOpts{ // Expiration: 10 * time.Second, // Gauges: []GaugeDefinition{ // { // Name: "application_component_measurement"}, // Help: "application_component_measurement provides an example of how to declare static metrics", // ConstLabels: []metrics.Label{ { Name: "my_label", Value: "does_not_change" }, }, // }, // }, // } GaugeDefinitions []GaugeDefinition SummaryDefinitions []SummaryDefinition CounterDefinitions []CounterDefinition Name string // Help of the metrics Help map[string]string }
Opts is used to configure the Prometheus Sink
type PushSink ¶
type PushSink struct { *Sink // contains filtered or unexported fields }
PushSink wraps a normal prometheus sink and provides an address and facilities to export it to an address on an interval.
func NewPushSink ¶
NewPushSink creates a PrometheusPushSink by taking an address, interval, and destination name.
type Sink ¶
type Sink struct {
// contains filtered or unexported fields
}
Sink provides a MetricSink that can be used with a prometheus server.
func NewSinkFrom ¶
NewSinkFrom creates a new Sink using the passed options.
func (*Sink) Collect ¶
func (p *Sink) Collect(c chan<- prometheus.Metric)
Collect meets the collection interface and allows us to enforce our expiration logic to clean up ephemeral metrics if their value haven't been set for a duration exceeding our allowed expiration time.
func (*Sink) Describe ¶
func (p *Sink) Describe(c chan<- *prometheus.Desc)
Describe sends a Collector.Describe value from the descriptor created around Sink.Name Note that we cannot describe all the metrics (gauges, counters, summaries) in the sink as metrics can be added at any point during the lifecycle of the sink, which does not respect the idempotency aspect of the Collector.Describe() interface
func (*Sink) IncrCounter ¶
IncrCounter should accumulate values