Skip to content

Accept space separated DD_TAGS - #338

Open
theluckystrike wants to merge 1 commit into
DataDog:masterfrom
theluckystrike:space-separated-dd-tags
Open

theluckystrike wants to merge 1 commit into
DataDog:masterfrom
theluckystrike:space-separated-dd-tags

Conversation

@theluckystrike

Copy link
Copy Markdown

Fixes #325.

The Datadog Agent docs and the Heroku buildpack describe DD_TAGS as a space separated list (for example DD_TAGS="simple-tag-0 tag-key-1:tag-value-1"), but TagSerializer#dd_tags only split on commas. With a space separated value the whole string became one tag, and to_tags_hash dropped it or kept it as a single broken tag, so none of the tags reached the metrics.

What I changed in dd_tags:

  • If the value contains a comma, it is split on commas as before. That keeps every existing comma separated setup working, including tag values that contain spaces (team:my team,env:qa).
  • Otherwise it is split on whitespace, which matches the Agent and buildpack format.
  • Each entry is stripped and empty entries are dropped, so "a, b" gives b instead of b, 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 spec passes (662 examples, 0 failures, 15 pending) on Ruby 4.0.2.

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
@theluckystrike
theluckystrike requested a review from a team as a code owner November 20, 2026 02:42
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T02:44:09.844702Z ee9f9b7 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +88 to +89
separator = dd_tags.include?(',') ? ',' : /\s+/
tags = dd_tags.split(separator).map(&:strip).reject(&:empty?)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

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.

Space separated tags in DD_TAGS are not included in DogStatsD

1 participant