Repository navigation
Name KnownTags ids after their tags and fail on constant clashes (tag registry rollout) - #13061
Conversation
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
fc3c6a5 to
66be8a1
Compare
There was a problem hiding this comment.
Validation of tag naming/constant clashes in KnownTagsEmitter occurs only after TagRegistryGenerator has already deleted the previous output, meaning a failed regeneration permanently destroys the last valid KnownTags.java. The fix is to compute and fully validate the generated source (including collision checks) before clearing the destination directory.
🤖 Bits Code Review · Commit fc3c6a5
AlexeyKuznetsov-DD
left a comment
There was a problem hiding this comment.
LGTM, left a suggestion about suffixes, to avoid potential ugly _NAME_NAME or _ID_ID, since name and id is very common in naming.
mcculls
left a comment
There was a problem hiding this comment.
Bruce's suggestion of using DB_POOL_NAME for the tag-id, and DB_POOL_NAME_TAG or similar for the tag-name also makes sense.
@mcculls Yes, I think that's my preference, too. I'm just waiting a bit to see what others think. |
JAVA_CONSTANT_BASE had landed between them and parse, taking both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The clash check runs while emitting KnownTags, which happened after the output directory was cleared, so a clash lost the last valid output. Render all outputs before touching the directory. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An id is what instrumentation sets, so it takes the tag's bare name: span.setTag(DB_POOL_NAME, ...) reads like the name it replaces. The string name keeps its full suffix (DB_POOL_NAME_NAME), as do the serial and OpenTelemetry-name constants, and the per-direction aliases are bare too (Outbound.SERVER_ADDRESS). The clash check now also covers a tag x.name (id X_NAME) against a tag x (name X_NAME). Every KnownTags.*_ID reference is renamed to match. TagStoreTest, which static-imported Tags.HTTP_ROUTE alongside the id, names the string as Tags.HTTP_ROUTE. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Bare ID naming makes the existing foo/foo.name plugin fixture collide at FOO_NAME, breaking generation-dependent tests. A remaining _ID reflection filter also silently excludes most tags from bucket-hash checks.
🤖 Bits Code Review · Commit d983320
Tags foo and foo.name both claim FOO_NAME now that ids are bare (foo's name, foo.name's id), so the fixture's second tag is foo.bar. Also TagStoreTest's import order under Spotless 8.11. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
d983320 to
7e702ac
Compare
#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>
#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>
#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>
#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>
knownTagIds() picked long fields ending in _ID, so once ids went bare it selected only the 16 tags whose names end in id and the bucket-hash and slot checks quietly shrank. It now takes every static long, and a new test asserts there is one per serial. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
#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>
#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>
#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>
#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>
#13061 named 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>
#13061 named 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>
…13193) Set database client and JDBC span tags by id DatabaseClientDecorator, which every database client's spans go through, and the JDBC instrumentation now set their tags with KnownTags ids instead of names. All of them were already registered; the "_dd.dbm_trace_injected" literal becomes the same id as its constant. JDBCDecorator's setTagIfPresent takes the id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Use the bare KnownTags id names #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> Co-authored-by: douglas.hawkins <douglas.hawkins@datadoghq.com>
Set Kafka span tags by id 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> Use the bare KnownTags id names #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> Co-authored-by: douglas.hawkins <douglas.hawkins@datadoghq.com>
Set servlet and JSP span tags by id The javax and jakarta servlet instrumentations and JSP set their tags (servlet.context, servlet.path, user.principal, timeout, jsp.*) with KnownTags ids instead of names or string literals. All were already registered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Use the bare KnownTags id names #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> Co-authored-by: douglas.hawkins <douglas.hawkins@datadoghq.com>
Set Spring web span tags by id Spring Web MVC (3.1 and 6.0) and Spring WebFlux set view.name, view.type, handler.type, request.predicate, and the WebFlux client's cancellation event and message with KnownTags ids instead of string literals. All were already registered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Use the bare KnownTags id names #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> Co-authored-by: douglas.hawkins <douglas.hawkins@datadoghq.com>
) Have the span own its tag stores directly DDSpanContext holds its IdStore (also its tag lock) and its HashStore instead of one TagMap, and routes each write to the store that holds the tag: a name is resolved once and routed, and a write by id goes straight to the id store. The custom store is borrowed read-only from the read-through parent until the span's first custom write. The eager post-processors already read and write the span through TagStore. The lazy post-processors and the serializer still take a TagMap: the span builds a view over its stores once, at serialization, and caches it (about 32 B per span until they move to TagStore). TagMap.Internals, the core's trusted side door, is gone: the stores are the direct path. The constructors drop the unused tagsSize parameter. Allocation, 7-span web-request trace: +104 B (+1.3%), from the new DDSpanContext fields (8 B per span) and the first custom store. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Use the bare KnownTags id names #13061 named 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> Remove the tag when a map write carries a null value setAllTags and unsafeSetTag passed null values straight to the stores, which take none, leaving a null-valued entry: the tag still showed in getTags() and could break serialization. TagMap.set removed the tag on null, as setTag does; route a null to removal again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Keep copying root-span tags locally when exporting OTLP With builder-tag precedence, root spans read their trace-level tags through a shared parent. The OTLP span writer emits only a span's own tags, so root-only tags (process_id, runtime-id, language, profiling) dropped out of OTLP exports. Turn the read-through off when OTLP export is on, decided once at startup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Copy root-span tags into root spans again instead of reading them through With builder-tag precedence, root spans read their root-span tags through a shared frozen parent. A parent is always the lowest layer, which is the same as applying it first, but root tags used to be applied after the inbound request's tags: a request header mapped onto a root-tag name (process_id, runtime-id, language, ...) now overrode it. The OTLP span writer also emits only local tags, so it lost them. Copy root tags into root spans again, as on master. Only the merged tracer tags, which were already applied first, stay in the read-through parent. That also makes the OTLP-export exception unnecessary. Root spans keep about 5-7 more tags locally. RootSpanTagsReadThroughTest becomes RootSpanTagsTest, which checks root and child spans in both precedence modes and that root tags win over same-named inbound tags. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Merge remote-tracking branch 'origin/master' into dougqh/tagmap-split-known-custom Store setAllTags entries with the id already looked up setAllTags resolved each name to choose the interceptor, then stored the tag through unsafeSetTag, which resolved it again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Drop the name-only routeSet overloads Each hid a KnownTagCodec.keyOf call, which is how setAllTags came to look a name up twice. Callers now resolve the id themselves, so every lookup is visible where it happens; setMetric does it before taking the lock. The comment introducing the route methods moves to where they start. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Set the by-name map's db.pool.name by name again A rename turned DB_POOL_NAME_NAME into the id constant, so the test's by-name map set that tag by id, and still passed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Trim the knownTags Javadoc to what the field needs; use SPAN_KIND_NAME The Storage section repeated what customTags and tagView say, and the rest is now the lock's scope, why it is reentrant, and who skips it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Trim the tag storage comments; post-processors don't call span setters The knownTags Javadoc said post-processors call back into the span's setters while the lock is held. None does: they write through the view. If one did, a custom tag written through the view could miss the span, so tagView now states the rule, and the rest of the comments are trimmed or dropped where the code says it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Merge remote-tracking branch 'origin/master' into dougqh/tagmap-split-known-custom Resolves #12998's package move (datadog.contract.Restricted) and adapts master's #13452 and SpanKind changes to the split stores: the new DDSpanContext constructor drops the removed tagsSize parameter, and seedAbsentSpanKind checks and stores span.kind through knownTags. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: douglas.hawkins <douglas.hawkins@datadoghq.com>
#13061 named 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>
…- part 8) (#13004) Add the dense id store behind an experimental flag DenseIdStore keeps a span's known tags in two parallel arrays, each tag's 16-bit serial and its value, with no Entry per tag. It reads through to the frozen parent's store like HashIdStore. A lookup scans the serials and is skipped when the slot and level masks rule the tag out; the full id is rebuilt from the serial (KnownTagCodec.idOf, backed by the generated IDS_BY_SERIAL table) only where a reader asks for it. The masks live in DenseIdStore, which needs them to index its arrays. HashIdStore's buckets are the exact state, so it stays without them and dense-off spans keep their current size. IdStoreFactory picks the store once per JVM from trace.experimental.dense.tags.enabled (off by default), so only one IdStore subclass is loaded and calls on it stay devirtualized. TraceShape probe, 7-span trace: 8,040 B with the flag off (unchanged), 5,504 B with it on (-30% vs master). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Read dense-stored tags with Entry's type and coercion rules The dense reader classifies and coerces through TagValueConversions, which had drifted from Entry while nothing used it: it typed Short and Byte as INT, said every value is(OBJECT), and coerced an OBJECT through Number (BigDecimal("12") read as 12) or to false ("GET"). So the dense flag could change what a tag read returned. TagValueConversions now encodes Entry's rules for a boxed value: only Boolean, Integer, Long, Float and Double are typed; anything else is an OBJECT, which is true when present and 0 as a number. Its tests check every conversion against an Entry of the same value, and the shared IdStore contract test checks both stores' readers against Entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Use the bare KnownTags id names #13061 named 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> Stop the dense store keeping values a write replaced or removed DenseIdStore answered put, getAndPut and remove with one reused reader pointed at the prior value. A caller that discarded the result, as the span's removal paths do, left that value reachable from the store until a later write with a prior value replaced it: a removed error.stack could stay attached to a long-lived span. - remove and put now return nothing, as TagMap's naming suggests; callers that need the prior value use getAndRemove (new) and getAndPut. The span's removal and put paths build no reader at all. - getAndPut and getAndRemove return a fresh reader instead of the reused one. That costs one 32-byte reader when there is a prior value; TagMap, their only caller, turns it into an Entry anyway. IdStoreContractTest checks, for both stores, that a removed or replaced value is collectable once the caller drops it; it fails with a reused reader. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: douglas.hawkins <douglas.hawkins@datadoghq.com>
What Does This Do
Changes how the KnownTags generator names constants: an id is named after its tag with no suffix, and the other constants always carry their full suffix. A naming clash now fails generation with instructions instead of getting a silent
_2(APMLP-2123).Ids are bare. An id is what instrumentation sets, so
span.setTag(DB_POOL_NAME, …)reads like the string-keyed call it replaces. The per-direction aliases are bare too (Outbound.SERVER_ADDRESS).Other constants keep the full suffix, even when the name already ends with it:
long)String)http.methodHTTP_METHODHTTP_METHOD_NAMEdb.pool.nameDB_POOL_NAMEDB_POOL_NAME_NAMEmessaging.kafka.cluster.idMESSAGING_KAFKA_CLUSTER_IDMESSAGING_KAFKA_CLUSTER_ID_NAME_SERIAL_NUMand_OTEL_NAMEwork the same way.A clash fails generation and says how to fix it. It used to get a silent
_2, which depended on registration order. A clash is two names that sanitize alike, or a tagx.name(idX_NAME) next to a tagx(nameX_NAME). The error names both tags and the overlay entry that resolves it:java_namesintag-conventions-java.yaml. It maps a Datadog tag name, or an OpenTelemetry name for the per-direction aliases, to its own constant base.aws.serviceandaws_service.aws_servicegetsTOP_LEVEL_AWS_SERVICE, the nameInstrumentationTagsalready uses.Motivation
The old naming had three problems:
db.operation.name's name anddb.operation's name), and the reader can't tell an id from a name._2.Bare ids keep the call sites readable as instrumentation moves onto ids (APMLP-1570). Settling the names before that spreads keeps the renames cheap.
Additional Notes
_IDsuffix: 330 ids plus 34 per-direction aliases. On master, 554 references in 44 files are updated, mostly in core, internal-api and the decorators.RUNTIME_ID) is now the bare form.DB_POOL_NAME→DB_POOL_NAME_NAME) andaws_service's.X_IDno longer exists. A bareXthat used to be a name is now along, so it can't be passed silently where aStringis expected.Tags.X(string) andKnownTags.X(id) won't compile ("reference is ambiguous"), so one has to be qualified.TagStoreTestwas the only such file; it now names the stringTags.HTTP_ROUTE. The generator plugin test's fixture registeredfooandfoo.name, exactly that clash, so its second tag is nowfoo.bar.KnownTagsreference.🤖 Generated with Claude Code