Skip to content

fix(ecs): [SVLS-9885] convert comma-separated globalTags for Agent DD_TAGS - #758

Merged
TalUsvyatsky merged 4 commits into
mainfrom
tal.usvyatsky/ecs-global-tags-comma
Oct 28, 2026
Merged

TalUsvyatsky merged 4 commits into
mainfrom
tal.usvyatsky/ecs-global-tags-comma

Conversation

@TalUsvyatsky

@TalUsvyatsky TalUsvyatsky commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

Fixes #742. globalTags is now a comma-separated list. The construct converts it to the format that each destination expects:

  • Agent DD_TAGS (Fargate and Managed Instances): commas become spaces, because the Agent separates tags with whitespace.
  • Fluent Bit dd_tags (Fargate): the log driver reads globalTags directly, not DD_TAGS. The output is the same as before.

The construct also adds synth warnings (Annotations.addWarningV2) for literal values it can check:

  • a globalTags item with whitespace in it (for example env:prod team:pay)
  • commas in environmentVariables.DD_TAGS when globalTags is not set (this value does not change)

The globalTags JSDoc, both READMEs, and the Fargate sample now show the comma-separated format.

Motivation

The construct copied globalTags unchanged to DD_TAGS. For "env:staging,version:abc", the Agent made one tag, env:staging_version:abc. The sample, tests, and code all used commas, so users who followed them got incorrect metric and trace tags. This has been the behavior since v2-2.3.0.

Testing Guidelines

  • Unit tests for toAgentTags (including tokens) and for each warning. Tokens get no warning.
  • Fargate tests for the Agent and log router output with commas, ", ", and one tag, with and without clusterName. Other tests check the precedence over environmentVariables.DD_TAGS and that env-only DD_TAGS does not change.
  • Managed Instances test for the converted DD_TAGS.
  • jest: 466 tests pass. eslint is clean.

Additional Notes

  • User-visible change: if globalTags has more than one comma-separated tag, the Agent now sends separate tags. Old combined values (for example team:a_owner:b) stop. Monitors, dashboards, or usage attribution that filter on these values need an update. Log tags do not change. Put this in the release notes.
  • Not in scope: DD_TAGS set only through environmentVariables does not change (a warning only). Normalizing it would change user-set env vars, so it goes in a future major.
  • No API changes.

Types of Changes

  • Bug fix
  • New feature
  • Breaking change
  • Misc (docs, refactoring, dependency upgrade, etc.)

Check all that apply

  • This PR's description is comprehensive
  • This PR contains breaking changes that are documented in the description
  • This PR introduces new APIs or parameters that are documented and unlikely to change in the foreseeable future
  • This PR impacts documentation, and it has been updated (or a ticket has been logged)
  • This PR's changes are covered by the automated tests
  • This PR collects user input/sensitive content into Datadog

🤖 Generated with Claude Code

- Convert comma-separated globalTags to whitespace-separated DD_TAGS for the Agent
- Keep comma-separated tags for the Fluent Bit log router
- Add synth warnings for whitespace/token in globalTags and commas in DD_TAGS
- Update docs, sample, and tests

Rationale: The Agent reads DD_TAGS as whitespace-separated, so comma-separated globalTags were parsed incorrectly. Ticket: SVLS-9885

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

This commit made by [/dd:git:commit:quick](https://github.com/DataDog/claude-marketplace/tree/main/dd/commands/git/commit/quick.md)
@TalUsvyatsky TalUsvyatsky changed the title [SVLS-9885] fix(ecs): convert comma-separated globalTags for Agent DD_TAGS fix(ecs): [SVLS-9885] convert comma-separated globalTags for Agent DD_TAGS Oct 20, 2026
@datadog-prod-us1-6

datadog-prod-us1-6 Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Pipelines

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: bdae3bc | Docs | Give us feedback!

TalUsvyatsky and others added 2 commits October 26, 2026 14:29
…bal-tags-comma

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Remove the token warning. A token inside globalTags converts correctly when
its value is one tag, so the warning fired on safe code. The construct now
warns only about literal values it can check at synth time.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@TalUsvyatsky
TalUsvyatsky marked this pull request as ready for review October 27, 2026 14:50
@TalUsvyatsky
TalUsvyatsky requested review from a team as code owners October 27, 2026 14:50

@stzou stzou left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, this fixes the reported case: the Agent gets whitespace-separated DD_TAGS, Fluent Bit keeps the comma form, and DD_TAGS only reaches the Agent container, so tracers aren't affected. Two non-blocking comments inline.

Comment thread src/ecs/utils.ts
* Converts comma-separated global tags to the whitespace-separated format that the Agent reads from DD_TAGS.
*/
export function toAgentTags(globalTags: string): string {
return globalTags.replace(/,/g, " ");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If globalTags comes from a token whose resolved value has commas (e.g. a CfnParameter or SSM parameter set to env:prod,team:pay), the replace sees no commas at synth, so the Agent still gets the comma form at deploy and nothing warns. Could toAgentTags use Fn.join(" ", Fn.split(",", globalTags)) when Token.isUnresolved(globalTags), so CloudFormation does the conversion? The current token test only covers a token inside literal tags.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good call, addressed in bdae3bc

Comment thread src/ecs/utils.ts
/**
* Converts comma-separated global tags to the whitespace-separated format that the Agent reads from DD_TAGS.
*/
export function toAgentTags(globalTags: string): string {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: the Agent also accepts DD_TAGS as a JSON array, so globalTags: '["env:prod","team:pay"]' used to give correct Agent tags. After this change it becomes ["env:prod" "team:pay"] and splits into broken tags. Probably rare, but could values starting with [ pass through unchanged, or get a warning?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch, I didn't realize this was also an accepted format. Updated to pass through unchanged in bdae3bc

…rays

- Convert globalTags that contain a token with Fn::Split and Fn::Join, so
  CloudFormation converts commas in the resolved value for DD_TAGS
- Pass a JSON array of tags through unchanged, because the Agent also
  accepts DD_TAGS as a JSON array
- Skip the tag warnings for JSON arrays

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@TalUsvyatsky
TalUsvyatsky merged commit 69bda21 into main Oct 28, 2026
10 of 11 checks passed
@TalUsvyatsky
TalUsvyatsky deleted the tal.usvyatsky/ecs-global-tags-comma branch October 28, 2026 15:33
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.

DatadogECSFargate: globalTags feeds both DD_TAGS and Fluent Bit dd_tags, which use different separators

2 participants