Skip to content

Commit dc72fd3

Browse files
fix(ddtrace_api): avoid clobbering ddtrace_api's stored tracer instance [backport 3.11] (#14160)
Fixes a bug in the ddtrace_api integration in which `patch()` with no arguments, and thus `patch_all()`, breaks the integration. ## Checklist - [x] PR author has checked that all the criteria below are met - The PR description includes an overview of the change - The PR description articulates the motivation for the change - The change includes tests OR the PR description describes a testing strategy - The PR description notes risks associated with the change, if any - Newly-added code is easy to change - The change follows the [library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) - The change includes or references documentation updates if necessary - Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) ## Reviewer Checklist - [x] Reviewer has checked that all the criteria below are met - Title is accurate - All changes are related to the pull request's stated goal - Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - Testing strategy adequately addresses listed risks - Newly-added code is easy to change - Release note makes sense to a user of the library - If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment - Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting) --------- (cherry picked from commit f5626c7) Co-authored-by: Brett Langdon <[email protected]>
1 parent e581279 commit dc72fd3

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

ddtrace/contrib/internal/ddtrace_api/patch.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ def _supported_versions() -> Dict[str, str]:
9191
def patch(tracer=None):
9292
if getattr(ddtrace_api, "__datadog_patch", False):
9393
return
94-
_STUB_TO_REAL[ddtrace_api.tracer] = tracer
94+
if tracer is not None:
95+
_STUB_TO_REAL[ddtrace_api.tracer] = tracer
9596

9697
DDTraceAPIWrappingContextBase(ddtrace_api.Tracer.start_span).wrap()
9798
DDTraceAPIWrappingContextBase(ddtrace_api.Tracer.trace).wrap()
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
fixes:
3+
- |
4+
ddtrace_api: Fixes a bug in the ddtrace_api integration in which ``patch()`` with no arguments, and
5+
thus ``patch_all()``, breaks the integration.

0 commit comments

Comments
 (0)