feat(otel): add OTLP logs signal correlated to traces#73
Open
brentrager wants to merge 1 commit into
Open
Conversation
Wire a LoggerProvider + BatchLogRecordProcessor + OTLP log exporter into setupOtelSdk, reusing the traces/metrics endpoint, auth, and enable path. App logs emitted through the standard @opentelemetry/api-logs facade become OTLP log records stamped with the active span's W3C trace_id/span_id; when no logs endpoint resolves the global LoggerProvider stays the api-logs no-op and stdout output is unchanged. - AuthInjectingLogExporter reuses the per-request Bearer/401-retry base - bootstrap derives /v1/logs from SMOOAI_OBSERVABILITY_ENDPOINT - flush/shutdown drain the log processor too - tests: exporter auth+retry, signal wiring, and a real-SDK correlation proof Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S2bM94GAnVjYSSv1x7HKRB
🦋 Changeset detectedLatest commit: 4c0af40 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Problem
The observability SDK exports traces and metrics but not logs. App log lines never reach the product's
/v1/logsOTLP endpoint, so they can't be viewed alongside — or correlated with — traces.Solution
Wire the OTel logs signal into
setupOtelSdk, reusing the exact traces/metrics plumbing (ADR-100):SMOOAI_OBSERVABILITY_ENDPOINT→/v1/logs(bootstrap derives it; per-signalOTEL_EXPORTER_OTLP_LOGS_ENDPOINToverride honored)._TOKENor M2M_AUTH_URL/_CLIENT_ID/_CLIENT_SECRETvia a newAuthInjectingLogExporterthat reuses the per-request Bearer + 401-retry base class (no header snapshot).LoggerProviderstays the@opentelemetry/api-logsno-op and stdout is unchanged.LoggerProvider+BatchLogRecordProcessor+OTLPLogExporter(http/json, matching the traces exporter protocol). Versions pinned to the existing0.55.xline — no bumps.@opentelemetry/api-logsfacade become OTLP log records; the logs SDK stamps the active span'strace_id/span_idfrom context, giving trace↔log correlation for free.flush/shutdowndrain the log processor too.Verification
pnpm typecheckclean,pnpm buildclean, 66/66 tests pass.AuthInjectingLogExporterauth + 401-retry + failure paths; logs-signal wiring toggles on the endpoint; and a real-SDK correlation proof (logs-correlation.test.ts) — a log emitted through the api-logs facade inside a real active span carries that span's real 32/16-hex W3C ids via a realLoggerProvider+ async-hooks context manager (not stubbed).🤖 Generated with Claude Code