-
Notifications
You must be signed in to change notification settings - Fork 509
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
Use executing to infer code qualname #749
Conversation
I'm getting a Django test failure, but when I try running the tests locally, I get
What's the procedure for testing without tox? |
4b61ff3
to
c353254
Compare
I don't understand what's happening with the project coverage. |
@alexmojaki Hey, sorry for responding so late! Would it be possible to have this be behind some sort of feature flag or integration, even? I think one could use the global event processors similar to how gnu backtrace does it to overwrite the data. The reason I am asking is because I am still not sure if doing this sort of thing incurs performance overhead, and if so, I would hate to see it being enabled simply because some package is installed. Now to your questions:
|
OK, I'm happy to make this optional based on an integration or something. However I don't know how to implement that. I can't take the approach of GNU backtrace because I need the actual code object (and similarly the other features need an actual frame object) which is not available in the data by the time I reach an event processor. Being able to use the frame directly within def function_name(frame):
# type: (FrameType) -> str
from sentry_sdk import Hub
from sentry_sdk.integrations.executing import ExecutingIntegration
if Hub.current.get_integration(ExecutingIntegration) is None:
return frame.f_code.co_name
else:
import executing
return executing.Source.for_frame(frame).code_qualname(frame.f_code) and apart from being awkward it doesn't work. I don't know how exactly Hub.current works, but apparently not like this. Any ideas? |
Ah sorry, I misremembered. The "prior art" can be found in the Django integration, where we access the sentry-python/sentry_sdk/integrations/django/__init__.py Lines 150 to 152 in dce439f
I acknowledge this is extremely awkward, but it still kind of keeps the API surface between the core SDK and the other integrations minimal. If one had to fully separate the integrations from the core sdk the utility functions used could be easily vendored. |
It's a thread local. If the executing integration is enabled once it should at least be accessible on the same thread. |
Regarding performance, there are three main sources of overhead:
|
What I found is that in hub = Hub(...)
hub.capture_message("HI") which leads directly to |
You're right. I would ignore this error for now, I would argue the testcase is unrealistic. Hub isn't supposed to be used directly, at least not like that. The testcases using I can fix that testcase up for you when the time comes. |
OK, this mostly works, but only if there's an actual exception. It doesn't work in cases like I don't think I can make the diff coverage 90% without jumping through unreasonable hoops. |
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 great! Can you:
- open a PR against https://github.com/getsentry/sentry-docs to add documentation for this integration (closest contender for similar integration is GNU Backtrace, introduced in getsentry/sentry-docs@4382341)
- Add an entry like this to Sentry such that Sentry suggests people to enable this integration if executing is installed (when viewing an event)
Merging this now so you can rebase the other prs |
This is one of the features mentioned in #748. As requested by @untitaker I've made executing an optional dependency.