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

Prevent dogstatsd sink from clobbering the metric key for other sinks #156

Merged
merged 1 commit into from
Jun 8, 2023

Conversation

mkeeler
Copy link
Member

@mkeeler mkeeler commented Jun 8, 2023

Fixes: #154

If using the Fanout sink and including the dogstatsd sink, any sinks sent the metric AFTER dogstatsd could see invalid metric names. This was due to some inadvertent modifications to the original metric key. The new implementation ensure that when modifying the orignial metric key, a new backing array is used and will have key parts copied into it instead of changing elements in the original metric key.

If using the Fanout sink and including the dogstatsd sink, any sinks sent the metric AFTER dogstatsd could see invalid metric names. This was due to some inadvertent modifications to the original metric key. The new implementation ensure that when modifying the orignial metric key, a new backing array is used and will have key parts copied into it instead of changing elements in the original metric key.
@chapmanc
Copy link

chapmanc commented Jun 8, 2023

This looks good but should we also make a copy of the key at the point the fan out passes the key to the other sinks? To avoid the sinks from affecting each other?

Copy link

@chapmanc chapmanc left a comment

Choose a reason for hiding this comment

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

Lgtm with one question

@mkeeler
Copy link
Member Author

mkeeler commented Jun 8, 2023

I looked at a few other sinks and this one is the only one that modified the key before converting it to a string.

As metrics get emitted a lot, I figured it would put unnecessary pressure on the GC to copy every time when it should be the responsibility of the sink to not modify.

@mkeeler mkeeler merged commit aee7470 into master Jun 8, 2023
@chapmanc
Copy link

chapmanc commented Jun 8, 2023

That's a good call out. We should probably add a unit test to ensure that keys don't get changed. A new sink or changes to existing sinks could easily resurface this.

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.

FanoutSink key modified across sinks when DogStatsdSink is enabled
2 participants