Skip to content
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 WSGI middleware and frameworks #3531

Merged
merged 13 commits into from
Oct 1, 2024

Conversation

antonpirker
Copy link
Member

@antonpirker antonpirker commented Sep 12, 2024

  • Do not capture transactions for OPTIONS and HEAD HTTP methods by default.
  • Make it possible with an http_methods_to_capture config option for Django and Flask, to specify what HTTP methods to capture.

Fixes #3528

Docs PR:
getsentry/sentry-docs#11348

Copy link

codecov bot commented Sep 12, 2024

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
12036 1 12035 1650
View the top 1 failed tests by shortest run time
tests.integrations.httpx.test_httpx test_crumb_capture_and_hint[httpx_client0]
Stack Traces | 5.23s run time
.tox/py3.9-httpx-v0.16/lib/python3.9....../site-packages/httpx/_exceptions.py:326: in map_exceptions
    yield
.tox/py3.9-httpx-v0.16/lib/python3.9...................../site-packages/httpx/_client.py:861: in _send_single_request
    (status_code, headers, stream, ext) = transport.request(
.tox/py3.9-httpx-v0.16/lib/python3.9.../httpcore/_sync/connection_pool.py:218: in request
    response = connection.request(
.tox/py3.9-httpx-v0.16/lib/python3.9.../httpcore/_sync/connection.py:93: in request
    self.socket = self._open_socket(timeout)
.tox/py3.9-httpx-v0.16/lib/python3.9.../httpcore/_sync/connection.py:119: in _open_socket
    return self.backend.open_tcp_stream(
.tox/py3.9-httpx-v0.16/lib/python3.9.../httpcore/_backends/sync.py:143: in open_tcp_stream
    return SyncSocketStream(sock=sock)
.../hostedtoolcache/Python/3.9.20....../x64/lib/python3.9/contextlib.py:137: in __exit__
    self.gen.throw(typ, value, traceback)
.tox/py3.9-httpx-v0.16/lib/python3.9.../site-packages/httpcore/_exceptions.py:12: in map_exceptions
    raise to_exc(exc) from None
E   httpcore.ConnectError: [Errno 101] Network is unreachable

The above exception was the direct cause of the following exception:
.../integrations/httpx/test_httpx.py:37: in test_crumb_capture_and_hint
    response = httpx_client.get(url)
.tox/py3.9-httpx-v0.16/lib/python3.9...................../site-packages/httpx/_client.py:907: in get
    return self.request(
.tox/py3.9-httpx-v0.16/lib/python3.9...................../site-packages/httpx/_client.py:733: in request
    return self.send(
sentry_sdk/utils.py:1786: in runner
    return sentry_patched_function(*args, **kwargs)
sentry_sdk/integrations/httpx.py:87: in send
    rv = real_send(self, request, **kwargs)
.tox/py3.9-httpx-v0.16/lib/python3.9...................../site-packages/httpx/_client.py:767: in send
    response = self._send_handling_auth(
.tox/py3.9-httpx-v0.16/lib/python3.9...................../site-packages/httpx/_client.py:805: in _send_handling_auth
    response = self._send_handling_redirects(
.tox/py3.9-httpx-v0.16/lib/python3.9...................../site-packages/httpx/_client.py:837: in _send_handling_redirects
    response = self._send_single_request(request, timeout)
.tox/py3.9-httpx-v0.16/lib/python3.9...................../site-packages/httpx/_client.py:861: in _send_single_request
    (status_code, headers, stream, ext) = transport.request(
.../hostedtoolcache/Python/3.9.20....../x64/lib/python3.9/contextlib.py:137: in __exit__
    self.gen.throw(typ, value, traceback)
.tox/py3.9-httpx-v0.16/lib/python3.9....../site-packages/httpx/_exceptions.py:343: in map_exceptions
    raise mapped_exc(message, **kwargs) from exc  # type: ignore
E   httpx.ConnectError: [Errno 101] Network is unreachable

To view individual test run time comparison to the main branch, go to the Test Analytics Dashboard

@antonpirker antonpirker marked this pull request as ready for review September 13, 2024 06:51
@antonpirker antonpirker changed the title Configure http methods to capture in wsgi middleware Configure HTTP methods to capture in WSGI middleware and framworks Sep 13, 2024
@antonpirker antonpirker changed the title Configure HTTP methods to capture in WSGI middleware and framworks Configure HTTP methods to capture in WSGI middleware and frameworks Sep 13, 2024
Copy link
Contributor

@sentrivana sentrivana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

…3533)

- Do not capture transactions for `OPTIONS` and `HEAD` HTTP methods by default. 
- Make it possible with an `http_methods_to_capture` config option for Starlette and FastAPI, to specify what HTTP methods to capture.

Fixes #3529
@antonpirker antonpirker enabled auto-merge (squash) October 1, 2024 12:26
@antonpirker antonpirker merged commit 1c64ff7 into master Oct 1, 2024
135 of 136 checks passed
@antonpirker antonpirker deleted the antonpirker/http_methods_to_capture branch October 1, 2024 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't trace OPTIONS and HEAD in WSGI frameworks by default
2 participants