Merge pull request #9 from matttproud/feature/base-labels-on-registration

Add ``baseLabels`` to the registration signature.
This commit is contained in:
juliusv 2013-01-15 11:36:00 -08:00
commit d670ebaba5
2 changed files with 19 additions and 14 deletions

View File

@ -57,12 +57,15 @@ func main() {
zed_rpc_calls := &metrics.CounterMetric{}
metrics := registry.NewRegistry()
metrics.Register("rpc_latency_foo_microseconds", "RPC latency for foo service.", foo_rpc_latency)
metrics.Register("rpc_calls_foo_total", "RPC calls for foo service.", foo_rpc_calls)
metrics.Register("rpc_latency_bar_microseconds", "RPC latency for bar service.", bar_rpc_latency)
metrics.Register("rpc_calls_bar_total", "RPC calls for bar service.", bar_rpc_calls)
metrics.Register("rpc_latency_zed_microseconds", "RPC latency for zed service.", zed_rpc_latency)
metrics.Register("rpc_calls_zed_total", "RPC calls for zed service.", zed_rpc_calls)
nilBaseLabels := make(map[string]string)
metrics.Register("rpc_latency_foo_microseconds", "RPC latency for foo service.", nilBaseLabels, foo_rpc_latency)
metrics.Register("rpc_calls_foo_total", "RPC calls for foo service.", nilBaseLabels, foo_rpc_calls)
metrics.Register("rpc_latency_bar_microseconds", "RPC latency for bar service.", nilBaseLabels, bar_rpc_latency)
metrics.Register("rpc_calls_bar_total", "RPC calls for bar service.", nilBaseLabels, bar_rpc_calls)
metrics.Register("rpc_latency_zed_microseconds", "RPC latency for zed service.", nilBaseLabels, zed_rpc_latency)
metrics.Register("rpc_calls_zed_total", "RPC calls for zed service.", nilBaseLabels, zed_rpc_calls)
go func() {
for {

View File

@ -100,14 +100,14 @@ var DefaultRegistry = NewRegistry()
/*
Associate a Metric with the DefaultRegistry.
*/
func Register(name, unusedDocstring string, metric metrics.Metric) {
DefaultRegistry.Register(name, unusedDocstring, metric)
func Register(name, unusedDocstring string, unusedBaseLabels map[string]string, metric metrics.Metric) {
DefaultRegistry.Register(name, unusedDocstring, unusedBaseLabels, metric)
}
/*
Register a metric with a given name. Name should be globally unique.
*/
func (r *Registry) Register(name, unusedDocstring string, metric metrics.Metric) {
func (r *Registry) Register(name, unusedDocstring string, unusedBaseLabels map[string]string, metric metrics.Metric) {
r.mutex.Lock()
defer r.mutex.Unlock()
@ -175,9 +175,11 @@ func (registry *Registry) YieldExporter() http.HandlerFunc {
}
func init() {
DefaultRegistry.Register("requests_metrics_total", "A counter of the total requests made against the telemetry system.", requestCount)
DefaultRegistry.Register("requests_metrics_latency_logarithmic_accumulating_microseconds", "A histogram of the response latency for requests made against the telemetry system.", requestLatencyLogarithmicAccumulating)
DefaultRegistry.Register("requests_metrics_latency_equal_accumulating_microseconds", "A histogram of the response latency for requests made against the telemetry system.", requestLatencyEqualAccumulating)
DefaultRegistry.Register("requests_metrics_latency_logarithmic_tallying_microseconds", "A histogram of the response latency for requests made against the telemetry system.", requestLatencyLogarithmicTallying)
DefaultRegistry.Register("request_metrics_latency_equal_tallying_microseconds", "A histogram of the response latency for requests made against the telemetry system.", requestLatencyEqualTallying)
nilBaseLabels := make(map[string]string)
DefaultRegistry.Register("requests_metrics_total", "A counter of the total requests made against the telemetry system.", nilBaseLabels, requestCount)
DefaultRegistry.Register("requests_metrics_latency_logarithmic_accumulating_microseconds", "A histogram of the response latency for requests made against the telemetry system.", nilBaseLabels, requestLatencyLogarithmicAccumulating)
DefaultRegistry.Register("requests_metrics_latency_equal_accumulating_microseconds", "A histogram of the response latency for requests made against the telemetry system.", nilBaseLabels, requestLatencyEqualAccumulating)
DefaultRegistry.Register("requests_metrics_latency_logarithmic_tallying_microseconds", "A histogram of the response latency for requests made against the telemetry system.", nilBaseLabels, requestLatencyLogarithmicTallying)
DefaultRegistry.Register("request_metrics_latency_equal_tallying_microseconds", "A histogram of the response latency for requests made against the telemetry system.", nilBaseLabels, requestLatencyEqualTallying)
}