SMOODEV-1067c: @smooai/observability-otel — OpenTelemetry foundation (Phase 1) - #4
Merged
Merged
Conversation
…(Phase 1)
First step of the OTel migration. New package wraps the OTel NodeSDK +
auto-instrumentations + OTLP/HTTP trace exporter, and bridges the core
Client so captureException also records on the active OTel span.
Why this matters for non-@smooai/logger users:
The bridge depends on @opentelemetry/api, not on the Smoo logger. Any
consumer with their own logger (winston, pino, bunyan, console) can pipe
readOtelCorrelation() into their format and get the same trace-id on
logs, traces, and Smoo error groups. OTel is the universal interop —
this package speaks it natively.
Public surface:
- setupOtelSdk(options) — idempotent Lambda / Node bootstrap. Returns
{ sdk, flush, shutdown } so the host can wire flush into SIGTERM /
beforeExit.
- bridgeClientToOtel() — wraps Client.captureException / setUser /
setTag to also update OTel span attributes + status. Idempotent.
- readOtelCorrelation() — read the active span's traceId / spanId /
sampled flag.
Bridge behavior: every captureException becomes a recorded exception
on the active span with SpanStatusCode.ERROR. If no span is active at
capture time (background job, raw process listener), a synthetic span
"observability.captureException" is minted so the error still surfaces
in the trace.
Tests: 12 green (7 bridge + 5 setup). Typecheck + build clean.
This is Phase 1 of the migration tracked under SMOODEV-1067c. Phase 2
swaps the ingest backend to accept OTLP/HTTP alongside the existing
Smoo-native wire format. Phase 3 rebuilds the metrics SDK on OTel
meters. Phase 4 turns @smooai/logger's context into OTel baggage.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
6 tasks
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
First step of the full OTel migration. New package
@smooai/observability-otelwraps the OTel NodeSDK + auto-instrumentations + OTLP/HTTP trace exporter, and bridges the core Client so everycaptureExceptionrecords on the active OTel span.Why this matters for users who don't have
@smooai/loggerThe bridge depends on
@opentelemetry/api, not the Smoo logger. Any consumer using winston / pino / bunyan / console can pipereadOtelCorrelation()into their format and get the same trace-id flowing through logs, traces, and Smoo error groups. OTel is the universal interop — this package speaks it natively.Public surface
setupOtelSdk({ serviceName, otlpEndpoint, environment, release, ... })— idempotent Lambda / Node bootstrap. Returns{ sdk, flush, shutdown }.bridgeClientToOtel()— wrapsClient.captureException/setUser/setTagto update OTel span attributes + status. Idempotent.readOtelCorrelation()— read the active span's traceId / spanId / sampled flag.Bridge behavior
Every
captureExceptionbecomes a recorded exception on the active span withSpanStatusCode.ERROR. If no span is active at capture time (background job, raw process listener), a synthetic spanobservability.captureExceptionis minted so the error still surfaces in the trace.Where this sits in the larger migration
@smooai/observabilitymetrics SDK on OTel meters@smooai/loggerwrites CONTEXT into OTel baggageUntil Phase 2 lands,
bridgeClientToOtel()is additive — Smoo's existing transport still ships events to the backend; OTel becomes a parallel output.Test plan
pnpm --filter @smooai/observability-otel exec vitest run— 12/12 green (7 bridge + 5 setup).pnpm --filter @smooai/observability-otel typecheckclean.pnpm --filter @smooai/observability-otel buildclean.🤖 Generated with Claude Code