Repository navigation
fix: align exported OTel span IDs with propagated run contexts - #113
Open
pear1-pea (pear1-pea) wants to merge 1 commit into
Open
pear1-pea (pear1-pea) wants to merge 1 commit into
pear1-pea (pear1-pea) wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Native OpenTelemetry spans created inside
@traceablecalls use a deterministic run span ID as their parent, while the exporter currently creates the LangSmith span with a new random ID. This leaves the native spans pointing at a parent that was never exported (fixes #58). Root spans can also inherit an artificial parent, and an external OTel parent can lead to different trace IDs during execution and export.This change gives each exported run a private copy of the standard SDK tracer with a run-specific ID generator. The copy retains the provider's sampler, processors, resource, scope, and limits without changing the shared provider or cached tracer. Execution contexts preserve an existing parent's trace ID, flags, and tracestate. Root runs use an empty parent context, and nested runs can recover their deterministic parent ID even if the parent's batch has not arrived.
Regression tests cover sync/async
@traceablecalls, external parent contexts, sampling inherited from a remote parent, nested and out-of-order batches, updates, concurrent exports, processor start/end identity, and late global provider initialization.The ID override applies to standard
opentelemetry-sdktracers, including normal subclasses. Other API tracer implementations keep their own span-creation behavior. This does not change the existing synthetic-context sampling lifecycle: with no external parent andParentBased(ALWAYS_OFF), native children can already be sampled while the run is dropped.Validation (Python 3.12.16):
The full all-extras test/typecheck suite and live-service integration suites were not run.