-
Notifications
You must be signed in to change notification settings - Fork 530
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
Refactor Sanic integration for v21.9 support #1212
Conversation
@AbhiPrasad So, I think this is generally a better approach. It will avoid touching Instead, we monkeypatch the Locally all of the tests pass, except for weak_request = weakref.ref(request)
request.ctx._sentry_hub = Hub(hub)
request.ctx._sentry_hub.__enter__()
with request.ctx._sentry_hub.configure_scope() as scope:
scope.clear_breadcrumbs()
scope.add_event_processor(_make_request_processor(weak_request)) with capture_internal_exceptions():
with hub.configure_scope() as scope: Also, what is the @app.route("/context-check/<i>")
async def context_check(request, i):
with configure_scope() as scope:
scope.set_tag("i", i)
await asyncio.sleep(random.random())
with configure_scope() as scope:
assert scope._tags["i"] == i
return response.text("ok") Any insight you could share? UPDATE: Nevermind... I figured it out. I just pushed another commit now where I believe all tests 🤞 should pass (they do locally 😆 ) I ran it using 21.9, 21.6, 21.3, 20.12 ✔️ |
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.
Thanks for the PR.
We have tried to focus on LTS versions as documented in https://docs.sentry.io/platforms/python/guides/sanic/.
We did merge in contributions to support recent non-LTS versions, but that's coming with a maintenance cost.
I'm happy we take this in to unblock users, but would also like to strongly consider dropping support for the non-LTS releases once 21.12 is out. Would that be a fair ask?
sentry_sdk/integrations/sanic.py
Outdated
|
||
class SanicIntegration(Integration): | ||
identifier = "sanic" | ||
|
||
@staticmethod | ||
def setup_once(): | ||
# type: () -> None | ||
|
||
global version |
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.
For maintainability and testability, I'd avoid global state and make this an instance attribute of SanicIntegration
.
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.
Are you okay with it being a class attribute?
That is a contract between you and your user base. I'm happy to make this PR to help out and/or be a resource as needed. |
Co-authored-by: Rodolfo Carvalho <rhcarvalho@gmail.com>
Thank you for your contribution @ahopkins! |
This PR allows for Sanic v21.9 style error handlers to operate and provide full access to handling Blueprint specific error handlers.
Source
See also: sanic-org/sanic#2259
UPDATE:
Fixes #1240
Fixes sanic-org/sanic#2250