Skip to content

feat(tag/measure): additive comma-separated --level (e.g. --level pipeline,job) #2387

Description

@eliebleton-manomano

Summary

Make --level on datadog-ci tag (and datadog-ci measure) additive: accept a comma-separated list so the same tags/measures are applied to several spans in one invocation, e.g. --level pipeline,job.

Today --level accepts exactly one of pipeline | job | stage | step, so applying the same tag to multiple span levels requires multiple invocations.

Motivation

Tags do not propagate between spans, and the level they belong on isn't always singular:

  • Some tags are useful at every level (e.g. team) — today you must call tag once per level.
  • Some tags should "flow down" to a few levels (e.g. job_maintainer belongs on both the job and the step span).

A comma-separated --level lets users express this directly instead of scripting N invocations.

Proposed behavior

  • --level accepts one or more of [pipeline, job, stage, step] as a comma-separated list (e.g. --level pipeline,job).
  • The full tag/measure set is sent to each listed span — one request per level.
  • Duplicate levels are ignored; order is irrelevant (levels are processed by span depth).
  • Validation is fail-fast: if any member is unknown or unsupported for the current provider, the command errors before sending anything.
  • A single value (--level pipeline) and all existing usage are unchanged.
  • --no-fail semantics are unchanged (narrow): it tolerates a failed submission request, but setup/config errors (missing API key, unsupported provider, GitHub diagnostic logs that can't be located) still exit non-zero. Per-level failures are reported with the offending level.
# apply team to both the pipeline and job spans in one call
datadog-ci tag --level pipeline,job --tags team:backend

# job_maintainer on both job and step
datadog-ci tag --level job,step --tags job_maintainer:alice

Scope

  • tag and measure (they share the level machinery).
  • README + CLI help updated for both.

Implementation notes

  • The per-level loop is shared between the two commands.
  • A per-execution cache avoids re-globbing and re-reading the GitHub Actions diagnostic logs once per level when several GitHub levels are requested (e.g. --level job,step); it is scoped to a single command run, never module-global.
  • No behavioral change for the existing single-level path or for --no-fail.

I have a working implementation with extensive tests and would be happy to open a PR if this is something the team would accept.

-- Claudelie

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions