Repository navigation
Have the span own its tag stores directly (dense store - part 7) - #13003
gh-worker-dd-mergequeue-cf854d[bot] merged 12 commits into
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. |
c6d9c8c to
074d3db
Compare
074d3db to
0696fab
Compare
0696fab to
0d8077c
Compare
5920fe6 to
b2616d7
Compare
b2616d7 to
bb4ef29
Compare
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>
#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>
ebb2581 to
96d6797
Compare
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>
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>
…ough 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>
There was a problem hiding this comment.
More details
Static inspection identified no concrete regression in tag routing, inherited-store handling, or serialization. Runtime behavior remains unverified.
🤖 Bits Code Review · Commit 00a78fe
PerfectSlayer
left a comment
There was a problem hiding this comment.
I have one question about the overall design: was there a cost of having an intermediate object like TagMap?
It was nice because it holds all the logic related to tags into a dedicated class, instead of mixing it into the span context concern, which still need to be cleaned of anything other than IDs and few propagation info, so the tags should end up in DDSpan at some point.
Otherwise, the changes are quite verbose about tag. I would try to trim it down. Maybe @bric3 skill would be useful for this purpose?
Otherwise, I got this report from my tooling:
🤖 A tag can be lost between the cached view and the span (latent):
- When it happens: during processTagsAndBaggage, the view creates its own custom store and something then calls a span setter for a custom tag.
- What goes wrong: the span's setter drops the view, so adoptViewStores skips adopting it. The span and Metadata then end up with different custom tags.
- Why it's latent: no post-processor calls back into span setters today, but the field Javadoc says they do. Either fix the Javadoc or make such callbacks unsupported.
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>
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>
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>
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>
There was a problem hiding this comment.
Please try again by commenting @datadog review.
|
I received another request for review but I could not find the answer to this question nor feedback about loosing the tag. Did I miss it? |
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>
|
@PerfectSlayer Yes, there were a few costs to TagMap. The first one being allocation (24B) which does add up. I did another simplification pass on the Javadoc & comments. I tend to err on the side of wanting more Javadoc than we'd historically had, but I can trim it if that's what others prefer. |
|
On the lost tag your tooling reported: good catch, and you're right that it's latent. No post-processor calls a span setter today (they all write through the view), but the Javadoc said they did, which invited exactly the path where a custom tag written through the view misses the span. Fixed in 78d5fd5: the claim is gone from the lock's Javadoc, and Reply written by Claude (Claude Code) on behalf of dougqh. |
…-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>
PerfectSlayer
left a comment
There was a problem hiding this comment.
I tend to err on the side of wanting more Javadoc than we'd historically had, but I can trim it if that's what others prefer.
It’s nice to have some. Not sure of what we can call too few or too much, for both humans and agents. They found most of it should be dropped as it tends to stale and mislead them. Anyway, having implementation details, thread & null safety, etc are still useful for the readers!
|
/merge |
|
View all feedbacks in Devflow UI.
It will be processed automatically as soon as GitHub reports it as mergeable. View in MergeQueue UI.
The expected merge time in
Build pipeline has failing jobs for 0c9faa9: What to do next?
|
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
Add OTel SDK span lifecycle self-monitoring metrics When trace.otel.sdk.self.monitoring.metrics.enabled is on (with OTel metrics, the OTLP exporter and experimental metrics), CoreTracer builds an OTel span lifecycle recorder that reports otel.sdk.span.started, split by otel.span.parent.origin, and otel.sdk.span.live on the bootstrap metric registry. Otherwise it keeps a no-op. The span call sites are wired in a follow-up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Reuse HealthMetrics hooks for OTel span lifecycle metrics Replace the separate SpanLifecycleMetrics recorder with an OTel implementation of HealthMetrics, so span creation and completion keep a single hook each, as suggested in review. - HealthMetrics.onCreateSpan now takes the span, so the OTel sink can read its parent origin; TracerHealthMetrics ignores it. - OtelSpanLifecycleMetrics becomes OtelHealthMetrics, which extends HealthMetrics and overrides only onCreateSpan and onFinishSpan. - Add CompositeHealthMetrics to fan every callback out to several sinks. start() and close() reach every delegate, then rethrow the first failure with later ones suppressed. - OtelSdkSelfMonitoring.healthMetrics(config) returns the OTel sink when the gate is on, otherwise null. CoreTracer is not wired here; the follow-up selects the sinks. - Test that every DDSpanContext parent origin maps to a distinct adder, that the composite forwards every callback, and that both collectors pass the span to onCreateSpan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Test parent origin sync and health metrics forwarding - Move the parent origin sync check into its own test, which also fails when a PARENT_ORIGIN_* constant is added without growing the OtelHealthMetrics arrays. - Call every CompositeHealthMetrics method through a two-delegate composite and verify both delegates receive the same call. - Cover OtelSdkSelfMonitoring.healthMetrics with the gate off and on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Trim CompositeHealthMetrics tests and rename OtelHealthMetricsTest - Drop the composite tests that the every-method forwarding test already covers (declared overrides, delegate order) and the zero-delegate case, which CoreTracer never builds. - Rename OtelHealthMetricsParentOriginTest to OtelHealthMetricsTest, the plain unit test for OtelHealthMetrics. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Use static imports in OTel health metrics tests Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Drop tagsSize argument removed from DDSpanContext Master removed the int tagsSize parameter from the DDSpanContext constructors (#13003), so StreamingTraceCollectorTest no longer compiled after rebasing onto it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Pass a stub span to onCreateSpan in HealthMetricsTest OtelHealthMetrics dereferences the span it is given, so tests should honour the non-null contract even though TracerHealthMetrics ignores the argument. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: devflow.devflow-routing-intake <devflow.devflow-routing-intake@kubernetes.us1.ddbuild.io>
What Does This Do
DDSpanContextowns its tag stores directly, instead of oneTagMap:IdStore, which is also the span's tag lock.HashStore, borrowed read-only from the read-through parent until the span's first custom write.Each write is routed 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.
TagStore(Introduce TagStore for eager tag post-processors (dense store - part 3) #13001), so they need noTagMap.TagMap. The span builds a view over its stores once, at serialization, and caches it. That costs about 32 B per span until they move toTagStore.TagMap.Internalsis gone, since the stores are now the direct path. The forbidden-API entry for it goes too.tagsSizeparameter, which is why many tests change by one line.Motivation
This is the last of three PRs that replace the span's single
TagMapwith two stores split by tag kind. The stores and theTagMapfacade are in the two PRs below this one. Here, the span stops going throughTagMapfor its own reads and writes. That gives the dense store (#13004) a place as the known-tag half.Additional Notes
Allocation, 7-span web-request trace, application thread only (JDK 25, per-thread allocated bytes,
TraceShapeBenchmark's shapes):legacy: every tag by namenormal: the calls today's decorators makenewApi: prototype at construction, tags by idTagMapobject of its own (about 24 B) while gaining three fields inDDSpanContext(about 8 B).HashStoreadds nothing over the old path.Tests: internal-api and dd-trace-core pass. The only failures are the two
TracerConnectionReliabilityTestcases, which need Docker.Where this is going
This PR is one step in replacing the span's single
TagMapwith storage that knows each tag's kind. The goal is to cut what every span allocates on the application thread, without changing behavior.The end state
TagMapbecomes a thin view for code outside the span.Entryobject per tag, and each span's store is presized from a per-operation hint. With the flag on, a web-request-shaped trace allocates about 30% less on the application thread than on master.TagStore, not aTagMap. That covers post-processors now and serializers later, so noTagMapview gets built for them.TagStorehas its own verbs,loadandstore, apart fromTagMap'sget/setand the span's interceptedgetTag/setTag, soDDSpanContextcan offer both. The tag stores themselves use the same verbs (Add id and name tag stores, not yet used (dense store - part 5) #13006). It starts with what the eager processors use, by name and by id, and grows typed-load and primitive-store variants. Its intercepted counterpart,SpanData(Take the span's tag lock once in setTagsFrom (tag api - part 1) #13030), is whatsetTagsFrom,TagContributorandTagExtractortake, with one lock per batch.Later, not in this stack: cheaper read-through to parent spans, trace-level tags in a per-trace holder (
TraceSegment), and primitive tag values without boxing.The stack. This replaces #12918, split into pieces that can each be reviewed, and measured, on their own.
TagMap. This is the stack's only behavior change, kept separate on purpose.TagMap, and addTraceShapeBenchmarkTagStorefor the eager post-processorsTagMap's bucket mechanics intoHashSupport(a pure move)TagMapa facade over the two storestrace.experimental.dense.tags.enabled(off by default)Every PR after #12999 is behavior-preserving.
The #13003, #13004 and #12926 figures were re-measured on 2026-11-03, after #13006 and #13007 merged, with a deterministic per-thread probe (
ThreadMXBeanallocated bytes, JDK 25) that buildsTraceShapeBenchmark's 7-span trace and, like serialization, feeds each span's size back into the sizing hints. The #12992 figure comes fromTraceShapeBenchmarkitself.🤖 Generated with Claude Code