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

Improper modification of global tags when bucketing histogram, meter, timer metrics #20

Closed
nitti opened this issue Oct 25, 2019 · 0 comments · Fixed by #21
Closed

Improper modification of global tags when bucketing histogram, meter, timer metrics #20

nitti opened this issue Oct 25, 2019 · 0 comments · Fixed by #21

Comments

@nitti
Copy link
Contributor

nitti commented Oct 25, 2019

When creating tags for the purpose of bucketing histogram, meter, and timer metrics, the library improperly modifies the global tag set:

https://github.com/vrischmann/go-metrics-influxdb/blob/master/influxdb.go#L151
https://github.com/vrischmann/go-metrics-influxdb/blob/master/influxdb.go#L173
https://github.com/vrischmann/go-metrics-influxdb/blob/master/influxdb.go#L207

I'm sure the intent here was to copy the existing tag set, but maps are a reference type. The result is that the bucket tag that is added for histogram, meter, and timer metrics is also applied to counter and gauge metrics.

The correct way to handle this is to explicitly copy the existing map:

these_tags := map[string]string{}
for tk, tv := range r.tags {
    these_tags[tk] = tv
}

I'll open a PR with the fix.

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 a pull request may close this issue.

1 participant