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

Support space-separated DD_TAGS #289

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

Conversation

ebarendt
Copy link

@ebarendt ebarendt commented Dec 13, 2023

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.

@ebarendt ebarendt requested a review from a team as a code owner December 13, 2023 23:22
@@ -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(' '))

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:

Suggested change
to_tags_hash(dd_tags.split(' '))
to_tags_hash(dd_tags.split(/[, ]/))

Copy link
Author

Choose a reason for hiding this comment

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

great idea: 120c0d4

Copy link
Contributor

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.

Copy link
Author

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.

Copy link
Author

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.

Copy link
Author

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.

Copy link
Contributor

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.

Copy link
Author

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?

Copy link
Author

Choose a reason for hiding this comment

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

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

Successfully merging this pull request may close these issues.

3 participants