Repository navigation
Accept space separated DD_TAGS - #338
theluckystrike wants to merge 1 commit into
Conversation
The Datadog Agent and the Heroku buildpack document DD_TAGS as a space separated list, but the tag serializer only split it on commas, so DD_TAGS="team:qa env:staging" became one broken tag. Split on commas when the value has one, so existing values (including tag values that contain spaces) keep working, and on whitespace otherwise. Surrounding whitespace and empty entries are dropped. Fixes DataDog#325
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ee9f9b7eee
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| separator = dd_tags.include?(',') ? ',' : /\s+/ | ||
| tags = dd_tags.split(separator).map(&:strip).reject(&:empty?) |
There was a problem hiding this comment.
Preserve spaces in existing single-tag DD_TAGS values
For an existing configuration containing just one tag with spaces, such as DD_TAGS="team:my team", the absence of a comma now selects whitespace parsing. This produces ["team:my", "team"], and to_tags_hash overwrites the first entry with the second, so the serializer emits only team instead of the previous team:my team. Upgrading therefore silently removes the tag value from metrics, events, and service checks using this configuration. Preserve the legacy single-tag case or make the ambiguous delimiter choice explicit; the new compatibility test only exercises values containing a comma.
Useful? React with 👍 / 👎.
Fixes #325.
The Datadog Agent docs and the Heroku buildpack describe
DD_TAGSas a space separated list (for exampleDD_TAGS="simple-tag-0 tag-key-1:tag-value-1"), butTagSerializer#dd_tagsonly split on commas. With a space separated value the whole string became one tag, andto_tags_hashdropped it or kept it as a single broken tag, so none of the tags reached the metrics.What I changed in
dd_tags:team:my team,env:qa)."a, b"givesbinstead ofb, and extra spaces do not create empty tags.This is the same idea as #289, which was closed by its author last year without a review. I kept the comma rule first so the change cannot break current users.
Tests: two new specs in
tag_serializer_spec.rb, one for a space separated value with extra spaces and one for a comma separated value with a space inside a tag value. Both fail on master and pass with the change.bundle exec rake specpasses (662 examples, 0 failures, 15 pending) on Ruby 4.0.2.