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

Introduce a flag that skips tag duplicate removal logic #165

Merged
merged 1 commit into from
Jul 18, 2024

Conversation

sungjujin
Copy link
Contributor

@sungjujin sungjujin commented Jul 15, 2024

This pull request primarily introduces a new feature to the Engine struct in engine.go which allows the skipping of duplicate tag removal in the metrics reporting process. This feature is tested in engine_test.go.

The most important changes are:

New feature:

  • engine.go: Added a new boolean field SkipTagDuplicateRemoval to the Engine struct. This field controls whether the engine should skip the removal of duplicate tags from the tags list before sending.

Feature integration:

  • engine.go: Modified the measure and ReportAt methods of the Engine struct to check the SkipTagDuplicateRemoval field before removing duplicate tags. [1] [2]

Testing:

  • engine_test.go: Added a new test scenario in TestEngine to test the behavior when SkipTagDuplicateRemoval is set.
  • engine_test.go: Implemented a new test function testEngineSkipTagDuplicateRemoval to test the new feature.

Contexts

image

https://twilio.slack.com/archives/CPLTV1V9A/p1720735336325819

@sungjujin sungjujin marked this pull request as ready for review July 16, 2024 16:49
engine.go Outdated Show resolved Hide resolved
@@ -148,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 && !TagsAreSorted(m.Tags) {
if len(tags) != 0 && !eng.SkipTagDuplicateRemoval && !TagsAreSorted(m.Tags) {
SortTags(m.Tags)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still want to sort tags even if we are not removing duplicates?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we rename the SortTags function to RemoveDuplicates that's really what it's doing, the sorting is an artifact of that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It makes sense but I can see other usages such as flagon. Do you want to rename to RemoveDuplicates because it doesn't offer the backwards compatibility?

@sungjujin
Copy link
Contributor Author

@kevinburkesegment would you please review again? Thank you!

@sungjujin
Copy link
Contributor Author

@kevinburkesegment I just wanted to follow up. Could you please review this PR when you have a moment? Thank you so much!

@kevinburkesegment kevinburkesegment force-pushed the skip-tag-duplicate-removal branch 2 times, most recently from dc46363 to f03f0bc Compare July 18, 2024 18:26
@kevinburkesegment kevinburkesegment force-pushed the skip-tag-duplicate-removal branch from f03f0bc to ec8ad7d Compare July 18, 2024 18:26
@kevinburkesegment kevinburkesegment merged commit 2a099d8 into main Jul 18, 2024
8 checks passed
@kevinburkesegment kevinburkesegment deleted the skip-tag-duplicate-removal branch July 18, 2024 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants