Go SDK: OTLP logs signal (ADR-100)#72
Open
brentrager wants to merge 1 commit into
Open
Conversation
Adds the third OTLP pipeline alongside traces and metrics: an sdk/log LoggerProvider with a batch processor exporting to the product /v1/logs endpoint, plus an otelslog-backed slog.Handler (SlogHandler) so app logs become OTel log records correlated to the active span. Reuses the existing traces/metrics wiring verbatim — same SMOOAI_OBSERVABILITY_ENDPOINT base (logs → /v1/logs), same auth (static header or TokenProvider via buildHTTPClient), same resource, same enable/init gating. Graceful no-op when no logs endpoint is configured. Deps pinned to otel core v1.44.0: otel/log + sdk/log + otlploghttp v0.20.0, otelslog v0.19.0. No unrelated bumps. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S2bM94GAnVjYSSv1x7HKRB
|
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 Go observability SDK exported traces and metrics but no logs. ADR-100 adds a logs signal into the product
/v1/logsOTLP endpoint, correlated to traces.Solution
Adds the third OTLP pipeline, reusing the existing traces/metrics wiring verbatim:
go/logs.go—buildLoggerProvider(sdk/logLoggerProvider+BatchProcessor+otlploghttpexporter) andSlogHandler(name)(anotelslogbridge over the globalLoggerProvider).go/otel.go—SetupOtelOptions.LogsEndpoint,OtelSDKHandle.LoggerProvider, logs block inSetupOtelSDK, global registration vialog/global.SetLoggerProvider, and Flush/Shutdown coverage.go/bootstrap.go— resolves/v1/logsoff the sameSMOOAI_OBSERVABILITY_ENDPOINTbase and theOTEL_EXPORTER_OTLP_LOGS_ENDPOINTfallback.Same endpoint base, same auth (static header or
TokenProviderviabuildHTTPClient), same resource, same enable/init gating. No new config keys. Graceful no-op when no logs endpoint is configured (nil provider; theSlogHandlerdrops records against the no-op global provider).Column mapping
severity←level, body←message, trace_id/span_id←active span context (the otelslog bridge reads it from ctx), resource
service.name→service_name, attrs→parsed_fields.Deps (pinned to otel core v1.44.0, no unrelated bumps)
otel/log+sdk/log+otlploghttpv0.20.0,contrib/bridges/otelslogv0.19.0.Tests
go test ./...→ 55 passed (3 new). Correlation verified by round-trip, not just compiled:TestSlogHandlerCorrelatesWithActiveSpanstarts a real span, logs throughSlogHandler, and asserts the exportedsdklog.Record.TraceID()/SpanID()equal the span's ids. Plus no-span (zero ids) and no-endpoint no-op cases.go vetclean,gofmtclean.🤖 Generated with Claude Code