Skip to content

Commit f6d814c

Browse files
feat(provider): expose context provider in ddtrace.trace [backport 2.20] (#12137)
Backport cb41f8e from #12135 to 2.20. ddtrace v3.0 is set to remove `ddtrace.providers` module from the public API. However we should still allow users to use their own ContextProviders. This PR ensures the BaseContextProvider remains in the public API and can be used in `tracer.configure(...)`. ## 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) Co-authored-by: Munir Abdinur <[email protected]>
1 parent ccd6f75 commit f6d814c

File tree

5 files changed

+13
-3
lines changed

5 files changed

+13
-3
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,14 @@ ddtrace/internal/remoteconfig @DataDog/remote-config @DataDog/apm-core-pyt
164164
tests/internal/remoteconfig @DataDog/remote-config @DataDog/apm-core-python
165165

166166
# API SDK
167+
ddtrace/trace/ @DataDog/apm-sdk-api-python
167168
ddtrace/_trace/ @DataDog/apm-sdk-api-python
168169
ddtrace/opentelemetry/ @DataDog/apm-sdk-api-python
169170
ddtrace/internal/opentelemetry @DataDog/apm-sdk-api-python
170171
ddtrace/opentracer/ @DataDog/apm-sdk-api-python
171172
ddtrace/propagation/ @DataDog/apm-sdk-api-python
172173
ddtrace/filters.py @DataDog/apm-sdk-api-python
174+
ddtrace/provider.py @DataDog/apm-sdk-api-python
173175
ddtrace/pin.py @DataDog/apm-sdk-api-python
174176
ddtrace/sampler.py @DataDog/apm-sdk-api-python
175177
ddtrace/sampling_rule.py @DataDog/apm-sdk-api-python

ddtrace/provider.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88

99
deprecate(
10-
"The context provider interface is deprecated.",
11-
message="The trace context is an internal interface and will no longer be supported.",
10+
"The context provider interface is deprecated",
11+
message="Import BaseContextProvider from `ddtrace.trace` instead.",
1212
category=DDTraceDeprecationWarning,
13+
removal_version="3.0.0",
1314
)

ddtrace/trace/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from ddtrace._trace.context import Context
22
from ddtrace._trace.filters import TraceFilter
33
from ddtrace._trace.pin import Pin
4+
from ddtrace._trace.provider import BaseContextProvider
45
from ddtrace._trace.span import Span
56
from ddtrace._trace.tracer import Tracer
67

@@ -15,4 +16,5 @@
1516
"Tracer",
1617
"Span",
1718
"tracer",
19+
"BaseContextProvider",
1820
]

docs/advanced_usage.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ context management.
221221

222222
If there is a case where the default is insufficient then a custom context
223223
provider can be used. It must implement the
224-
:class:`ddtrace.provider.BaseContextProvider` interface and can be configured
224+
:class:`ddtrace.trace.BaseContextProvider` interface and can be configured
225225
with::
226226

227227
tracer.configure(context_provider=MyContextProvider)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
deprecations:
3+
- |
4+
tracing: Moves ``ddtrace.provider.BaseContextProvider`` to ``ddtrace.trace.BaseContextProvider``.
5+
The ``ddtrace.provider`` module is deprecated and will be removed in v3.0.0.

0 commit comments

Comments
 (0)