Skip to content

Add the tag registry and map OpenTelemetry tag names through it (otlp - tag registry - phase 1) - #12354

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 5 commits into
masterfrom
dougqh/tag-registry-otel
Oct 8, 2026
Merged

gh-worker-dd-mergequeue-cf854d[bot] merged 5 commits into
masterfrom
dougqh/tag-registry-otel

Conversation

@dougqh

@dougqh dougqh commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

What Does This Do

Extracts the tag registry — generated tag ids plus name resolution — from the dense-store stack, so it can land on its own, and uses it to emit OTLP attributes under their OpenTelemetry names.

A tag id is identity only: a globally unique serial plus the trace/span level bit. It says what a tag is, never how it is stored or set. Bits [47-32] are documented and held vacant for the co-occurrence slot the dense tag store assigns, which lands with that store.

On top of that identity, each tag gets a per-namespace name:

  • keyOf is many→one — a Datadog name or an OpenTelemetry name both resolve to the one id.
  • datadogNameOf / openTelemetryNameOf take the name back out per namespace; openTelemetryTagOf is the one place the pass-through policy lives (declared rename, else the Datadog name).
  • OtlpTraceProto and OtlpTraceJson emit known tags — including intercepted Metadata fields such as http.status_code, and service.name — under their OpenTelemetry names when trace.otel.semantics.enabled is on, and under Datadog names otherwise.

Aliases are one tag, on write as well as on export

  • TagMap canonicalizes a known tag's OpenTelemetry spelling to its Datadog name at Entry construction, so setting http.request.method and http.method on one span yields one entry, not two attributes with the same OTLP key. Lookup (getTag, contains, removal) canonicalizes the same way.
  • TagInterceptor treats both spellings alike for every intercepted tag that has a rename (service, http.method, http.status_code, http.url, db.statement), so behavior no longer depends on the spelling, or on whether the attribute was set on the builder or after start. db.statement / db.query.text is consumed into resource.name under either spelling, per the policy noted in tag-conventions.yaml.
  • DDSpanContext.getTag() recognizes the http.response.status_code alias of the intercepted status.

Conventions rules the generator enforces

tag-conventions.yaml is the single, language-agnostic source. Beyond parsing, the generator rejects:

  • A second declaration of a tag, even one that agrees. A tag shared by several span types lives on their common parent or a mixin; any other span type uses { ref: <dd-name>, required: <level> }, which may override only the requirement level. http.url moved to the shared http parent.
  • A rename on a concrete span type without span-kind-neutral: true. Canonicalization ignores span kind, so a rename is only right if the OpenTelemetry attribute means that tag on every span kind it appears on. Renames in a shared scope need no flag.
  • An OpenTelemetry name claimed by two tags or equal to a Datadog name, a missing dd-name, a ref to an undeclared tag, and colliding generated constant names.

Renames deliberately left out

Each of these maps differently by span kind, which a flat rename cannot express, so it passes through under its Datadog name for now:

  • http.hostname → server.address — on client spans OTel's server.address is the remote server.
  • network.client.ip → network.peer.address — OTel's network.peer.address is the remote end on every span kind.
  • http.query.string → url.query — url.full already carries the query, and QueryObfuscator would append it twice.

A follow-on will model this directly (relative vs absolute names, resolved by span direction) rather than as renames.

Build

The generator is a build-logic plugin (dd-trace-java.tag-registry-generator). KnownTags.java and its reports are generated under internal-api/build/generated/tag-registry and wired into the main source set, so compileJava always compiles against the current YAML — nothing generated is committed. Tag ids are not a stable contract, so renumbering when tags are added is expected; the YAML is what gets reviewed.

Why Entry.tagId() is not memoized

TagMap$Entry is the tracer's largest allocation source, one per tag per span on the app thread. A memo field widens every entry and adds a putfield per construction, for a value only OTLP serialization reads — on the background thread, once per entry. Resolving on demand is cheaper. (The constructor does now pay one StringIndex lookup to canonicalize the name; that is the price of aliases being one tag.)

Why intercept modelling is not in the registry

The registry originally mirrored TagInterceptor.needsIntercept as an id bit. It had already drifted from the switch that is the actual authority, and nothing consumed it. Interception is a TagInterceptor property; the classification returns with the work that consumes it (an id→handler dispatch that retires the switch), and adding it then is purely additive.

Why there is no resolver registration

KnownTagCodec (bit layout, naming policy) and generated KnownTags (the name↔id tables) are two halves of one class. They were first joined at runtime — KnownTags registered its resolver — which left a window where an early read latched an empty fallback permanently, with no error. Since KnownTags is generated into the same module and package, KnownTagCodec names KnownTags.RESOLVER directly: reading a name is what initializes the registry, so the window is gone, along with init(), the CoreTracer coupling and the fallback codec. A nested holder remains so the codec finishes initializing before KnownTags (which calls back into it) starts.

Motivation

PR #12230 maps OpenTelemetry tag names via the registry, and another team is waiting on it. It was based on #12047, which sits on the dense store (#12045) and the colored-slot encoding (#12046), so the OTel work was blocked behind the whole storage stack. TagRegistry.build() already separated serial assignment and name validation from graph coloring; this PR is the identity-and-names half, targeting master directly.

Additional Notes

  • Dropped relative to Generate KnownTags from tag-conventions via the tag-registry code generator (phase 2 - dense tag storage) #12047: graph coloring, slots, dense-store routing, and the layout-only reports. Re-adding coloring later is purely additive, since the slot window is left zero and documented.
  • Every declared tag is registered, including ones whose span type is not modeled yet (ci_visibility's test.*); the gap is reported in resolved-tags.txt rather than silently dropped.
  • Known inaccuracy: the peer mixin models peer.* as client-only, though server spans also carry peer.ipv4/6 / peer.port (for the client's address). Harmless today — none of those tags has an OpenTelemetry name — and addressed by the follow-on.
  • @TableTest for OpenTelemetry14ConventionsTest is left to the OTel/OTLP owners.

Contributor Checklist

  • Format code with ./gradlew spotlessApply
  • build-logic :tag-registry:test (generator unit + TestKit) green
  • :internal-api:test (KnownTags*, TagMap*), :internal-api:spotlessCheck green
  • :dd-trace-core:test (*otlp*, *taginterceptor*) green
  • :dd-java-agent:instrumentation:opentelemetry:opentelemetry-1.4:test (OpenTelemetry14ConventionsTest) green

Jira ticket

N/A

🤖 Generated with Claude Code

@dougqh dougqh added comp: core Tracer core tag: ai generated Largely based on code generated by an AI or LLM tag: no release notes Changes to exclude from release notes type: refactoring labels Aug 31, 2026
@dougqh

dougqh commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a98850bf24

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread tag-conventions.yaml
Comment thread dd-trace-core/src/main/java/datadog/trace/core/otlp/trace/OtlpTraceProto.java Outdated
Comment thread internal-api/src/main/java/datadog/trace/api/TagMap.java Outdated
Comment thread tag-conventions.java.yaml Outdated
Comment thread buildSrc/src/main/kotlin/datadog/gradle/plugin/tags/TagConventions.kt Outdated
@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
• Patch Coverage: 85.90%
• Overall Coverage: 59.35% (+0.04%)

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

@dd-octo-sts

dd-octo-sts Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

🟡 Java Benchmark SLOs — Performance SLO warning (near threshold)

Suite Status
Startup 🟡 warning

SLO thresholds are defined here based on automatically generated metrics. A warning is raised when results are within 5% of the threshold.

PR vs. master results
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 13.97 s 13.84 s [+0.1%; +1.7%] (maybe worse)
startup:insecure-bank:tracing:Agent 12.88 s 12.91 s [-0.9%; +0.4%] (no difference)
startup:petclinic:appsec:Agent 17.73 s 17.47 s [+0.6%; +2.4%] (maybe worse)
startup:petclinic:iast:Agent 17.46 s 17.52 s [-1.3%; +0.7%] (no difference)
startup:petclinic:profiling:Agent 16.96 s 16.96 s [-4.7%; +4.6%] (no difference)
startup:petclinic:sca:Agent 17.73 s 17.63 s [-0.3%; +1.5%] (no difference)
startup:petclinic:tracing:Agent 16.57 s 16.67 s [-1.6%; +0.4%] (no difference)

Commit: 58386047 · CI Pipeline · Benchmarking Platform UI


Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion.

@dougqh
dougqh force-pushed the dougqh/tag-registry-otel branch 2 times, most recently from 6d5eb31 to d712502 Compare August 31, 2026 21:12
Comment thread dd-trace-core/src/main/java/datadog/trace/core/otlp/trace/OtlpTraceProto.java Outdated
Comment thread dd-trace-core/src/main/java/datadog/trace/core/CoreTracer.java Outdated
@dougqh

dougqh commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d712502ee8

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread tag-conventions.java.yaml Outdated
Comment thread tag-conventions.java.yaml Outdated
Comment thread tag-conventions.java.yaml Outdated
@dougqh
dougqh force-pushed the dougqh/tag-registry-otel branch from 80011c9 to 6439499 Compare September 2, 2026 13:14
@dougqh

dougqh commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9e1491718c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread dd-trace-core/src/main/java/datadog/trace/core/otlp/trace/OtlpTraceProto.java Outdated
Comment thread buildSrc/src/main/kotlin/datadog/gradle/plugin/tags/TagConventions.kt Outdated
Comment thread dd-trace-core/src/main/java/datadog/trace/core/otlp/trace/OtlpTraceProto.java Outdated
@dougqh
dougqh force-pushed the dougqh/tag-registry-otel branch from 9e14917 to 8d60761 Compare September 2, 2026 18:21
@dougqh dougqh changed the title Add the tag registry and map OpenTelemetry tag names through it Add the tag registry and map OpenTelemetry tag names through it (otel/otlp - priority) Sep 15, 2026
@dougqh dougqh changed the title Add the tag registry and map OpenTelemetry tag names through it (otel/otlp - priority) Add the tag registry and map OpenTelemetry tag names through it (otel/otlp) Sep 15, 2026
Comment thread internal-api/src/main/java/datadog/trace/api/TagMap.java Outdated
Comment thread internal-api/src/main/java/datadog/trace/api/TagMap.java
Comment thread internal-api/src/main/java/datadog/trace/api/TagMap.java Outdated
@dougqh
dougqh marked this pull request as ready for review September 16, 2026 15:25
@dougqh
dougqh requested review from a team as code owners September 16, 2026 15:25
@dougqh
dougqh removed the request for review from a team September 16, 2026 15:25
@dougqh
dougqh removed this pull request from stack #12687 October 7, 2026 13:16
@dougqh
dougqh enabled auto-merge October 7, 2026 19:18
@dougqh
dougqh added this pull request to the merge queue Oct 7, 2026
@dd-octo-sts

dd-octo-sts Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-10-07 20:17:53 UTC ℹ️ Start processing command /merge


2026-10-07 20:17:57 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 1h (p90).


2026-10-07 20:36:03 UTC ❌ MergeQueue: The build pipeline contains failing jobs for this merge request

Build pipeline has failing jobs for 46f23b3:

⚠️ Do NOT retry failed jobs directly (why?).

What to do next?

  • Investigate the failures and when ready, re-add your pull request to the queue!
  • If your PR checks are green, try to rebase/merge. It might be because the CI run is a bit old.
  • Any question, go check the FAQ.
Details

Since those jobs are not marked as being allowed to fail, the pipeline will most likely fail.
Therefore, and to allow other builds to be processed, this merge request has been rejected and the pipeline got canceled.

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 7, 2026
@dougqh

dougqh commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-10-07 20:41:15 UTC ℹ️ Start processing command /merge


2026-10-07 20:41:19 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 1h (p90).


2026-10-07 20:58:55 UTC ❌ MergeQueue: The build pipeline contains failing jobs for this merge request

Build pipeline has failing jobs for 2e2f367:

⚠️ Do NOT retry failed jobs directly (why?).

What to do next?

  • Investigate the failures and when ready, re-add your pull request to the queue!
  • If your PR checks are green, try to rebase/merge. It might be because the CI run is a bit old.
  • Any question, go check the FAQ.
Details

Since those jobs are not marked as being allowed to fail, the pipeline will most likely fail.
Therefore, and to allow other builds to be processed, this merge request has been rejected and the pipeline got canceled.

@dougqh

dougqh commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-10-07 21:00:12 UTC ℹ️ Start processing command /merge


2026-10-07 21:00:16 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 1h (p90).


2026-10-07 23:00:59 UTC ❌ MergeQueue: The build pipeline has timeout

The merge request has been interrupted because the build 4368097690923153236 took longer than expected. The current limit for the base branch 'master' is 120 minutes.

Possible reasons:

  • PR is conflicting with its base branch

@dougqh

dougqh commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-10-08 12:34:15 UTC ℹ️ Start processing command /merge


2026-10-08 12:34:22 UTC ℹ️ MergeQueue: Pull request is not mergeable yet

It will be processed automatically as soon as GitHub reports it as mergeable. View in MergeQueue UI.

  • Run /code blockers to see what is blocking it.
  • Run /remove to cancel it.

2026-10-08 17:31:14 UTC ⚠️ MergeQueue: This merge request was unqueued

devflow unqueued this merge request: It did not become mergeable within the expected time

@dougqh
dougqh enabled auto-merge October 8, 2026 19:20
@dougqh
dougqh added this pull request to the merge queue Oct 8, 2026
@dd-octo-sts

dd-octo-sts Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-10-08 19:57:12 UTC ℹ️ Start processing command /merge


2026-10-08 19:57:16 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 1h (p90).


2026-10-08 20:15:29 UTC ❌ MergeQueue: The build pipeline contains failing jobs for this merge request

Build pipeline has failing jobs for 06b54a5:

⚠️ Do NOT retry failed jobs directly (why?).

What to do next?

  • Investigate the failures and when ready, re-add your pull request to the queue!
  • If your PR checks are green, try to rebase/merge. It might be because the CI run is a bit old.
  • Any question, go check the FAQ.
Details

Since those jobs are not marked as being allowed to fail, the pipeline will most likely fail.
Therefore, and to allow other builds to be processed, this merge request has been rejected and the pipeline got canceled.

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 8, 2026
@dougqh
dougqh added this pull request to the merge queue Oct 8, 2026
@dd-octo-sts

dd-octo-sts Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-10-08 20:20:59 UTC ℹ️ Start processing command /merge


2026-10-08 20:21:03 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 1h (p90).


2026-10-08 21:33:39 UTC ℹ️ MergeQueue: This merge request was merged

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 8, 2026
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit bdba988 into master Oct 8, 2026
609 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the dougqh/tag-registry-otel branch October 8, 2026 21:33
@github-actions github-actions Bot added this to the 1.68.0 milestone Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: core Tracer core tag: ai generated Largely based on code generated by an AI or LLM tag: no release notes Changes to exclude from release notes type: refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants