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

Sanitise invalid characters in metric names #55

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ben-healthforge
Copy link

resolves #27

@nmuesch
Copy link
Contributor

nmuesch commented Sep 30, 2018

Hey @ben-healthforge Thanks for the contribution! Since the dogstatsd clients can typically see a high throughput of data points, one thing I want to be mindful of is any performance impact. Have you happened to see any performance difference before and after this change?

Are you currently experiencing metrics with a : or invalid character not making it through to the Datadog Agent or are they not appearing in the UI?

@ben-healthforge
Copy link
Author

Hi @nmuesch, we haven't noticed a performance impact at our level of usage but I suppose it could become significant as the number of metrics increases.

Metrics with a : don't make it through the agent, they cause a parse error in dogstatsd (which is understandable given that the protocol uses : as a separator).

@nmuesch
Copy link
Contributor

nmuesch commented Oct 1, 2018

Thanks for the info and context. I'll try to take a look to see if there is some performance impact here, if noticeable we may want to put this behind some configuration option if possible.

@rud
Copy link

rud commented Nov 6, 2018

According to https://docs.datadoghq.com/developers/faq/what-best-practices-are-recommended-for-naming-metrics-and-tags/ this sanitization is already supposed to happen, or am I misreading it?

Copy link

@rud rud left a comment

Choose a reason for hiding this comment

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

Was just checking the codebase for this functionality, glad I found this PR. +1 to merge it 🚀

Copy link
Contributor

@gzussa gzussa left a comment

Choose a reason for hiding this comment

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

Hi @ben-healthforge Thanks a lot for your contribution. This is great! However, I may miss something very obvious regarding your logic (see my first comment).

@@ -427,7 +434,7 @@ String tagString(final String[] tags) {
*/
@Override
public void count(final String aspect, final long delta, final String... tags) {
send(new StringBuilder(prefix).append(aspect).append(":").append(delta).append("|c").append(tagString(tags)).toString());
send(new StringBuilder(prefix).append(sanitiseAspect(aspect)).append(":").append(delta).append("|c").append(tagString(tags)).toString());
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we factorize this logic in a function instead of repeating it almost everywhere?

@ben-healthforge ben-healthforge force-pushed the feature/sanitise-metric-names branch from fe3372e to 19ce172 Compare August 15, 2019 15:27
Copy link

@rud rud left a comment

Choose a reason for hiding this comment

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

Looks great 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Delete ":" from metric names to allow statsd server insert them
5 participants