Repository navigation
fix(internal): format logged exceptions on Python 3.9 - #22026
Conversation
traceback.format_exception(exc) with a single argument only exists in Python 3.10+, so product logs carrying exc_info raised a TypeError inside the logging filter on 3.9, which dd-trace-py still supports. Pass the (type, value, traceback) triple instead, which works on every version. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Codeowners resolved asResolved from the full PR diff against |
Dependency direction analysis
|
There was a problem hiding this comment.
More details
Passing the complete exception tuple fixes the Python 3.9 signature mismatch while remaining compatible with later Python versions. The added regression test exercises the affected product-logging path.
🤖 Bits Code Review · Commit aaf8b03
🎉 All green!🧪 All tests passed 🔗 Commit SHA: aaf8b03 | Docs | View more details | Give us feedback! |
BenchmarksBenchmark execution time: 2026-11-23 15:38:27 Comparing candidate commit aaf8b03 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 644 metrics, 10 unstable metrics, 1 flaky benchmarks without significant changes.
|
Description
On Python 3.9, a product log that carries exception info (
log.error(..., exc_info=True, extra={"product": ...})) raisedTypeErrorinside ddtrace's logging filter, so the log call itself failed.ddtrace/internal/logger.pycalledtraceback.format_exception(record.exc_info[1], limit=...). That single-exception signature only exists from Python 3.10. This change callstraceback.format_exception(*record.exc_info, limit=...), which works on every supported Python.Found while porting
ddtrace/internal/logger.pyto theddtrace-internalpackage (DataDog/datadog-apm-python#77). It's split out as its own PR so it can be backported.Testing
test_product_log_formats_exc_infointests/internal/test_logger.py.tests/internal/test_logger.pypasses on 3.9 and 3.12 (12 passed).Risks
None. The output is unchanged on 3.10+.
Additional Notes
Release note included.