-
Notifications
You must be signed in to change notification settings - Fork 140
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
Support space-separated DD_TAGS #289
base: master
Are you sure you want to change the base?
Conversation
This has been in use since datadog-agent 6.0: DataDog/datadog-agent@75fa4ea#diff-2c623f3c6a917be56c59d43279244996836262cb1e12d9d0786c9c49eef6b43cR70-R71
@@ -79,7 +79,7 @@ def escape_tag_content(tag) | |||
def dd_tags(env = ENV) | |||
return {} unless dd_tags = env['DD_TAGS'] | |||
|
|||
to_tags_hash(dd_tags.split(',')) | |||
to_tags_hash(dd_tags.split(' ')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To address concerns about backwards-compatibility, this could be changed to allow spaces or commas as the separator:
to_tags_hash(dd_tags.split(' ')) | |
to_tags_hash(dd_tags.split(/[, ]/)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great idea: 120c0d4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem here is that if someone has spaces in their tag names then they will be split with this change. This could cause alerts to fire if they are monitoring a particular metric with a tag that has space in it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I thought about that too. What about parsing it as CSV, including quote delimiters? It might slow things down - I'm not sure how often this gets called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And it would still require people to add quotes since they weren't there before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the DD docs it seems like spaces are not supported in tag names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spaces count as other special characters so will be converted to underscores once they are sent back to DD.
From the docs:
Other special characters are converted to underscores.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@carlosroman what if it's conditional - if DD_TAGS has a ,
in it, split on that. Otherwise split on spaces?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Problem
For logging, DD_TAGS should be space separated, per the docs. We changed to that on 11/16 and that's been working since. But at the same time we lost tagging on metrics because they're required to be comma-separated. (edited)
Solution
Spaces have been in use since datadog-agent 6.0 in 2018. This PR adds space splitting to be consistent with datadog-agent expectations but keeps comma splitting to maintain backward compatibility.