-
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.
We implement trigger probes. These allows triggering the capture of debug information along a trace, ensuring all the relevant probes are also triggered.
- Loading branch information
Showing
4 changed files
with
145 additions
and
48 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
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,30 @@ | ||
from dataclasses import dataclass | ||
import typing as t | ||
from weakref import WeakKeyDictionary as wkdict | ||
|
||
from ddtrace import tracer | ||
|
||
|
||
@dataclass | ||
class Session: | ||
ident: str | ||
level: int | ||
|
||
def link_to_trace(self): | ||
SessionManager.link_session_to_trace(self) | ||
|
||
@classmethod | ||
def get_for_trace(cls) -> t.Optional["Session"]: | ||
return SessionManager.get_session_for_trace() | ||
|
||
|
||
class SessionManager: | ||
_session_trace_map: wkdict = wkdict() # Span to Session mapping | ||
|
||
@classmethod | ||
def link_session_to_trace(cls, session) -> None: | ||
cls._session_trace_map[tracer.current_root_span()] = session | ||
|
||
@classmethod | ||
def get_session_for_trace(cls) -> t.Optional[Session]: | ||
return cls._session_trace_map.get(tracer.current_root_span()) |
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