Esempio n. 1
0
func recordOutcome(counter metrics.Counter, latency metrics.Histogram, duration time.Duration, err error, success, failure map[string]string) {
	labels := success
	if err != nil {
		labels = failure
	}

	counter.Increment(labels)
	latency.Add(labels, float64(duration/time.Microsecond))
}
Esempio n. 2
0
	ReportablePercentiles: []float64{0.01, 0.05, 0.5, 0.9, 0.99},
})
var requestLatencyEqualTallying *metrics.Histogram = metrics.CreateHistogram(&metrics.HistogramSpecification{
	Starts:                requestLatencyEqualBuckets,
	BucketMaker:           metrics.TallyingBucketBuilder,
	ReportablePercentiles: []float64{0.01, 0.05, 0.5, 0.9, 0.99},
})

/*
This callback accumulates the microsecond duration of the reporting framework's
overhead such that it can be reported.
*/
var requestLatencyAccumulator metrics.CompletionCallback = func(duration time.Duration) {
	microseconds := float64(int64(duration) / 1E3)

	requestLatencyLogarithmicAccumulating.Add(microseconds)
	requestLatencyEqualAccumulating.Add(microseconds)
	requestLatencyLogarithmicTallying.Add(microseconds)
	requestLatencyEqualTallying.Add(microseconds)
}

/*
Registry is, as the name implies, a registrar where metrics are listed.

In most situations, using DefaultRegistry is sufficient versus creating one's
own.
*/
type Registry struct {
	mutex        sync.RWMutex
	NameToMetric map[string]metrics.Metric
}