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 ¶
var ( // FiveSecondDistribution is a percentile distribution between 0 and 5000 milliseconds. // // Generated Distribution // // []float64{10, 55, 255, 505, 1255, 2505, 3755, 4505, 4755, 4955, 5000} FiveSecondDistribution = WithStandardPercentiles(0, 5000) // ThirtySecondDistribution is a percentile distribution between 0 and 30,000 milliseconds. // // Generated Distribution // // []float64{60, 330, 1530, 3030, 7530, 15030, 22530, 27030, 28530, 29730, 30000} ThirtySecondDistribution = WithStandardPercentiles(0, 30000) )
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 DistributionFunc ¶ added in v0.0.48
type DistributionFunc func() []float64
DistributionFunc is able to return an explicit boundaries slice for a given distribution.
func WithPercentileDistribution ¶ added in v0.0.48
func WithPercentileDistribution(min, max float64, pattern []float64) DistributionFunc
WithPercentileDistribution will generate boundaries by scaling the values between the min and the max according to supplied percentile distribution pattern.
func WithStandardPercentiles ¶ added in v0.0.48
func WithStandardPercentiles(min, max float64) DistributionFunc
WithStandardPercentiles returns a bulls horn shaped distribution where the lower and upper boundaries are captured using more precision than the middle. This distribution is most useful for collecting histograms where you are most interested in the upper and/or lower boundaries like the P95, P99, P999 or P05, P01, P001.
This standard percentile distribution used here will generate boundaries with the following percentile distribution P(0.001), P(0.01), P(0.05), P(0.1), P(0.25), P(0.5), P(0.75), P(0.9), P(0.95), P(0.99), P(0.999)
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 NewExplicitHistogram(name string, fn DistributionFunc) metrics.Histogram NewCardinalityCounter(name string) CardinalityCounter Stop() Flush() error }
Provider represents the different types of metrics that a provider can expose. We duplicate the definition from go-kit for 2 reasons:
- A little copying never hurt anyone (and in copying, we avoid the need to import and vendor all of go-kit's supported providers
- It provides us an extension mechanism for our own custom metric types that we can implement without go-kit's approval.
Source Files ¶
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. |
Package multiprovider allows multiple metrics.Providers to be composed together to report metrics to multiple places.
|
Package multiprovider allows multiple metrics.Providers to be composed together to report metrics to multiple places. |
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. |
otel
Package otel is a wrapper around Open-Telemetry's API for submitting metrics.
|
Package otel is a wrapper around Open-Telemetry's API for submitting metrics. |
Package testmetrics is for testing provider metrics with a test Provider that adheres to the Provider interface
|
Package testmetrics is for testing provider metrics with a test Provider that adheres to the Provider interface |