[Feature]: OTel plugin: emit severityText and severityNumber on enriched logs

Aperta
#938 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
67/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
observability

Direzione di ricerca

Start with packages/aws-durable-execution-sdk-python-otel/src/aws_durable_execution_sdk_python_otel/log_filter.py, especially OtelContextLogFilter.filter(), and trace how enriched records from the Invocation and Execution plugins reach serialized structured logs. Check existing tests for durable context logs, stdlib logs, and replay behavior. Add coverage for the specified severity mappings and field types across initial and resumed invocations; done means both views emit top-level severity fields while disabled enrichment and default logging remain unchanged.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement needs-triage pkg:otel
What would you like?

When aws-durable-execution-sdk-python-otel log enrichment is enabled, include OpenTelemetry severityText and severityNumber on the emitted structured application logs, alongside the existing native log level and trace correlation fields.

This is the Python counterpart of https://github.com/aws/aws-durable-execution-sdk-js/issues/1228.

The current OtelContextLogFilter.filter() adds traceId, spanId, and otelTraceSampled, but does not add either severity field. Both Invocation and Execution OTel plugins use this filter when enrich_logger=True. This finding is based on source inspection of main at 54883810bc417c59017540bae31e35fa9b35bd8c.

OTel-aware consumers, including CloudWatch Logs Analyze logs as described in the JS issue, need the standard severity fields to recognize, filter, and group log severity.

Possible Implementation

Extend the OTel logging enrichment path to set severityText from the source log level and map Python log levels to OpenTelemetry severity numbers:

Python level severityText severityNumber
DEBUG DEBUG 5
INFO INFO 9
WARNING WARNING 13
ERROR ERROR 17
CRITICAL, when logged through stdlib logging CRITICAL 21

WARNING is Python's spelling of the WARN severity range. logger.exception() should receive ERROR severity, like logger.error().

Follow the OTel log data model. The telemetry exporter's existing severity mapping is based on execution status and cannot be reused directly as an application log-level mapping.

Keep this additive and scoped to active OTel log enrichment. Preserve the existing native level, trace correlation, durable metadata, and replay suppression. Ensure the fields reach the serialized structured log output as top-level fields, with numeric severityNumber, rather than existing only as internal LogRecord attributes.

Acceptance criteria:

  • Both Invocation and Execution views emit the fields with the correct types and mappings.
  • Cover the durable context logger and stdlib logs that already flow through the enrichment filter.
  • Cover an initial invocation and a resumed invocation, preserving suppression of completed durable logs during replay.
  • Without the plugin, or with log enrichment disabled, the default logging behavior remains unchanged.
Is this a breaking change?

No.

Does this require an RFC?

No.

Additional Context
Lingua principale
Python
Stelle
59
Fork
32
Merge medio
1g 5h
PR unite (30g)
76

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di aws/aws-durable-execution-sdk-python

Tutte le issue di aws/aws-durable-execution-sdk-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.