Skip to content

Commit

Permalink
apply code review
Browse files Browse the repository at this point in the history
  • Loading branch information
sungjujin committed Jul 16, 2024
1 parent 875de5e commit 9f9ed78
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ type Engine struct {
// that manipulates this field directly has to respect this requirement.
Tags []Tag

// Indicates whether to skip the removal of duplicate tags from the tags list before sending.
// Indicates whether to allow duplicated tags from the tags list before sending.
// This option is turned off by default, ensuring that duplicate tags are removed.
// Turn it on if you need to send the same tag multiple times with different values,
// which is a special use case.
SkipTagDuplicateRemoval bool
AllowDuplicateTags bool

// This cache keeps track of the generated measure structures to avoid
// rebuilding them every time a same measure type is seen by the engine.
Expand Down Expand Up @@ -154,7 +154,7 @@ func (eng *Engine) measure(t time.Time, name string, value interface{}, ftype Fi
m.Tags = append(m.Tags[:0], eng.Tags...)
m.Tags = append(m.Tags, tags...)

if len(tags) != 0 && !eng.SkipTagDuplicateRemoval && !TagsAreSorted(m.Tags) {
if len(tags) != 0 && !eng.AllowDuplicateTags && !TagsAreSorted(m.Tags) {
SortTags(m.Tags)
}

Expand Down Expand Up @@ -198,7 +198,7 @@ func (eng *Engine) ReportAt(time time.Time, metrics interface{}, tags ...Tag) {
tb = tagsPool.Get().(*tagsBuffer)
tb.append(tags...)
tb.append(eng.Tags...)
if !eng.SkipTagDuplicateRemoval {
if !eng.AllowDuplicateTags {
tb.sort()
}
tags = tb.tags
Expand Down
4 changes: 2 additions & 2 deletions engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func TestEngine(t *testing.T) {
function: testEngineWithTags,
},
{
scenario: "calling Engine.Incr produces expected tags when SkipTagDuplicateRemoval is set",
scenario: "calling Engine.Incr produces expected tags when AllowDuplicateTags is set",
function: testEngineSkipTagDuplicateRemoval,
},
}
Expand Down Expand Up @@ -132,7 +132,7 @@ func testEngineFlush(t *testing.T, eng *stats.Engine) {

func testEngineSkipTagDuplicateRemoval(t *testing.T, eng *stats.Engine) {
e2 := eng.WithTags()
e2.SkipTagDuplicateRemoval = true
e2.AllowDuplicateTags = true
if e2.Prefix != "test" {
t.Error("bad prefix:", e2.Prefix)
}
Expand Down

0 comments on commit 9f9ed78

Please sign in to comment.