Context API `beforeFinish` Migration by zarirhamza · Pull Request #9422 · DataDog/dd-trace-java

and others added 3 commits

August 21, 2025 09:43
* Creates inferred proxy spans for API Gateway calls via presence of http headers

---------

Co-authored-by: Zarir Hamza <zarir.hamza@datadoghq.com>
Avoid duplicate expensive context extraction
Avoid subclassing tracing span for serverless but used serverless context element instead to store / track inferred span while keep tracing feature untouched
Improved propagator to not create / capture inferred span context element on invalid data
Rework context element to hold the inferred spans and its captured data
Release captured data as soon as they span start (never read after this point so reclaiming memory)
Refactor context element and propagator into the right package, not context component (product / feature agnostic)
Refactor unit tests

@zarirhamza

ygree

ygree

mhlidd

@zarirhamza

mhlidd

@zarirhamza

@zarirhamza

ygree

ygree

ygree

ygree

ygree

ygree

ygree

@zarirhamza

@zarirhamza

This was referenced

Nov 13, 2025

bm1549 added a commit that referenced this pull request

Mar 18, 2026
Three deterministic bugs fixed:

1. Key mismatch in PassthruInstrumentation: PR #9422 renamed the context
   key constant but forgot to update the hardcoded string literal in
   SynapsePassthruInstrumentation, breaking parent span propagation
   across the passthru mechanism.

2. http.url test assertion: QueryObfuscator recombines http.url with the
   query string after obfuscation. The test expected path-only but the
   actual value correctly includes the query string.

3. Missing peer.service in V1 client spans: SynapseClientDecorator
   returns relative URIs (no host), so peer.hostname was never set.
   Added peer hostname/IP/port extraction from NHttpClientConnection.

Additionally, hardened the passthru span propagation to read the server
span directly from the source connection context rather than relying
solely on activeSpan(). SourceHandler.requestReceived() dispatches to a
worker thread pool, and while java-concurrent instrumentation normally
handles context propagation across ThreadPoolExecutor, the connection-
based lookup is more robust.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>