Skip to content

Set Kafka span tags by id (tag registry rollout) - #13192

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 2 commits into
masterfrom
dougqh/kafka-tag-ids
Nov 6, 2026
Merged

gh-worker-dd-mergequeue-cf854d[bot] merged 2 commits into
masterfrom
dougqh/kafka-tag-ids

Conversation

@dougqh

@dougqh dougqh commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

What Does This Do

Kafka's producer, consumer and Streams spans now set their tags with KnownTags ids instead of names. That's 35 call sites in kafka-clients-0.11, kafka-clients-3.8 and kafka-streams-0.11.

tag was (InstrumentationTags, String) now (KnownTags id, long)
partition / offset PARTITION / OFFSET PARTITION / OFFSET
messaging.destination.name MESSAGING_DESTINATION_NAME MESSAGING_DESTINATION_NAME
kafka.group CONSUMER_GROUP KAFKA_GROUP
messaging.kafka.cluster.id KAFKA_CLUSTER_ID MESSAGING_KAFKA_CLUSTER_ID
messaging.kafka.bootstrap.servers KAFKA_BOOTSTRAP_SERVERS MESSAGING_KAFKA_BOOTSTRAP_SERVERS
record.queue_time_ms, kafka.records_count, tombstone, processor.name InstrumentationTags.* KnownTags.*, same name

Many ids have the same simple name as the string constant they replace. The static import is what changes, from InstrumentationTags to KnownTags.

Motivation

This is the first instrumentation moved onto ids. Every Kafka tag was already registered (the kafka mixin, plus kafka.records_count and record.queue_time_ms), so the port is a mechanical swap. Setting by id skips the name-to-id lookup that setTag(String, …) does on every call.

Additional Notes

  • No behavior change. For a known tag, the core span's setTag(String, …) resolves the name and calls setTag(long, …). This PR calls the id setter directly, so storage and interception are unchanged. Non-core spans fall back to the name through the default method.
  • Overloads stay in the same category. ProducerRecord.partition() is a boxed Integer, so it still resolves to the Object overload, as it did with a String key.
  • Advice-safe. setTag(long, …) is a default instance method on AgentSpan, not a static interface method, and the ids are compile-time constants that get inlined.
  • Stacked on Name KnownTags ids after their tags and fail on constant clashes (tag registry rollout) #13061, for its bare id names (MESSAGING_KAFKA_CLUSTER_ID).
  • Testing:
    • kafka-clients-0.11: test, forkedTest, latestDepTest and latestDepForkedTest pass (125 tests).
    • kafka-clients-3.8: test passes (23 tests).
    • kafka-streams-0.11 latestDepTest fails with 7 traces where it expects 3, because of extra kafka.poll traces. It fails the same way on the base branch without this change, so it's pre-existing. The tags on its spans are correct.

🤖 Generated with Claude Code

@dougqh dougqh added tag: no release notes Changes to exclude from release notes type: refactoring inst: kafka Kafka instrumentation tag: ai generated Largely based on code generated by an AI or LLM labels Nov 3, 2026
@dougqh
dougqh marked this pull request as ready for review November 3, 2026 22:33
@dougqh
dougqh requested review from a team as code owners November 3, 2026 22:33
@dougqh
dougqh requested review from ygree and removed request for a team November 3, 2026 22:33
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T22:35:55.501723Z 17e2fea Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@datadog-datadog-prod-us1 datadog-datadog-prod-us1 Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bits Code Review: PASS

More details

The Kafka tag IDs match the original tag names and preserve overload selection, tag interception, and fallback behavior for non-core spans.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 17e2fea

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
• Patch Coverage: 100.00%
• Overall Coverage: 59.98% (-0.00%)

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

@dd-octo-sts

dd-octo-sts Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

🟢 Java Benchmark SLOs — All performance SLOs passed

Suite Status
Startup 🟢 pass

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 14.79 s 14.65 s [+0.3%; +1.7%] (maybe worse)
startup:insecure-bank:tracing:Agent 13.60 s 13.68 s [-1.4%; +0.1%] (no difference)
startup:petclinic:appsec:Agent 17.30 s 17.08 s [+0.5%; +2.1%] (maybe worse)
startup:petclinic:iast:Agent 17.13 s 17.18 s [-1.0%; +0.4%] (no difference)
startup:petclinic:profiling:Agent 16.92 s 16.88 s [-1.1%; +1.6%] (no difference)
startup:petclinic:sca:Agent 16.52 s 17.17 s [-8.2%; +0.5%] (no difference)
startup:petclinic:tracing:Agent 16.28 s 16.21 s [-0.4%; +1.4%] (no difference)

Commit: 197a6245 · 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.

@ygree ygree left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

IDM approved

@dougqh
dougqh force-pushed the dougqh/kafka-tag-ids branch from 17e2fea to 20319a0 Compare November 5, 2026 20:34
@dougqh
dougqh force-pushed the dougqh/known-tags-full-suffix branch from d983320 to 7e702ac Compare November 5, 2026 20:44
@dougqh
dougqh requested review from a team as code owners November 5, 2026 20:44
@dougqh
dougqh requested review from PerfectSlayer, dromanol, jandro996 and mtoffl01 and removed request for a team November 5, 2026 20:44
@dougqh
dougqh force-pushed the dougqh/kafka-tag-ids branch from 20319a0 to 6af5cb4 Compare November 5, 2026 20:50

@datadog-datadog-prod-us1 datadog-datadog-prod-us1 Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bits Code Review: FAIL

The new constant-collision rule rejects the existing foo/foo.name fixture, preventing Gradle plugin compilation and cache tests from reaching their assertions.

Open Bits AI session

🤖 Bits Code Review · Commit 20319a0


Findings that could not be posted inline

build-logic/tag-registry/src/main/kotlin/datadog/buildlogic/tagRegistry/KnownTagsEmitter.kt:47

P2 Update the plugin-test fixture for the new collision rule

The existing TagRegistryGeneratorPluginTest shared fixture declares both foo and foo.name without an overlay. These claims assign FOO_NAME to both foo's string constant and foo.name's ID, causing generation to throw instead of succeeding. Compilation, caching, and custom-output tests consequently fail before their assertions. Rename a fixture tag or configure a java_names overlay in the shared fixture.

React: 👍 useful · 👎 wrong · 😕 unclear · 👀 right, but not acting on it

What each reaction means
  • 👍 Useful: correct, and you're fixing it or will.
  • 👎 Wrong: the finding is incorrect, for example the bug can't happen or the code was misread.
  • 😕 Unclear: you can't tell what it means or why it matters.
  • 👀 Right, not acting: correct, but intended, out of scope for this PR, a known risk, or too minor.

🤖 Bits Code Review · Open Bits AI session

Base automatically changed from dougqh/known-tags-full-suffix to master November 6, 2026 17:24
dougqh and others added 2 commits November 6, 2026 12:28
Kafka's producer, consumer and Streams spans now set their tags with
KnownTags ids instead of names, skipping the name lookup on every set.
All of them were already registered (the kafka mixin, plus
kafka.records_count and record.queue_time_ms), so this is a mechanical
swap; the core span stores and intercepts an id exactly as it did the
name it resolved to.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#13061 now names an id after its tag with no _ID suffix. Rename only;
the ids are the same values.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dougqh
dougqh force-pushed the dougqh/kafka-tag-ids branch from 6af5cb4 to 197a624 Compare November 6, 2026 17:30

@datadog-datadog-prod-us1 datadog-datadog-prod-us1 Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bits Code Review: PASS

More details

The Kafka ID setters preserve existing tag names and setter overloads, and the stacked generator’s constant renames are consistently reflected in callers.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 6af5cb4

@dougqh

dougqh commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-11-06 18:36:36 UTC ℹ️ Start processing command /merge


2026-11-06 18:36:47 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-11-06 18:50:06 UTC ℹ️ MergeQueue: merge request added to the queue

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


2026-11-06 19:51:57 UTC ℹ️ MergeQueue: This merge request was merged

@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit 11ebdfe into master Nov 6, 2026
683 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the dougqh/kafka-tag-ids branch November 6, 2026 19:51
@github-actions github-actions Bot added this to the 1.69.0 milestone Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

inst: kafka Kafka instrumentation 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.

2 participants