Skip to content

feat: add execution context attributes to telemetry spans#288

Draft
pkosiec wants to merge 2 commits intomainfrom
pkosiec/obo-trace
Draft

feat: add execution context attributes to telemetry spans#288
pkosiec wants to merge 2 commits intomainfrom
pkosiec/obo-trace

Conversation

@pkosiec
Copy link
Copy Markdown
Member

@pkosiec pkosiec commented Apr 20, 2026

Summary

  • Fixes orphaned plugin.execute telemetry spans by preserving OTel context across the async generator boundary in executeStream()
  • Adds execution.context ("user" or "service") and caller.id span attributes to the telemetry interceptor, allowing traces to distinguish OBO from service principal code paths

Problem

The TelemetryInterceptor creates spans via startActiveSpan, but executeStream() 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 with otelContext.with() inside. This is the standard OTel JS pattern for async boundary context propagation.

Test plan

  • Unit tests for execution context attributes (user + service paths)
  • All 1566 existing tests pass
  • Full build pipeline passes
  • Manual: verify plugin.execute span appears as child of HTTP request span in Jaeger/Grafana with execution.context and caller.id attributes

pkosiec added 2 commits April 20, 2026 14:14
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant