Add --span-id and --parent-id options to trace span#2397
Merged
Conversation
🎉 All green!🧪 All tests passed 🔗 Commit SHA: e583ac4 | Docs | Datadog PR Page | Give us feedback! |
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
force-pushed
the
rodrigo.roca/span-command-span-id-parent-id
branch
from
July 6, 2026 08:02
93768da to
e583ac4
Compare
rodrigo-roca
marked this pull request as ready for review
July 6, 2026 08:03
GabrielAnca
approved these changes
Jul 6, 2026
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]>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.