Documentation ¶
Index ¶
- func CountCall(metrics Metrics, key string, keyn ...string) func(*error)
- type Blackhole
- func (Blackhole) AddSample(key []string, val float32)
- func (Blackhole) AddSampleWithLabels(key []string, val float32, labels []Label)
- func (Blackhole) EmitKey(key []string, val float32)
- func (Blackhole) IncrCounter(key []string, val float32)
- func (Blackhole) IncrCounterWithLabels(key []string, val float32, labels []Label)
- func (Blackhole) MeasureSince(key []string, start time.Time)
- func (Blackhole) MeasureSinceWithLabels(key []string, start time.Time, labels []Label)
- func (Blackhole) SetGauge(key []string, val float32)
- func (Blackhole) SetGaugeWithLabels(key []string, val float32, labels []Label)
- type CallCounter
- type Label
- type Metrics
- type MetricsConfig
- type MetricsImpl
- type Sink
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Blackhole ¶
type Blackhole struct{}
Blackhole implements the Metrics interface, but throws away the metric data Useful for satisfying the Metrics interface when testing code which depends on it.
func (Blackhole) AddSampleWithLabels ¶
func (Blackhole) IncrCounter ¶
func (Blackhole) IncrCounterWithLabels ¶
func (Blackhole) MeasureSinceWithLabels ¶
type CallCounter ¶
type CallCounter struct {
// contains filtered or unexported fields
}
CallCounter is used to track timing and other information about a "call". It is intended to be scoped to a function with a defer and a named error value, if applicable, like so:
func Foo() (err error) { call := StartCall(metrics, "foo") defer call.Done(&err) call.AddLabel("food", "burgers") }
In the simplest case, if no labels are going to be added, the CountCall function provides an easier interface:
func Foo() (err error) { defer CountCall(metrics, "foo")(&err) }
func StartCall ¶
func StartCall(metrics Metrics, key string, keyn ...string) *CallCounter
StartCall starts a "call", which when finished via Done() will emit timing and error related metrics.
func (*CallCounter) AddLabel ¶
func (c *CallCounter) AddLabel(name, value string)
AddLabel adds a label to be emitted with the call counter. It is safe to call from multiple goroutines.
func (*CallCounter) Done ¶
func (c *CallCounter) Done(errp *error)
Done finishes the "call" and emits metrics. No other calls to the CallCounter should be done during or after the call to Done. In other words, it is not thread-safe and is intended to be the final call to the CallCounter struct.
type Metrics ¶
type Metrics interface { // A Gauge should retain the last value it is set to SetGauge(key []string, val float32) SetGaugeWithLabels(key []string, val float32, labels []Label) // Should emit a Key/Value pair for each call EmitKey(key []string, val float32) // Counters should accumulate values IncrCounter(key []string, val float32) IncrCounterWithLabels(key []string, val float32, labels []Label) // Samples are for timing information, where quantiles are used AddSample(key []string, val float32) AddSampleWithLabels(key []string, val float32, labels []Label) // A convenience function for measuring elapsed time with a single line MeasureSince(key []string, start time.Time) MeasureSinceWithLabels(key []string, start time.Time, labels []Label) }
func WithLabels ¶
type MetricsImpl ¶
type MetricsImpl struct { *metrics.Metrics // contains filtered or unexported fields }
func NewMetrics ¶
func NewMetrics(c *MetricsConfig) *MetricsImpl
NewMetrics returns a Metric implementation
func (*MetricsImpl) Stop ¶
func (t *MetricsImpl) Stop()