Skip to content

feat(telemetry): add OTel standard logs as third signal#239

Draft
jeanscherf wants to merge 2 commits into
mainfrom
feat/otel-standard-logs
Draft

feat(telemetry): add OTel standard logs as third signal#239
jeanscherf wants to merge 2 commits into
mainfrom
feat/otel-standard-logs

Conversation

@jeanscherf

Copy link
Copy Markdown
Member

Summary

  • Wires up a LoggerProvider alongside existing metrics and traces using the shared resource attributes (service.name, region, subaccount, etc.)
  • auto_instrument() now sets up all three OTel signals — no app boilerplate changes needed
  • Uses LoggingHandler from opentelemetry-instrumentation-logging (not the deprecated SDK one) installed on the root stdlib logger

Changes

  • _provider.py: setup_log_provider() + _create_log_exporter() — mirrors _setup_meter_provider() pattern, same grpc/http protocol switch
  • auto_instrument.py: one setup_log_provider() call wired in after trace setup
  • user-guide.md: new Logging section covering usage, extra={} structured fields, level filtering, trace correlation

Tests

  • Mock unit tests for _create_log_exporter, setup_log_provider, and auto_instrument wiring
  • End-to-end tests with a real in-memory exporter verifying body, severity, resource attributes, extra={} fields, and trace/span correlation — all run in CI without any external dependencies

App usage

No changes needed. After auto_instrument(), all existing logging.getLogger(...) calls ship logs to the OTel backend automatically:

auto_instrument()  # sets up traces, metrics, and logs

logger = logging.getLogger(__name__)
logger.info("Request handled", extra={"tenant_id": tid})

Wire up a LoggerProvider alongside the existing metrics and traces so
stdlib logging calls automatically flow through OTel with the shared
resource attributes (service.name, region, subaccount, etc.).

- setup_log_provider() in _provider.py mirrors _setup_meter_provider():
  LoggerProvider + BatchLogRecordProcessor + OTLP exporter (grpc/http)
- LoggingHandler from opentelemetry-instrumentation-logging installed on
  root logger so all existing logging.getLogger() calls are captured
- auto_instrument() calls setup_log_provider() alongside trace setup,
  keeping the one-call contract for apps
- user-guide.md: new Logging section with usage examples, structured
  fields, level filtering, and trace correlation notes
- unit tests: mock-level coverage for exporter protocol, provider setup,
  handler installation, and auto_instrument wiring
- e2e tests: real in-memory pipeline verifying body, severity, resource
  attributes, extra={} fields, and trace/span correlation
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