|
1 | 1 | from collections.abc import Set |
2 | 2 | import sentry_sdk |
3 | 3 | from sentry_sdk.consts import OP |
4 | | -from sentry_sdk.integrations import _DEFAULT_FAILED_REQUEST_STATUS_CODES, DidNotEnable, Integration |
| 4 | +from sentry_sdk.integrations import ( |
| 5 | + _DEFAULT_FAILED_REQUEST_STATUS_CODES, |
| 6 | + DidNotEnable, |
| 7 | + Integration, |
| 8 | +) |
5 | 9 | from sentry_sdk.integrations.asgi import SentryAsgiMiddleware |
6 | 10 | from sentry_sdk.integrations.logging import ignore_logger |
7 | 11 | from sentry_sdk.scope import should_send_default_pii |
@@ -47,9 +51,10 @@ class LitestarIntegration(Integration): |
47 | 51 | identifier = "litestar" |
48 | 52 | origin = f"auto.http.{identifier}" |
49 | 53 |
|
50 | | - def __init__(self, |
51 | | - failed_request_status_codes=_DEFAULT_FAILED_REQUEST_STATUS_CODES, # type: Set[int] |
52 | | - ) -> None: |
| 54 | + def __init__( |
| 55 | + self, |
| 56 | + failed_request_status_codes=_DEFAULT_FAILED_REQUEST_STATUS_CODES, # type: Set[int] |
| 57 | + ) -> None: |
53 | 58 | self.failed_request_status_codes = failed_request_status_codes |
54 | 59 |
|
55 | 60 | @staticmethod |
@@ -285,11 +290,12 @@ def exception_handler(exc, scope): |
285 | 290 | sentry_scope.set_user(user_info) |
286 | 291 |
|
287 | 292 | if isinstance(exc, HTTPException): |
288 | | - integration = sentry_sdk.get_client().get_integration( |
289 | | - LitestarIntegration |
290 | | - ) |
291 | | - if integration is not None and exc.status_code not in integration.failed_request_status_codes: |
292 | | - return |
| 293 | + integration = sentry_sdk.get_client().get_integration(LitestarIntegration) |
| 294 | + if ( |
| 295 | + integration is not None |
| 296 | + and exc.status_code not in integration.failed_request_status_codes |
| 297 | + ): |
| 298 | + return |
293 | 299 |
|
294 | 300 | event, hint = event_from_exception( |
295 | 301 | exc, |
|
0 commit comments