-
Notifications
You must be signed in to change notification settings - Fork 395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Store span ids in profiling events #1043
Conversation
372760e
to
f97f8ef
Compare
tests/test_tracer.py
Outdated
|
||
span2 = self.span2 | ||
del self.span2 | ||
assert self.tracer.thread_to_span[th.ident] == span2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we call span2.finish()
, th.ident
should be removed from self.tracer.thread_to_span
correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessarily; it'll be removed as soon there's no ref to span2
and once the GC has run.
f97f8ef
to
28d5e72
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The approach for linking threads and spans looks good so far!
ddtrace/_linker.py
Outdated
for span in set(spans): | ||
if not span.finished: | ||
try: | ||
spans.remove(span._parent) | ||
except KeyError: | ||
pass | ||
|
||
return {span for span in spans if not span.finished} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reuse the other function and use set difference.
for span in set(spans): | |
if not span.finished: | |
try: | |
spans.remove(span._parent) | |
except KeyError: | |
pass | |
return {span for span in spans if not span.finished} | |
active_spans = self.get_active_spans_from_thread_id(thread_id) | |
return active_spans - {span._parent for span in active_spans} |
782d4ee
to
0deb7ca
Compare
Could we move the hooks changes to a separate PR? Not super necessary, just a tad cleaner 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Did a first pass 🙂.
Didn't review the hook changes yet, I will do so here if you'd like to keep those changes in this PR.
The hooks changed have being pulled out in #1428 |
6b19054
to
9144b60
Compare
This allows to register a function to be called when a new span is being started by a Tracer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one last comment but I think otherwise it's good to go!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥳 this is a super cool feature!
feat(tracer): add a on_start_span hook
This allows to register a function to be called when a new span is being
started by a Tracer.
chore(black): blackify ddtrace/settings
feat(profiling/stack): collect span ids for running thread and stack frames