Skip to content

Commit

Permalink
fix start time
Browse files Browse the repository at this point in the history
  • Loading branch information
P403n1x87 committed Jan 9, 2025
1 parent f108c5a commit 2d85475
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
5 changes: 2 additions & 3 deletions ddtrace/debugging/_origin/span.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ def __enter__(self):
s.set_tag_str("_dd.code_origin.frames.0.type", location.module)
s.set_tag_str("_dd.code_origin.frames.0.method", location.name)

self.set("start_time", monotonic_ns())

return self

def _close_signal(self, retval=None, exc_info=(None, None, None)):
Expand All @@ -180,9 +182,6 @@ def _close_signal(self, retval=None, exc_info=(None, None, None)):
root.set_tag_str("_dd.code_origin.frames.0.snapshot_id", snapshot.uuid)
span.set_tag_str("_dd.code_origin.frames.0.snapshot_id", snapshot.uuid)

self.set("snapshot", snapshot)
self.set("start_time", monotonic_ns())

snapshot.do_exit(retval, exc_info, monotonic_ns() - self.get("start_time"))

self.collector.push(snapshot)
Expand Down
16 changes: 16 additions & 0 deletions tests/debugging/test_session.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
import pytest

from ddtrace.debugging._session import DEFAULT_SESSION_LEVEL
from ddtrace.debugging._session import Session
from ddtrace.debugging._session import _sessions_from_debug_tag
from ddtrace.debugging._session import _sessions_to_debug_tag


@pytest.mark.parametrize(
"tag,sessions",
[
("session1", [Session("session1", DEFAULT_SESSION_LEVEL)]),
("session1:2", [Session("session1", 2)]),
("session1:1.session2:2", [Session("session1", 1), Session("session2", 2)]),
("session1.session2", [Session("session1", DEFAULT_SESSION_LEVEL), Session("session2", DEFAULT_SESSION_LEVEL)]),
],
)
def test_session_parse(tag, sessions):
assert list(_sessions_from_debug_tag(tag)) == sessions


@pytest.mark.parametrize(
"a,b",
[
("session1:1.session2:2", "session1.session2:2"),
("session1:0.session2:2", "session1:0.session2:2"),
("session1.session2", "session1.session2"),
],
)
def test_tag_identity(a, b):
Expand Down

0 comments on commit 2d85475

Please sign in to comment.