feat(enrichers): add OTel auto-instrumentation bridge via createOtelSpanEnricher#388
feat(enrichers): add OTel auto-instrumentation bridge via createOtelSpanEnricher#388HugoRCD wants to merge 2 commits into
Conversation
…tion bridge
Adds a zero-dependency enricher that reads the active OpenTelemetry span
from @opentelemetry/api's global singleton (Symbol.for('opentelemetry.js.api.1'))
and attaches traceId/spanId to evlog events automatically.
This bridges evlog with OTel auto-instrumentation: when the OTel SDK is running,
log events are correlated with active traces without any HTTP header parsing.
Works for background jobs and internal spans, not just HTTP-layer requests.
The enricher is a no-op when OTel is not present.
Generated with [Linear](https://linear.app/hrcd/issue/EVL-182/explore-otel-auto-instrumentation-for-evlog#agent-session-e90a8d6d)
Co-authored-by: linear-code[bot] <222613912+linear-code[bot]@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hey there and thank you for opening this pull request! 👋🏼 We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted. Details: |
Adds
createOtelSpanEnrichertoevlog/enrichers— a zero-dependency enricher that bridges evlog with the OpenTelemetry SDK when it's running.How it works: The OTel API registers itself on
globalThis[Symbol.for('opentelemetry.js.api.1')]. This enricher reads the active span from that global on first use (per enricher instance) and attachestraceId/spanIdto evlog events.Why this matters over the existing
createTraceContextEnricher:createTraceContextEnricherparses W3Ctraceparentheaders — only works on the HTTP layercreateOtelSpanEnricherreads from OTel's async context manager — works for background jobs, queue consumers, internal spans, or any async context where OTel has propagated a spanTradeoffs / constraints:
createOtelSpanEnricher()call, on first event. If OTel registers after the enricher first fires, it won't be picked up (uncommon in practice)Symbol.for('opentelemetry.js.api.1')which is OTel API's documented global key (stable across 1.x)Usage: