-
Notifications
You must be signed in to change notification settings - Fork 503
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
Configure HTTP methods to capture in ASGI middleware and frameworks #3533
Configure HTTP methods to capture in ASGI middleware and frameworks #3533
Conversation
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## antonpirker/http_methods_to_capture #3533 +/- ##
=======================================================================
- Coverage 84.30% 84.29% -0.01%
=======================================================================
Files 133 133
Lines 13902 13914 +12
Branches 2933 2936 +3
=======================================================================
+ Hits 11720 11729 +9
Misses 1444 1444
- Partials 738 741 +3
|
if transaction is not None: | ||
is_http_response = ( | ||
event.get("type") == "http.response.start" | ||
and "status" in event | ||
) | ||
if is_http_response: | ||
transaction.set_http_status(event["status"]) |
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.
I did it this way to make mypy happy
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.
mypy also made me do things I'm not proud of. We need mypy anonymous
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.
See comments, we can dedup some things but looks very nice
@@ -15,6 +15,19 @@ | |||
from sentry_sdk.utils import AnnotatedValue | |||
|
|||
|
|||
DEFAULT_HTTP_METHODS_TO_CAPTURE = ( |
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.
Should we maybe just import this from _wsgi_common
here? Or directly use the _wsgi_common
constant in the integrations?
# This noop context manager can be replaced with "from contextlib import nullcontext" when we drop Python 3.6 support | ||
@contextmanager | ||
def nullcontext(): | ||
# type: () -> Iterator[None] | ||
yield |
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.
Maybe move this to utils.py
and use it from there? Also for wsgi.py
if transaction is not None: | ||
is_http_response = ( | ||
event.get("type") == "http.response.start" | ||
and "status" in event | ||
) | ||
if is_http_response: | ||
transaction.set_http_status(event["status"]) |
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.
mypy also made me do things I'm not proud of. We need mypy anonymous
8944047
into
antonpirker/http_methods_to_capture
I have merge this PR into #3531 and did the de-duping in the other PR. |
OPTIONS
andHEAD
HTTP methods by default.http_methods_to_capture
config option for Starlette and FastAPI, to specify what HTTP methods to capture.Fixes #3529
Docs PR:
getsentry/sentry-docs#11349