feat: add execution context attributes to telemetry spans#288
Draft
feat: add execution context attributes to telemetry spans#288
Conversation
Add `execution.context` and `caller.id` span attributes to the telemetry interceptor, allowing traces to distinguish OBO (user) from service principal code paths. Signed-off-by: Pawel Kosiec <pawel.kosiec@databricks.com>
…Stream The TelemetryInterceptor spans were orphaned because OTel lost the parent HTTP span context when crossing into the async generator. Capture context.active() before the generator and restore it with context.with() inside, so plugin.execute spans appear as children of the HTTP request trace. Signed-off-by: Pawel Kosiec <pawel.kosiec@databricks.com>
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.
Summary
plugin.executetelemetry spans by preserving OTel context across the async generator boundary inexecuteStream()execution.context("user"or"service") andcaller.idspan attributes to the telemetry interceptor, allowing traces to distinguish OBO from service principal code pathsProblem
The
TelemetryInterceptorcreates spans viastartActiveSpan, butexecuteStream()runs the interceptor chain inside an async generator — OTel loses the parent HTTP span context at this boundary. The spans were created but orphaned in separate traces, making them invisible.Fix
Capture
otelContext.active()before the generator, restore it withotelContext.with()inside. This is the standard OTel JS pattern for async boundary context propagation.Test plan
plugin.executespan appears as child of HTTP request span in Jaeger/Grafana withexecution.contextandcaller.idattributes