Skip to content

Go SDK: OTLP logs signal (ADR-100)#72

Open
brentrager wants to merge 1 commit into
mainfrom
feat/go-otlp-logs-signal
Open

Go SDK: OTLP logs signal (ADR-100)#72
brentrager wants to merge 1 commit into
mainfrom
feat/go-otlp-logs-signal

Conversation

@brentrager

Copy link
Copy Markdown
Contributor

Problem

The Go observability SDK exported traces and metrics but no logs. ADR-100 adds a logs signal into the product /v1/logs OTLP endpoint, correlated to traces.

Solution

Adds the third OTLP pipeline, reusing the existing traces/metrics wiring verbatim:

  • go/logs.gobuildLoggerProvider (sdk/log LoggerProvider + BatchProcessor + otlploghttp exporter) and SlogHandler(name) (an otelslog bridge over the global LoggerProvider).
  • go/otel.goSetupOtelOptions.LogsEndpoint, OtelSDKHandle.LoggerProvider, logs block in SetupOtelSDK, global registration via log/global.SetLoggerProvider, and Flush/Shutdown coverage.
  • go/bootstrap.go — resolves /v1/logs off the same SMOOAI_OBSERVABILITY_ENDPOINT base and the OTEL_EXPORTER_OTLP_LOGS_ENDPOINT fallback.

Same endpoint base, same auth (static header or TokenProvider via buildHTTPClient), same resource, same enable/init gating. No new config keys. Graceful no-op when no logs endpoint is configured (nil provider; the SlogHandler drops 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.nameservice_name, attrs→parsed_fields.

Deps (pinned to otel core v1.44.0, no unrelated bumps)

otel/log + sdk/log + otlploghttp v0.20.0, contrib/bridges/otelslog v0.19.0.

Tests

go test ./...55 passed (3 new). Correlation verified by round-trip, not just compiled: TestSlogHandlerCorrelatesWithActiveSpan starts a real span, logs through SlogHandler, and asserts the exported sdklog.Record.TraceID()/SpanID() equal the span's ids. Plus no-span (zero ids) and no-endpoint no-op cases. go vet clean, gofmt clean.

🤖 Generated with Claude Code

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
@changeset-bot

changeset-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: c57d57b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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