-
Notifications
You must be signed in to change notification settings - Fork 417
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
61 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,10 @@ | ||
import typing as t | ||
|
||
from ddtrace.debugging._session import Session | ||
from ddtrace.internal import core | ||
|
||
|
||
def handle_distributed_context(context: t.Any) -> None: | ||
debug_tag = context._meta.get("_dd.p.debug") | ||
if debug_tag is None: | ||
return | ||
|
||
for session in debug_tag.split(","): | ||
ident, _, level = session.partition(":") | ||
Session(ident=ident, level=int(level or 0)).link_to_trace(context) | ||
|
||
|
||
def enable() -> None: | ||
core.on("distributed_context.activated", handle_distributed_context, "live_debugger") | ||
core.on("distributed_context.activated", Session.from_trace_context, "live_debugger") | ||
|
||
|
||
def disable() -> None: | ||
core.reset_listeners("distributed_context.activated", handle_distributed_context) | ||
core.reset_listeners("distributed_context.activated", Session.from_trace_context) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from ddtrace.debugging._session import _sessions_from_debug_tag | ||
from ddtrace.debugging._session import _sessions_to_debug_tag | ||
|
||
|
||
def test_tag_identity(): | ||
""" | ||
Test that the combination of _sessions_from_debug_tag and | ||
_sessions_to_debug_tag is the identity function. | ||
""" | ||
debug_tag = "session1:1,session2:2" | ||
assert _sessions_to_debug_tag(_sessions_from_debug_tag(debug_tag)) == debug_tag |