Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update collector metric counters to have a name #886

Merged
merged 2 commits into from
Jun 25, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions cmd/collector/app/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type countsBySvc struct {
factory metrics.Factory
lock *sync.Mutex
maxServiceNames int
category string
}

type metricsBySvc struct {
Expand Down Expand Up @@ -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,
}
}

Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion cmd/collector/app/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "", 3)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we change this test to reflect the usage (i.e. not a blank arg)?


metrics.countByServiceName("fry", false)
metrics.countByServiceName("leela", false)
Expand Down