metricsutil

package
v1.5.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2020 License: MPL-2.0 Imports: 16 Imported by: 29

Documentation

Index

Constants

View Source
const (
	OpenMetricsMIMEType = "application/openmetrics-text"

	PrometheusSchemaMIMEType = "prometheus/telemetry"

	// ErrorContentType is the content type returned by an error response.
	ErrorContentType = "text/plain"
)
View Source
const OverflowBucket = "+Inf"
View Source
const (
	PrometheusMetricFormat = "prometheus"
)

Variables

This section is empty.

Functions

func FormatFromRequest

func FormatFromRequest(req *logical.Request) string

func NamespaceLabel added in v1.5.0

func NamespaceLabel(ns *namespace.Namespace) metrics.Label

NamespaceLabel creates a metrics label for the given Namespace: root is "root"; others are path with the final '/' removed.

func TTLBucket added in v1.5.0

func TTLBucket(ttl time.Duration) string

TTLBucket computes the label to apply for a token TTL.

Types

type ClusterMetricSink added in v1.5.0

type ClusterMetricSink struct {
	// ClusterName is either the cluster ID, or a name provided
	// in the telemetry configuration stanza.
	//
	// Because it may be set after the Core is initialized, we need
	// to protect against concurrent access.
	ClusterName atomic.Value

	MaxGaugeCardinality int
	GaugeInterval       time.Duration

	// Sink is the go-metrics instance to send to.
	Sink metrics.MetricSink
}

ClusterMetricSink serves as a shim around go-metrics and inserts a "cluster" label.

It also provides a mechanism to limit the cardinality of the labels on a gauge (at each reporting interval, which isn't sufficient if there is variability in which labels are the top N) and a backoff mechanism for gauge computation.

func BlackholeSink added in v1.5.0

func BlackholeSink() *ClusterMetricSink

BlackholeSink is a default suitable for use in unit tests.

func NewClusterMetricSink added in v1.5.0

func NewClusterMetricSink(clusterName string, sink metrics.MetricSink) *ClusterMetricSink

func (*ClusterMetricSink) AddDurationWithLabels added in v1.5.0

func (m *ClusterMetricSink) AddDurationWithLabels(key []string, d time.Duration, labels []Label)

func (*ClusterMetricSink) AddSampleWithLabels added in v1.5.0

func (m *ClusterMetricSink) AddSampleWithLabels(key []string, val float32, labels []Label)

func (*ClusterMetricSink) IncrCounterWithLabels added in v1.5.0

func (m *ClusterMetricSink) IncrCounterWithLabels(key []string, val float32, labels []Label)

func (*ClusterMetricSink) MeasureSinceWithLabels added in v1.5.0

func (m *ClusterMetricSink) MeasureSinceWithLabels(key []string, start time.Time, labels []Label)

func (*ClusterMetricSink) NewGaugeCollectionProcess added in v1.5.0

func (m *ClusterMetricSink) NewGaugeCollectionProcess(
	key []string,
	id []Label,
	collector GaugeCollector,
	logger log.Logger,
) (*GaugeCollectionProcess, error)

NewGaugeCollectionProcess creates a new collection process for the callback function given as an argument, and starts it running. A label should be provided for metrics *about* this collection process.

The Run() method must be called to start the process.

func (*ClusterMetricSink) SetDefaultClusterName added in v1.5.0

func (m *ClusterMetricSink) SetDefaultClusterName(clusterName string)

SetDefaultClusterName changes the cluster name from its default value, if it has not previously been configured.

func (*ClusterMetricSink) SetGaugeWithLabels added in v1.5.0

func (m *ClusterMetricSink) SetGaugeWithLabels(key []string, val float32, labels []Label)

type GaugeCollectionProcess added in v1.5.0

type GaugeCollectionProcess struct {
	// contains filtered or unexported fields
}

A GaugeCollectionProcess is responsible for one particular gauge metric. It handles a delay on initial startup; limiting the cardinality; and exponential backoff on the requested interval.

func (*GaugeCollectionProcess) Run added in v1.5.0

func (p *GaugeCollectionProcess) Run()

Run should be called as a goroutine.

func (*GaugeCollectionProcess) Stop added in v1.5.0

func (p *GaugeCollectionProcess) Stop()

Stop the collection process

type GaugeCollector added in v1.5.0

type GaugeCollector = func(context.Context) ([]GaugeLabelValues, error)

GaugeCollector is a callback function that returns an unfiltered set of label-value pairs. It may be cancelled if it takes too long.

type GaugeLabelValues added in v1.5.0

type GaugeLabelValues struct {
	Labels []Label
	Value  float32
}

GaugeLabelValues is one gauge in a set sharing a single key, that are measured in a batch.

type Label added in v1.5.0

type Label = metrics.Label

Convenience alias

type MetricsHelper

type MetricsHelper struct {
	PrometheusEnabled bool
	// contains filtered or unexported fields
}

func NewMetricsHelper

func NewMetricsHelper(inMem *metrics.InmemSink, enablePrometheus bool) *MetricsHelper

func (*MetricsHelper) GenericResponse

func (m *MetricsHelper) GenericResponse() *logical.Response

func (*MetricsHelper) PrometheusResponse

func (m *MetricsHelper) PrometheusResponse() *logical.Response

func (*MetricsHelper) ResponseForFormat

func (m *MetricsHelper) ResponseForFormat(format string) *logical.Response

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL