diff --git a/cmd/collector/app/metrics.go b/cmd/collector/app/metrics.go index f500b3441b8..cbdf1c8f7ff 100644 --- a/cmd/collector/app/metrics.go +++ b/cmd/collector/app/metrics.go @@ -53,6 +53,7 @@ type countsBySvc struct { factory metrics.Factory lock *sync.Mutex maxServiceNames int + category string } type metricsBySvc struct { @@ -94,25 +95,26 @@ func NewSpanProcessorMetrics(serviceMetrics metrics.Factory, hostMetrics metrics } func newMetricsBySvc(factory metrics.Factory, category string) metricsBySvc { - spansFactory := factory.Namespace("spans."+category, nil) - tracesFactory := factory.Namespace("traces."+category, nil) + spansFactory := factory.Namespace("spans", nil) + tracesFactory := factory.Namespace("traces", nil) return metricsBySvc{ - spans: newCountsBySvc(spansFactory, maxServiceNames), - traces: newCountsBySvc(tracesFactory, maxServiceNames), + spans: newCountsBySvc(spansFactory, category, maxServiceNames), + traces: newCountsBySvc(tracesFactory, category, maxServiceNames), } } -func newCountsBySvc(factory metrics.Factory, maxServiceNames int) countsBySvc { +func newCountsBySvc(factory metrics.Factory, category string, maxServiceNames int) countsBySvc { return countsBySvc{ counts: map[string]metrics.Counter{ - otherServices: factory.Counter("", map[string]string{"svc": otherServices, "debug": "false"}), + otherServices: factory.Counter(category, map[string]string{"svc": otherServices, "debug": "false"}), }, debugCounts: map[string]metrics.Counter{ - otherServices: factory.Counter("", map[string]string{"svc": otherServices, "debug": "true"}), + otherServices: factory.Counter(category, map[string]string{"svc": otherServices, "debug": "true"}), }, factory: factory, lock: &sync.Mutex{}, maxServiceNames: maxServiceNames, + category: category, } } @@ -181,7 +183,7 @@ func (m *countsBySvc) countByServiceName(serviceName string, isDebug bool) { if isDebug { debugStr = "true" } - c := m.factory.Counter("", map[string]string{"svc": serviceName, "debug": debugStr}) + c := m.factory.Counter(m.category, map[string]string{"svc": serviceName, "debug": debugStr}) counts[serviceName] = c counter = c } else { diff --git a/cmd/collector/app/metrics_test.go b/cmd/collector/app/metrics_test.go index ee45f9f8078..6f63dfecab1 100644 --- a/cmd/collector/app/metrics_test.go +++ b/cmd/collector/app/metrics_test.go @@ -57,7 +57,7 @@ func TestProcessorMetrics(t *testing.T) { func TestNewCountsBySvc(t *testing.T) { baseMetrics := jaegerM.NewLocalFactory(time.Hour) - metrics := newCountsBySvc(baseMetrics, 3) + metrics := newCountsBySvc(baseMetrics, "not_on_my_level", 3) metrics.countByServiceName("fry", false) metrics.countByServiceName("leela", false) @@ -65,9 +65,9 @@ func TestNewCountsBySvc(t *testing.T) { metrics.countByServiceName("zoidberg", false) counters, _ := baseMetrics.LocalBackend.Snapshot() - assert.EqualValues(t, 1, counters["|debug=false|svc=fry"]) - assert.EqualValues(t, 1, counters["|debug=false|svc=leela"]) - assert.EqualValues(t, 2, counters["|debug=false|svc=other-services"]) + assert.EqualValues(t, 1, counters["not_on_my_level|debug=false|svc=fry"]) + assert.EqualValues(t, 1, counters["not_on_my_level|debug=false|svc=leela"]) + assert.EqualValues(t, 2, counters["not_on_my_level|debug=false|svc=other-services"]) metrics.countByServiceName("zoidberg", true) metrics.countByServiceName("bender", true) @@ -75,7 +75,7 @@ func TestNewCountsBySvc(t *testing.T) { metrics.countByServiceName("fry", true) counters, _ = baseMetrics.LocalBackend.Snapshot() - assert.EqualValues(t, 1, counters["|debug=true|svc=zoidberg"]) - assert.EqualValues(t, 1, counters["|debug=true|svc=bender"]) - assert.EqualValues(t, 2, counters["|debug=true|svc=other-services"]) + assert.EqualValues(t, 1, counters["not_on_my_level|debug=true|svc=zoidberg"]) + assert.EqualValues(t, 1, counters["not_on_my_level|debug=true|svc=bender"]) + assert.EqualValues(t, 2, counters["not_on_my_level|debug=true|svc=other-services"]) }