Add OTLP logs signal (Python) correlated to traces#69
Open
brentrager wants to merge 1 commit into
Open
Conversation
Adds the logs signal alongside the existing traces + metrics OTLP setup in setup_otel_sdk: a LoggerProvider + BatchLogRecordProcessor + OTLPLogExporter (HTTP, matching the traces/metrics exporter protocol) plus a stdlib LoggingHandler attached to the root logger so ordinary `logging` calls become OTel log records. Reuses the SAME endpoint (/v1/logs), auth (static token or M2M AuthInjectingLogExporter), and enable/skip_start path as traces — no new config keys and no new dependencies (the log exporter ships in the existing otlp extra, the logs SDK in opentelemetry-sdk). The LoggingHandler reads the ACTIVE span context per record, so logs emitted inside a span carry the real W3C trace_id/span_id — verified with an in-memory exporter against the exact handler class the setup attaches. Disabled/skip_start is a graceful no-op that leaves the root logger untouched. bootstrap derives the /v1/logs endpoint from SMOOAI_OBSERVABILITY_ENDPOINT. 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 Python observability SDK exported traces + metrics over OTLP but not logs, so nothing lands in the product
/v1/logsendpoint and logs can't be correlated to traces. (Pearl th-5dca7d; matches ADR-100.)Solution
Adds the logs signal to
setup_otel_sdk, reusing the exact traces/metrics setup as the template:LoggerProvider+BatchLogRecordProcessor+OTLPLogExporter(HTTP — matches the traces/metrics exporter protocol), plus a stdlibLoggingHandlerattached to the root logger so ordinaryloggingcalls become OTel log records./v1/logs), auth (static token or M2M via newAuthInjectingLogExporter), and enable/skip_startpath as traces. No new config keys, no new dependencies — the log exporter ships in the existingotlpextra and the logs SDK inopentelemetry-sdk.bootstrapderives/v1/logsfromSMOOAI_OBSERVABILITY_ENDPOINT.Correlation (verified)
The
LoggingHandlerreads the active span context per record, so logs emitted inside a span carry the real W3Ctrace_id/span_id. Verified with an in-memory log exporter against the exact handler class the setup attaches (tests/test_otel_logs.py) — not just a compile. Disabled/skip_startis a graceful no-op that leaves the root logger untouched.Tests
python/tests/test_otel_logs.py— wiring, root-logger-untouched-when-skipped, log-in-span carries real ids, log-outside-span has no trace context. Full Python suite: 70 passed, ruff lint + format clean.🤖 Generated with Claude Code