feat(tag): comma-separated --level (e.g. --level pipeline,job)#2388
Conversation
Drarig29
left a comment
There was a problem hiding this comment.
LGTM for tag, just a few nits.
But for measure, can you really think of a measure that would be interesting to set with the same value at multiple levels? It sounds like it's more of a feature for tag only 🤔
Numbers are meant to be aggregated, so I would expect this:
- Pipeline:
binary.size:1000- Job 1:
binary.size:600 - Job 2:
binary.size:400
- Job 1:
And since we market measures as "numerical tags", I'd assume we overwrite the values instead of appending. I'll check with the team.
But long story short, it looks like you are only interested for the tag command, so I'd say it's safer to split the effort... because it's indeed a low-hanging fruit on the tag side.
|
Also, I ran the CI and it's failing. You can run the tests locally with Thanks again for the effort 🙏 |
Allow `--level pipeline,job` so the same tags/measures are applied to multiple span levels in one invocation. Levels are deduped and validated fail-fast; one request is sent per level. Adds a shared per-level loop (`processLevels`) used by both `tag` and `measure`, and a per-execution cache so the GitHub Actions diagnostic logs are located and read once even when several levels need them (e.g. `--level job,step`). Single-level usage and `--no-fail` semantics are unchanged: `--no-fail` still tolerates a failed submission but not setup/config errors, which are reported with the offending level. Refs DataDog#2387 Co-Authored-By: Claude Opus 4.8 <[email protected]>
These tests assumed the host filesystem lacks GitHub Worker_*.log diagnostic files under the well-known fallback dirs to force the `step` enrichment to fail. That assumption doesn't hold on real GitHub Actions runners, causing flaky CI failures. Mock fs.readdirSync to throw ENOENT explicitly instead.
b8a59c0 to
a61a60e
Compare
…EADME Reviewer feedback on DataDog#2388: measure semantics for multi-level are unclear (should measures be aggregated/overwritten per level instead of duplicated?), so revert measure back to single-level --level. tag keeps additive comma-separated --level. Also applies 3 README wording nits for tag. Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
Thanks for the thorough review, @Drarig29!
-- Claudelie |
--level (e.g. --level pipeline,job)--level (e.g. --level pipeline,job)
What and why
Makes
--levelondatadog-ci tagadditive: it now accepts a comma-separated list, so the same tags can be applied to several spans in one invocation (e.g.--level pipeline,job).Tags don't propagate between spans, and the level they belong on isn't always singular — e.g.
teamis useful at every level, andjob_maintainerbelongs on bothjobandstep. Today that requires N separate invocations.Closes #2387.
Behavior
--levelaccepts one or more of[pipeline, job, stage, step]as a comma-separated list.--no-fail: it still tolerates a failed submission request but not setup/config errors (missing API key, unsupported provider, GitHub diagnostic logs that can't be located), which exit non-zero with the offending level named.Implementation
processLevels()helper drives the per-level loop for both commands; each level is enriched on its own copy ofciEnvso e.g. the step index never leaks into the job request.GithubLogCachelocates and reads the GitHub Actions diagnostic logs at most once even when several levels need them (e.g.--level job,step). It is scoped to a single command run, never module-global, so it can't leak across commands or tests.tagREADMEs and CLI help updated.Tests
parseLevelsunit tests (single/multi/sort/dedupe/whitespace/empty/unknown/unsupported).processLevelstests: per-execution caching (logs read once acrossjob,step), orchestration-id selection cached, and fatal-error propagation annotated with the level.tag: one request per level, dedupe, fail-fast, GitHubjob,stepenrichment, and--no-failsemantics.yarn build,yarn lint, and the affected test suites pass.-- Claudelie
🤖 Generated with Claude Code