metrics

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2019 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package metrics is a largely a wrapper around the standard go-kit Provider type, with an extension for Cardinality estimators, for use on large sets.

It is extracted like this for convenience. See the Provider documentation for more information.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MeasureSince

func MeasureSince(h kitmetrics.Histogram, t0 time.Time)

MeasureSince takes a Histogram and initial time and generates an observation for the total duration of the operation. It's intended to be called via defer, e.g. defer MeasureSince(h, time.Now()).

Types

type CardinalityCounter

type CardinalityCounter interface {
	With(labelValues ...string) CardinalityCounter
	Insert(b []byte)
}

CardinalityCounter describes a metric that reports a count of the number of unique values inserted.

type DurationTimer

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

DurationTimer acts as a stopwatch, sending observations to a wrapped histogram. It's a bit of helpful syntax sugar for h.Observe(time.Since(x)), with a specified time duration unit.

func NewDurationTimer

func NewDurationTimer(h kitmetrics.Histogram) *DurationTimer

NewDurationTimer wraps the given histogram and records the current time. It defaults to time.Millisecond units.

func (*DurationTimer) ObserveDuration

func (t *DurationTimer) ObserveDuration()

ObserveDuration captures the number of time units since the timer was constructed, and forwards that observation to the histogram.

type HLLCounter

type HLLCounter struct {
	Name string
	// contains filtered or unexported fields
}

HLLCounter provides a wrapper around a HyperLogLog probabalistic counter, capable of being reported to Librato.

func NewHLLCounter

func NewHLLCounter(name string) *HLLCounter

NewHLLCounter creates a new HyperLogLog based counter.

func (*HLLCounter) Estimate

func (c *HLLCounter) Estimate() uint64

Estimate the cardinality of the inserted items. Safe for concurrent use.

func (*HLLCounter) EstimateReset

func (c *HLLCounter) EstimateReset() uint64

EstimateReset returns the cardinality estimate, and resets the estimate to zero allowing a new set to be counted. Safe for concurrent use.

func (*HLLCounter) Insert

func (c *HLLCounter) Insert(i []byte)

Insert adds the item to the set to be counted.

func (*HLLCounter) LabelValues

func (c *HLLCounter) LabelValues() []string

LabelValues returns the label values for this HLLCounter.

func (*HLLCounter) With

func (c *HLLCounter) With(labelValues ...string) CardinalityCounter

With returns a new UniqueCounter with the passed in label values merged with the previous label values. The counter's values are copied.

type MonotonicTimer

type MonotonicTimer struct {
	DurationTimer
	// contains filtered or unexported fields
}

MonotonicTimer emits metrics periodically until it is stopped.

func NewMonotonicTimer

func NewMonotonicTimer(h kitmetrics.Histogram, d, frequency time.Duration) *MonotonicTimer

NewMonotonicTimer takes a histogram and units like Duration Timer, as well as a frequency to report statistics on

func (*MonotonicTimer) Finish

func (t *MonotonicTimer) Finish()

Finish stops the ongoing reports of duration and makes one final Observation

type Provider

type Provider interface {
	NewCounter(name string) metrics.Counter
	NewGauge(name string) metrics.Gauge
	NewHistogram(name string, buckets int) metrics.Histogram
	NewCardinalityCounter(name string) CardinalityCounter
	Stop()
}

Provider represents the different types of metrics that a provider can expose. We duplicate the definition from go-kit for 2 reasons:

  1. A little copying never hurt anyone (and in copying, we avoid the need to import and vendor all of go-kit's supported providers
  2. It provides us an extension mechanism for our own custom metric types that we can implement without go-kit's approval.

Directories

Path Synopsis
Package l2met provides a basic log-based metrics provider for cases where a real provider is not available.
Package l2met provides a basic log-based metrics provider for cases where a real provider is not available.
provider
discard
Package discard is copied out of the go-kit metrics, provider package because importing that package brings in too many dependencies.
Package discard is copied out of the go-kit metrics, provider package because importing that package brings in too many dependencies.
librato
Package librato is a small wrapper around Librato's API for submitting metrics.
Package librato is a small wrapper around Librato's API for submitting metrics.

Jump to

Keyboard shortcuts

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