Skip to content

Add --span-id and --parent-id options to trace span#2397

Merged
rodrigo-roca merged 1 commit into
masterfrom
rodrigo.roca/span-command-span-id-parent-id
Jul 6, 2026
Merged

Add --span-id and --parent-id options to trace span#2397
rodrigo-roca merged 1 commit into
masterfrom
rodrigo.roca/span-command-span-id-parent-id

Conversation

@rodrigo-roca

@rodrigo-roca rodrigo-roca commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Adds two optional flags to datadog-ci trace span:

  • --span-id — assign an explicit span ID (hexadecimal). When omitted, a random ID is generated, as today.
  • --parent-id — nest this custom span under another custom span by referencing its span ID (hexadecimal). When omitted, the span attaches to its job/step as before.

Both are validated as hexadecimal; invalid values fail before any request is sent.

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Jul 6, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

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

@rodrigo-roca rodrigo-roca added the software-delivery Related to [coverage, deployment, dora, junit, measure, tag, trace] label Jul 6, 2026
Let callers assign an explicit span ID and nest a custom span under another
custom span, instead of every span being flat under the job. --span-id
defaults to a generated ID when omitted; --parent-id references another
span's ID and attaches to the job/step as before when omitted. Both are
validated as hexadecimal.

This makes it possible to assemble arbitrary span trees (e.g. from an
OpenTelemetry dump) via repeated `trace span` calls.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@rodrigo-roca
rodrigo-roca force-pushed the rodrigo.roca/span-command-span-id-parent-id branch from 93768da to e583ac4 Compare July 6, 2026 08:02
@rodrigo-roca
rodrigo-roca marked this pull request as ready for review July 6, 2026 08:03
@rodrigo-roca
rodrigo-roca requested review from a team as code owners July 6, 2026 08:03
@rodrigo-roca
rodrigo-roca requested a review from xinyeji July 6, 2026 08:03
eliebleton-manomano added a commit to eliebleton-manomano/datadog-ci that referenced this pull request Jul 6, 2026
…ustom spans

Adds `datadog-ci trace from-otel <file.json>`, which reads an OpenTelemetry
OTLP/JSON trace file (e.g. from an OTel Collector `file` exporter, otel-cli, or a
tool's built-in exporter) and reports each span to Datadog as a CI Visibility
custom span. Addresses the request in DataDog#2385.

Hierarchy uses the same `span_id`/`parent_id` convention that `trace span`
adopts in DataDog#2397: each span gets a `span_id` derived from the OTLP file, child
spans set `parent_id` to their parent's `span_id`, and root spans attach to the
CI job/step. The originating OTel trace id is preserved as an `otel.trace_id`
tag for correlation. ID normalization accepts both hex and base64 encodings, and
enums/timestamps accept both the numeric and proto3 string forms the Go
Collector emits.

- Base-only command under the existing `trace` scope; gated at runtime via
  `DD_BETA_COMMANDS_ENABLED` (the scope is non-beta, so scope-level gating can't
  express it).
- No new dependencies: OTLP wire types are a small local subset (the SDK doesn't
  export them publicly and would drag in the transformer chain).
- Reuses `CustomSpanCommand` for API-key/CI/git tag assembly and the intake POST;
  adds an additive `executeReportCustomSpans` batch method and threads an optional
  `parentId` through `executeReportCustomSpan` (single-span payload and tag/measure
  precedence unchanged). OTel attributes sit below git/CI context tags so they
  cannot clobber authoritative values.
- `--max-spans` (default 1000) caps volume; malformed input yields a clean exit 1.
- Two behaviors intentionally match the existing `trace span`: `DD_TAGS` takes
  precedence over `--tags`, and a failed send is logged but does not fail the
  command.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@rodrigo-roca
rodrigo-roca merged commit d80a1cf into master Jul 6, 2026
34 checks passed
@rodrigo-roca
rodrigo-roca deleted the rodrigo.roca/span-command-span-id-parent-id branch July 6, 2026 11:59
@TalUsvyatsky TalUsvyatsky mentioned this pull request Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

software-delivery Related to [coverage, deployment, dora, junit, measure, tag, trace]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants