Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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") )
var EmitUnlabeledMetric = EmitUnlabeledMetricOption{}
Functions ¶
func GetUnlabeledMetricName ¶
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.
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 ¶
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 ¶
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() .... }