Documentation ¶
Index ¶
- Variables
- type CounterDefinition
- type GaugeDefinition
- type PrometheusOpts
- type PrometheusPushSink
- type PrometheusSink
- func (p *PrometheusSink) AddSample(parts []string, val float32)
- func (p *PrometheusSink) AddSampleWithLabels(parts []string, val float32, labels []metrics.Label)
- func (p *PrometheusSink) Collect(c chan<- prometheus.Metric)
- func (p *PrometheusSink) Describe(c chan<- *prometheus.Desc)
- func (p *PrometheusSink) EmitKey(key []string, val float32)
- func (p *PrometheusSink) IncrCounter(parts []string, val float32)
- func (p *PrometheusSink) IncrCounterWithLabels(parts []string, val float32, labels []metrics.Label)
- func (p *PrometheusSink) SetGauge(parts []string, val float32)
- func (p *PrometheusSink) SetGaugeWithLabels(parts []string, val float32, labels []metrics.Label)
- func (p *PrometheusSink) SetPrecisionGauge(parts []string, val float64)
- func (p *PrometheusSink) SetPrecisionGaugeWithLabels(parts []string, val float64, labels []metrics.Label)
- type SummaryDefinition
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultPrometheusOpts is the default set of options used when creating a // PrometheusSink. DefaultPrometheusOpts = PrometheusOpts{ 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 PrometheusOpts ¶
type PrometheusOpts 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 PrometheusSink 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: []string{ "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 }
PrometheusOpts is used to configure the Prometheus Sink
type PrometheusPushSink ¶
type PrometheusPushSink struct { *PrometheusSink // contains filtered or unexported fields }
PrometheusPushSink wraps a normal prometheus sink and provides an address and facilities to export it to an address on an interval.
func NewPrometheusPushSink ¶
func NewPrometheusPushSink(address string, pushInterval time.Duration, name string) (*PrometheusPushSink, error)
NewPrometheusPushSink creates a PrometheusPushSink by taking an address, interval, and destination name.
func (*PrometheusPushSink) Shutdown ¶
func (s *PrometheusPushSink) Shutdown()
Shutdown tears down the PrometheusPushSink, and blocks while flushing metrics to the backend.
type PrometheusSink ¶
type PrometheusSink struct {
// contains filtered or unexported fields
}
func NewPrometheusSink ¶
func NewPrometheusSink() (*PrometheusSink, error)
NewPrometheusSink creates a new PrometheusSink using the default options.
func NewPrometheusSinkFrom ¶
func NewPrometheusSinkFrom(opts PrometheusOpts) (*PrometheusSink, error)
NewPrometheusSinkFrom creates a new PrometheusSink using the passed options.
func (*PrometheusSink) AddSample ¶
func (p *PrometheusSink) AddSample(parts []string, val float32)
func (*PrometheusSink) AddSampleWithLabels ¶
func (p *PrometheusSink) AddSampleWithLabels(parts []string, val float32, labels []metrics.Label)
func (*PrometheusSink) Collect ¶
func (p *PrometheusSink) 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 (*PrometheusSink) Describe ¶
func (p *PrometheusSink) Describe(c chan<- *prometheus.Desc)
Describe sends a Collector.Describe value from the descriptor created around PrometheusSink.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 (*PrometheusSink) EmitKey ¶
func (p *PrometheusSink) EmitKey(key []string, val float32)
EmitKey is not implemented. Prometheus doesn’t offer a type for which an arbitrary number of values is retained, as Prometheus works with a pull model, rather than a push model.
func (*PrometheusSink) IncrCounter ¶
func (p *PrometheusSink) IncrCounter(parts []string, val float32)
func (*PrometheusSink) IncrCounterWithLabels ¶
func (p *PrometheusSink) IncrCounterWithLabels(parts []string, val float32, labels []metrics.Label)
func (*PrometheusSink) SetGauge ¶
func (p *PrometheusSink) SetGauge(parts []string, val float32)
func (*PrometheusSink) SetGaugeWithLabels ¶
func (p *PrometheusSink) SetGaugeWithLabels(parts []string, val float32, labels []metrics.Label)
func (*PrometheusSink) SetPrecisionGauge ¶
func (p *PrometheusSink) SetPrecisionGauge(parts []string, val float64)
func (*PrometheusSink) SetPrecisionGaugeWithLabels ¶
func (p *PrometheusSink) SetPrecisionGaugeWithLabels(parts []string, val float64, labels []metrics.Label)
type SummaryDefinition ¶
SummaryDefinition can be provided to PrometheusOpts to declare a constant summary that is not deleted on expiry.