Repository navigation
Conversation
Pull request dashboard statusWaiting on the author · refreshed 2026-11-15 07:18 UTC Respond to 1 review item (e.g. link a commit, explain why not, ask a follow-up):
Status above doesn't look right?
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the change enabling direct numeric comparisons of severity values.
No open issues 🎉
What changed in this PR
Changes SeverityNumber to IntEnum before the logs API is stabilized, enabling direct numeric comparisons and addressing #5785.
Changes:
- Switches
SeverityNumberfromenum.Enumtoenum.IntEnum. - Adds tests for integer compatibility, severity ordering, and enum construction.
- Documents the breaking change in the changelog.
| File | Description |
|---|---|
opentelemetry-api/tests/logs/test_severity.py |
Tests integer equality, ordering, and enum identity. |
opentelemetry-api/src/opentelemetry/_logs/severity/__init__.py |
Makes SeverityNumber inherit from IntEnum. |
.changelog/5930.changed |
Announces the breaking change and direct comparison support. |
Review effort: Balanced
|
|
||
|
|
||
| class SeverityNumber(enum.Enum): | ||
| class SeverityNumber(enum.IntEnum): |
There was a problem hiding this comment.
Could we also update test_benchmark_logs_enabled.py:39 and the OTLP encoders to compare directly without .value and getattr (and ensure #5724 uses direct comparison in Logger.enabled())? It would be great to run test_benchmark_logs_enabled before and after to verify the speedup.
|
Per Claude: Benchmark:
|
| Test | Median before (µs) | Median after (µs) | Δ |
|---|---|---|---|
test_disabled_emit[processor_filter-kwargs-guarded] |
0.225 | 0.135 | -40.1% |
test_disabled_emit[processor_filter-log_record-guarded] |
0.225 | 0.135 | -40.1% |
test_disabled_emit[processor_filter-kwargs-unguarded] |
0.392 | 0.301 | -23.2% |
test_disabled_emit[processor_filter-log_record-unguarded] |
0.717 | 0.612 | -14.5% |
test_enabled_emit[guarded] |
2.834 | 2.625 | -7.4% |
test_enabled_emit[unguarded] |
2.584 | 2.500 | -3.3% |
Description
Changes
SeverityNumberfromenum.Enumtoenum.IntEnumbeforeopentelemetry.logsis stabilized.Resolves #5785
Type of change
Please delete options that are not relevant.
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.
tox -e precommittox -e typecheck