From cb41f8e77aa71bfffbb63f7ee1a9808e659189d2 Mon Sep 17 00:00:00 2001 From: Munir Abdinur Date: Wed, 29 Jan 2025 08:39:44 -0500 Subject: [PATCH] feat(provider): expose context provider in ddtrace.trace (#12135) 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) --- .github/CODEOWNERS | 2 ++ ddtrace/provider.py | 5 +++-- ddtrace/trace/__init__.py | 2 ++ docs/advanced_usage.rst | 2 +- .../feat-expose-base-context-provider-530ebec2225f6c8d.yaml | 5 +++++ 5 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/feat-expose-base-context-provider-530ebec2225f6c8d.yaml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 84e6c873642..b1162da2348 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -166,12 +166,14 @@ ddtrace/internal/remoteconfig @DataDog/remote-config @DataDog/apm-core-pyt tests/internal/remoteconfig @DataDog/remote-config @DataDog/apm-core-python # API SDK +ddtrace/trace/ @DataDog/apm-sdk-api-python ddtrace/_trace/ @DataDog/apm-sdk-api-python ddtrace/opentelemetry/ @DataDog/apm-sdk-api-python ddtrace/internal/opentelemetry @DataDog/apm-sdk-api-python ddtrace/opentracer/ @DataDog/apm-sdk-api-python ddtrace/propagation/ @DataDog/apm-sdk-api-python ddtrace/filters.py @DataDog/apm-sdk-api-python +ddtrace/provider.py @DataDog/apm-sdk-api-python ddtrace/pin.py @DataDog/apm-sdk-api-python ddtrace/sampler.py @DataDog/apm-sdk-api-python ddtrace/sampling_rule.py @DataDog/apm-sdk-api-python diff --git a/ddtrace/provider.py b/ddtrace/provider.py index 4a275ece8c8..7b9867de01a 100644 --- a/ddtrace/provider.py +++ b/ddtrace/provider.py @@ -7,7 +7,8 @@ deprecate( - "The context provider interface is deprecated.", - message="The trace context is an internal interface and will no longer be supported.", + "The context provider interface is deprecated", + message="Import BaseContextProvider from `ddtrace.trace` instead.", category=DDTraceDeprecationWarning, + removal_version="3.0.0", ) diff --git a/ddtrace/trace/__init__.py b/ddtrace/trace/__init__.py index f709310d589..8473c0b99f0 100644 --- a/ddtrace/trace/__init__.py +++ b/ddtrace/trace/__init__.py @@ -1,6 +1,7 @@ from ddtrace._trace.context import Context from ddtrace._trace.filters import TraceFilter from ddtrace._trace.pin import Pin +from ddtrace._trace.provider import BaseContextProvider from ddtrace._trace.span import Span from ddtrace._trace.tracer import Tracer @@ -15,4 +16,5 @@ "Tracer", "Span", "tracer", + "BaseContextProvider", ] diff --git a/docs/advanced_usage.rst b/docs/advanced_usage.rst index 05879acac37..392e1406fb7 100644 --- a/docs/advanced_usage.rst +++ b/docs/advanced_usage.rst @@ -221,7 +221,7 @@ context management. If there is a case where the default is insufficient then a custom context provider can be used. It must implement the -:class:`ddtrace.provider.BaseContextProvider` interface and can be configured +:class:`ddtrace.trace.BaseContextProvider` interface and can be configured with:: tracer.configure(context_provider=MyContextProvider) diff --git a/releasenotes/notes/feat-expose-base-context-provider-530ebec2225f6c8d.yaml b/releasenotes/notes/feat-expose-base-context-provider-530ebec2225f6c8d.yaml new file mode 100644 index 00000000000..010d2bf52bd --- /dev/null +++ b/releasenotes/notes/feat-expose-base-context-provider-530ebec2225f6c8d.yaml @@ -0,0 +1,5 @@ +--- +deprecations: + - | + tracing: Moves ``ddtrace.provider.BaseContextProvider`` to ``ddtrace.trace.BaseContextProvider``. + The ``ddtrace.provider`` module is deprecated and will be removed in v3.0.0.