uber-archive / statsrelay

A consistent-hashing relay for statsd and carbon metrics
Other
101 stars 28 forks source link

Add key normalizers #50

Closed sloppyfocus closed 7 years ago

sloppyfocus commented 9 years ago

This change adds support for normalizing a key before it it submitted to a backend

eklitzke commented 9 years ago

It seems to me like it makes more sense to put this in the validator, and just fail lines with repeated dots. this is also faster, because you can implement it by using strstr(3), so it's just like something like:

if (strstr(stats_key, "..") != NULL) {
    goto fail;
}

I'm a little bit worried that if we add hacks like this then it encourages people to have buggy client code. Otherwise, you can still implement this whole thing simply and more efficiently again by using strstr(3) to find repeated dot sequences, and then only doing the replacement if there are any dots. This will be a lot faster because it avoids copying the string in the most common case (when there are no repetitions).