Closed mkeeler closed 1 year ago
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?
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.
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.
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.