labeled

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2019 License: Apache-2.0 Imports: 8 Imported by: 24

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAlreadySet = fmt.Errorf("cannot set metric keys more than once")
	ErrEmpty      = fmt.Errorf("cannot set metric keys to an empty set")
	ErrNeverSet   = fmt.Errorf("must call SetMetricKeys prior to using labeled package")
)
View Source
var EmitUnlabeledMetric = EmitUnlabeledMetricOption{}

Functions

func GetUnlabeledMetricName

func GetUnlabeledMetricName(metricName string) string

func SetMetricKeys

func SetMetricKeys(keys ...contextutils.Key)

Sets keys to use with labeled metrics. The values of these keys will be pulled from context at runtime.

Types

type Counter

type Counter struct {
	*prometheus.CounterVec

	prometheus.Counter
}

Represents a counter labeled with values from the context. See labeled.SetMetricsKeys for information about to configure that.

func NewCounter

func NewCounter(name, description string, scope promutils.Scope, opts ...MetricOption) Counter

Creates a new labeled counter. Label keys must be set before instantiating a counter. See labeled.SetMetricsKeys for information about to configure that.

func (Counter) Add

func (c Counter) Add(ctx context.Context, v float64)

Add adds the given value to the counter. It panics if the value is < 0.. The data point will be labeled with values from context. See labeled.SetMetricsKeys for information about to configure that.

func (Counter) Inc

func (c Counter) Inc(ctx context.Context)

Inc increments the counter by 1. Use Add to increment it by arbitrary non-negative values. The data point will be labeled with values from context. See labeled.SetMetricsKeys for information about to configure that.

type EmitUnlabeledMetricOption

type EmitUnlabeledMetricOption struct {
}

Instructs the metric to emit unlabeled metric (besides the labeled one). This is useful to get overall system performance.

type MetricOption

type MetricOption interface {
	// contains filtered or unexported methods
}

Defines extra set of options to customize the emitted metric.

type StopWatch

type StopWatch struct {
	*promutils.StopWatchVec

	// We use SummaryVec for emitting StopWatchVec, this computes percentiles per metric tags combination on the client-
	// side. This makes it impossible to aggregate percentiles across tags (e.g. to have system-wide view). When enabled
	// through a flag in the constructor, we initialize this additional untagged stopwatch to compute percentiles
	// across tags.
	promutils.StopWatch
}

func NewStopWatch

func NewStopWatch(name, description string, scale time.Duration, scope promutils.Scope, opts ...MetricOption) StopWatch

Creates a new labeled stopwatch. Label keys must be set before instantiating a counter. See labeled.SetMetricsKeys for information about to configure that.

func (StopWatch) Observe

func (c StopWatch) Observe(ctx context.Context, start, end time.Time)

Observes specified duration between the start and end time. The data point will be labeled with values from context. See labeled.SetMetricsKeys for information about to configure that.

func (StopWatch) Start

func (c StopWatch) Start(ctx context.Context) Timer

Start creates a new Instance of the StopWatch called a Timer that is closeable/stoppable. Common pattern to time a scope would be

{
  timer := stopWatch.Start(ctx)
  defer timer.Stop()
  ....
}

func (StopWatch) Time

func (c StopWatch) Time(ctx context.Context, f func())

This method observes the elapsed duration since the creation of the timer. The timer is created using a StopWatch. The data point will be labeled with values from context. See labeled.SetMetricsKeys for information about to configure that.

type Timer

type Timer interface {
	// Stops the timer and reports observation.
	Stop() float64
}

Defines a common interface for timers.

Jump to

Keyboard shortcuts

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