Skip to content

fix: map Python CRITICAL log level to OTel FATAL severity text#5011

Open
Krishnachaitanyakc wants to merge 1 commit intoopen-telemetry:mainfrom
Krishnachaitanyakc:fix/map-critical-severity-text-to-fatal
Open

fix: map Python CRITICAL log level to OTel FATAL severity text#5011
Krishnachaitanyakc wants to merge 1 commit intoopen-telemetry:mainfrom
Krishnachaitanyakc:fix/map-critical-severity-text-to-fatal

Conversation

@Krishnachaitanyakc
Copy link

Description

Fixes #4984

The OTel specification defines the severity text for the highest severity range (SeverityNumber 21-24) as FATAL. However, the Python SDK's LoggingHandler._translate method was passing through Python's native CRITICAL level name unchanged as the severity_text.

This is the same class of bug that was previously fixed for WARNING -> WARN in #3566 (which addressed #3548). The fix extends the existing severity text mapping to also cover CRITICAL -> FATAL.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Changes

  • Extended the severity text mapping in LoggingHandler._translate() to map Python's CRITICAL level name to OTel's FATAL severity text, using a dictionary lookup instead of a single conditional
  • Updated all related test assertions in test_export.py, test_handler.py, and test_multi_log_processor.py to expect "FATAL" instead of "CRITICAL"
  • Added CHANGELOG entry

Does This PR Require a Contrib Repo Change?

  • No.

Test plan

  • All 78 existing log tests pass (opentelemetry-sdk/tests/logs/)
  • Tests that previously asserted severity_text == "CRITICAL" now correctly assert severity_text == "FATAL"

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Mar 25, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: Krishnachaitanyakc / name: Krishna Chaitanya (097898f)

@Krishnachaitanyakc Krishnachaitanyakc marked this pull request as ready for review March 25, 2026 02:12
@Krishnachaitanyakc Krishnachaitanyakc requested a review from a team as a code owner March 25, 2026 02:12
The OTel specification defines the severity text for the highest severity
range as "FATAL", but the Python SDK was passing through Python's native
"CRITICAL" level name unchanged. This is the same class of bug that was
previously fixed for WARNING -> WARN in open-telemetry#3566.

Fixes open-telemetry#4984
@Krishnachaitanyakc Krishnachaitanyakc force-pushed the fix/map-critical-severity-text-to-fatal branch from de0932f to 097898f Compare March 25, 2026 15:53
@tammy-baylis-swi
Copy link
Contributor

Thank you for this @Krishnachaitanyakc

Would you be interested in making a similar change in the other repo?: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/822cd77b25444f874a1eb289529d0234fe794034/instrumentation/opentelemetry-instrumentation-logging/src/opentelemetry/instrumentation/logging/handler.py#L191-L195 As part of stabilizing the Logging SDK, the handler will eventually be housed in contrib (#4330).

For this PR, please could you do tox -e lint-opentelemetry-sdk and commit the fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Reviewed PRs that need fixes

Development

Successfully merging this pull request may close these issues.

Logs: Severity Text string does not match the spec

2 participants