Skip to content

Commit

Permalink
fix(tracing): add Context back to the public api (#10044)
Browse files Browse the repository at this point in the history
  • Loading branch information
mabdinur authored Aug 16, 2024
1 parent 430a9dc commit 100bc17
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ddtrace/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


deprecate(
"The context interface is deprecated.",
message="The trace context is an internal interface and will no longer be supported.",
"The ddtrace.context module is deprecated and will be removed from the public API.",
message="Context should be imported from the ddtrace.trace package",
category=DDTraceDeprecationWarning,
)
2 changes: 1 addition & 1 deletion ddtrace/internal/opentelemetry/trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def start_span(
curr_otel_span = get_current_span(context)
if curr_otel_span is INVALID_SPAN:
# There is no active datadog/otel span
dd_active = None # type: Optional[Union[ddtrace.context.Context, ddtrace.Span]]
dd_active = None # type: Optional[Union[ddtrace.trace.Context, ddtrace.Span]]
elif isinstance(curr_otel_span, Span):
# Get underlying ddtrace span from the active otel span
dd_active = curr_otel_span._ddspan
Expand Down
7 changes: 7 additions & 0 deletions ddtrace/trace/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from ddtrace._trace.context import Context


# TODO: Move `ddtrace.Pin`, `ddtrace.Tracer`, `ddtrace.Span`, and `ddtrace.tracer` to this module
__all__ = [
"Context",
]
2 changes: 1 addition & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Tracing
.. autoclass:: ddtrace.Pin
:members:

.. autoclass:: ddtrace.context.Context
.. autoclass:: ddtrace.trace.Context
:members:
:undoc-members:

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
fixes:
- |
tracing: Adds ``ddtrace.trace.Context`` to the public api. This class can now be used to propagate context across execution boundaries (ex: threads).
1 change: 1 addition & 0 deletions tests/.suitespec.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"ddtrace/_logger.py",
"ddtrace/_monkey.py",
"ddtrace/_trace/*",
"ddtrace/trace/*",
"ddtrace/constants.py",
"ddtrace/context.py",
"ddtrace/filters.py",
Expand Down

0 comments on commit 100bc17

Please sign in to comment.