Skip to content

Commit

Permalink
1. Add one more unit test for statsd reporter 2. Add comment for usin…
Browse files Browse the repository at this point in the history
…g statsdreporter
  • Loading branch information
longquanzheng committed Oct 17, 2017
1 parent ead094a commit 8af97a8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
24 changes: 18 additions & 6 deletions common/metrics/tally/statsd/reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,24 @@ func TestMetricNameWithTags(t *testing.T) {
"tag2": "456",
"tag3": "789",
}
name := "test-metric-name"
name := "test-metric-name1"

//test the order is stable
assert.Equal(t, r.metricNameWithTags(name, tags), r.metricNameWithTags(name, tags))
assert.Equal(t, r.metricNameWithTags(name, tags), r.metricNameWithTags(name, tags))
assert.Equal(t, r.metricNameWithTags(name, tags), r.metricNameWithTags(name, tags))
assert.Equal(t, r.metricNameWithTags(name, tags), r.metricNameWithTags(name, tags))
assert.Equal(t, "test-metric-name1.tag1.123.tag2.456.tag3.789", r.metricNameWithTags(name, tags))
}

func TestMetricNameWithTagsStability(t *testing.T) {
r := cadenceTallyStatsdReporter{
tallystatsd: nil,
}
tags := map[string]string{
"tag1": "123",
"tag2": "456",
"tag3": "789",
}
name := "test-metric-name2"

//test the order is stable
for i := 1; i<=16; i++ {
assert.Equal(t, r.metricNameWithTags(name, tags), r.metricNameWithTags(name, tags))
}
}
2 changes: 2 additions & 0 deletions common/service/config/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ func (c *Metrics) newStatsdScope() tally.Scope {
if err != nil {
log.Fatalf("error creating statsd client, err=%v", err)
}
//NOTE: according to ( https://github.com/uber-go/tally )Tally's statsd implementation doesn't support tagging.
// Therefore, we implement Tally interface to have a statsd reporter that can support tagging
reporter := statsdreporter.NewReporter(statter, tallystatsdreporter.Options{})
scopeOpts := tally.ScopeOptions{
Tags: c.Tags,
Expand Down

0 comments on commit 8af97a8

Please sign in to comment.