Documentation ¶
Index ¶
- Constants
- func Deregister(n *Namespace)
- func Handler() http.Handler
- func InstrumentHandler(metrics []*HTTPMetric, handler http.Handler) http.HandlerFunc
- func InstrumentHandlerFunc(metrics []*HTTPMetric, handlerFunc http.HandlerFunc) http.HandlerFunc
- func Register(n *Namespace)
- func StartTimer(timer Timer) (done func())
- type Counter
- type Gauge
- type HTTPHandlerOpts
- type HTTPMetric
- type LabeledCounter
- type LabeledGauge
- type LabeledTimer
- type Labels
- type Namespace
- func (n *Namespace) Add(collector prometheus.Collector)
- func (n *Namespace) Collect(ch chan<- prometheus.Metric)
- func (n *Namespace) Describe(ch chan<- *prometheus.Desc)
- func (n *Namespace) NewCounter(name, help string) Counter
- func (n *Namespace) NewDefaultHttpMetrics(handlerName string) []*HTTPMetric
- func (n *Namespace) NewDesc(name, help string, unit Unit, labels ...string) *prometheus.Desc
- func (n *Namespace) NewGauge(name, help string, unit Unit) Gauge
- func (n *Namespace) NewHttpMetrics(handlerName string, ...) []*HTTPMetric
- func (n *Namespace) NewHttpMetricsWithOpts(handlerName string, opts HTTPHandlerOpts) []*HTTPMetric
- func (n *Namespace) NewInFlightGaugeMetric(handlerName string) *HTTPMetric
- func (n *Namespace) NewLabeledCounter(name, help string, labels ...string) LabeledCounter
- func (n *Namespace) NewLabeledGauge(name, help string, unit Unit, labels ...string) LabeledGauge
- func (n *Namespace) NewLabeledTimer(name, help string, labels ...string) LabeledTimer
- func (n *Namespace) NewRequestDurationMetric(handlerName string, buckets []float64) *HTTPMetric
- func (n *Namespace) NewRequestSizeMetric(handlerName string, buckets []float64) *HTTPMetric
- func (n *Namespace) NewRequestTotalMetric(handlerName string) *HTTPMetric
- func (n *Namespace) NewResponseSizeMetric(handlerName string, buckets []float64) *HTTPMetric
- func (n *Namespace) NewTimer(name, help string) Timer
- func (n *Namespace) WithConstLabels(labels Labels) *Namespace
- type Timer
- type Unit
Constants ¶
const ( InstrumentHandlerResponseSize = iota InstrumentHandlerRequestSize InstrumentHandlerDuration InstrumentHandlerCounter InstrumentHandlerInFlight )
Variables ¶
This section is empty.
Functions ¶
func Deregister ¶
func Deregister(n *Namespace)
Deregister removes all the metrics in the provided namespace from the global metrics registry
func Handler ¶
Handler returns the global http.Handler that provides the prometheus metrics format on GET requests. This handler is no longer instrumented.
func InstrumentHandler ¶
func InstrumentHandler(metrics []*HTTPMetric, handler http.Handler) http.HandlerFunc
func InstrumentHandlerFunc ¶
func InstrumentHandlerFunc(metrics []*HTTPMetric, handlerFunc http.HandlerFunc) http.HandlerFunc
func Register ¶
func Register(n *Namespace)
Register adds all the metrics in the provided namespace to the global metrics registry
func StartTimer ¶
func StartTimer(timer Timer) (done func())
StartTimer begins a timer observation at the callsite. When the target operation is completed, the caller should call the return done func().
Types ¶
type Counter ¶
type Counter interface { // Inc adds Sum(vs) to the counter. Sum(vs) must be positive. // // If len(vs) == 0, increments the counter by 1. Inc(vs ...float64) }
Counter is a metrics that can only increment its current count
type Gauge ¶
type Gauge interface { Inc(...float64) Dec(...float64) // Add adds the provided value to the gauge's current value Add(float64) // Set replaces the gauge's current value with the provided value Set(float64) }
Gauge is a metric that allows incrementing and decrementing a value
type HTTPHandlerOpts ¶
type HTTPHandlerOpts struct { DurationBuckets []float64 RequestSizeBuckets []float64 ResponseSizeBuckets []float64 }
HTTPHandlerOpts describes a set of configurable options of http metrics
type HTTPMetric ¶
type HTTPMetric struct { prometheus.Collector // contains filtered or unexported fields }
type LabeledCounter ¶
LabeledCounter is counter that must have labels populated before use.
type LabeledGauge ¶
LabeledGauge describes a gauge the must have values populated before use.
type LabeledTimer ¶
type LabeledTimer interface {
WithValues(labels ...string) *labeledTimerObserver
}
LabeledTimer is a timer that must have label values populated before use.
type Namespace ¶
type Namespace struct {
// contains filtered or unexported fields
}
Namespace describes a set of metrics that share a namespace and subsystem.
func NewNamespace ¶
NewNamespace returns a namespaces that is responsible for managing a collection of metrics for a particual namespace and subsystem
labels allows const labels to be added to all metrics created in this namespace and are commonly used for data like application version and git commit
func (*Namespace) Add ¶
func (n *Namespace) Add(collector prometheus.Collector)
func (*Namespace) Collect ¶
func (n *Namespace) Collect(ch chan<- prometheus.Metric)
func (*Namespace) Describe ¶
func (n *Namespace) Describe(ch chan<- *prometheus.Desc)
func (*Namespace) NewCounter ¶
func (*Namespace) NewDefaultHttpMetrics ¶
func (n *Namespace) NewDefaultHttpMetrics(handlerName string) []*HTTPMetric
func (*Namespace) NewHttpMetrics ¶
func (n *Namespace) NewHttpMetrics(handlerName string, durationBuckets, requestSizeBuckets, responseSizeBuckets []float64) []*HTTPMetric
func (*Namespace) NewHttpMetricsWithOpts ¶
func (n *Namespace) NewHttpMetricsWithOpts(handlerName string, opts HTTPHandlerOpts) []*HTTPMetric
func (*Namespace) NewInFlightGaugeMetric ¶
func (n *Namespace) NewInFlightGaugeMetric(handlerName string) *HTTPMetric
func (*Namespace) NewLabeledCounter ¶
func (n *Namespace) NewLabeledCounter(name, help string, labels ...string) LabeledCounter
func (*Namespace) NewLabeledGauge ¶
func (n *Namespace) NewLabeledGauge(name, help string, unit Unit, labels ...string) LabeledGauge
func (*Namespace) NewLabeledTimer ¶
func (n *Namespace) NewLabeledTimer(name, help string, labels ...string) LabeledTimer
func (*Namespace) NewRequestDurationMetric ¶
func (n *Namespace) NewRequestDurationMetric(handlerName string, buckets []float64) *HTTPMetric
func (*Namespace) NewRequestSizeMetric ¶
func (n *Namespace) NewRequestSizeMetric(handlerName string, buckets []float64) *HTTPMetric
func (*Namespace) NewRequestTotalMetric ¶
func (n *Namespace) NewRequestTotalMetric(handlerName string) *HTTPMetric
func (*Namespace) NewResponseSizeMetric ¶
func (n *Namespace) NewResponseSizeMetric(handlerName string, buckets []float64) *HTTPMetric
func (*Namespace) WithConstLabels ¶
WithConstLabels returns a namespace with the provided set of labels merged with the existing constant labels on the namespace.
Only metrics created with the returned namespace will get the new constant labels. The returned namespace must be registered separately.
type Timer ¶
type Timer interface { // Update records an observation, duration, and converts to the target // units. Update(duration time.Duration) // UpdateSince will add the duration from the provided starting time to the // timer's summary with the precisions that was used in creation of the timer UpdateSince(time.Time) }
Timer is a metric that allows collecting the duration of an action in seconds