Skip to content

Commit

Permalink
Fix exclude tags with withTags method (#3466)
Browse files Browse the repository at this point in the history
  • Loading branch information
yux0 authored and dnr committed Oct 10, 2022
1 parent cb2f574 commit 78a5e36
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions common/metrics/tally_metrics_handler.go
Expand Up @@ -64,6 +64,7 @@ func (tmp *tallyMetricsHandler) WithTags(tags ...Tag) MetricsHandler {
return &tallyMetricsHandler{
scope: tmp.scope.Tagged(tagsToMap(tags, tmp.excludeTags)),
perUnitBuckets: tmp.perUnitBuckets,
excludeTags: tmp.excludeTags,
}
}

Expand Down
9 changes: 9 additions & 0 deletions common/metrics/tally_metrics_handler_test.go
Expand Up @@ -29,6 +29,7 @@ import (
"testing"
"time"

"github.com/pborman/uuid"
"github.com/stretchr/testify/assert"
"github.com/uber-go/tally/v4"
)
Expand Down Expand Up @@ -79,6 +80,14 @@ func TestTallyScope(t *testing.T) {
}, histograms["test.transmission+"].Values())
assert.EqualValues(t, map[time.Duration]int64(nil), histograms["test.transmission+"].Durations())
assert.EqualValues(t, map[string]string{}, histograms["test.transmission+"].Tags())

newTaggedHandler := mp.WithTags(NamespaceTag(uuid.New()))
recordTallyMetrics(newTaggedHandler)
snap = scope.Snapshot()
counters = snap.Counters()

assert.EqualValues(t, 11, counters["test.hits-tagged+taskqueue=__sticky__"].Value())
assert.EqualValues(t, map[string]string{"taskqueue": "__sticky__"}, counters["test.hits-tagged+taskqueue=__sticky__"].Tags())
}

func recordTallyMetrics(mp MetricsHandler) {
Expand Down

0 comments on commit 78a5e36

Please sign in to comment.