librato / statsd-librato-backend

A StatsD backend that sends metrics to Librato Metrics
MIT License
76 stars 34 forks source link

Append the `globalPrefix` only after `sourceRegex` alterations to the mea… #90

Closed plmwong closed 7 years ago

plmwong commented 7 years ago

…sureName have been done, or if there is no sourceRegex configured.

Unlike in version 1.7.x, the globalPrefix is being applied to the metric name before it is run through the sourceRegex to pull out the source and discard the matching substring from the metric name. So instead of the sourceRegex being matched against the original statsd metric name, it's being matched against the metric name with the prefix added on the beginning, which causes unexpected results.

I've changed it so that the globalPrefix is applied at the same point the sanitizeName function is applied. I.e., those are the last things that happen to the metric name before it is set on the measure object.

bryanmikaelian commented 7 years ago

Perfect! Thanks for the PR and the tests!