docker / go-metrics

Package for metrics collection in Docker projects
Apache License 2.0
87 stars 32 forks source link

namespace: separate labeled and bare metrics #4

Closed stevvooe closed 8 years ago

stevvooe commented 8 years ago

Namespace is refactored into a concrete factory type that allows callers to create labeled and unlabeled metrics. Namespaces can be declared with all metrics with constant labels from the start or can be broken apart using WithConstLabels to have different sets of constant labels for child metrics.

Metrics requiring labels must now explicitly set the labels before using the actual counter. We use the convention Metrics and LabeledMetric to differentiate these types. Users of the metric must supply label values to the WithValues function, in order. This interface may be slightly error prone but allows for zero allocation workflows on metric reporting.

All metrics now implement prometheus.Collector, including Namespace, which allows registering metrics individually or as group with Namespace.

Signed-off-by: Stephen J Day stephen.day@docker.com

cc @crosbymichael

crosbymichael commented 8 years ago

Getting some build errors

github.com/docker/go-metrics
# github.com/docker/go-metrics
./counter.go:43: undefined: sumFloat64
./gauge.go:47: undefined: sumFloat64
./gauge.go:55: undefined: sumFloat64
# github.com/docker/go-metrics
./counter.go:43: undefined: sumFloat64
./gauge.go:47: undefined: sumFloat64
./gauge.go:55: undefined: sumFloat64
stevvooe commented 8 years ago

@crosbymichael Forgot to check in file. Fixed.