|
13 | 13 | ) |
14 | 14 | from sentry_sdk.integrations import DidNotEnable, Integration, _check_minimum_version |
15 | 15 | from sentry_sdk.integrations._wsgi_common import RequestExtractor, _filter_headers |
16 | | -from sentry_sdk.integrations.logging import ignore_logger |
17 | 16 | from sentry_sdk.scope import should_send_default_pii |
18 | 17 | from sentry_sdk.traces import SegmentNameSource, StreamedSpan |
19 | 18 | from sentry_sdk.tracing import TransactionSource |
@@ -78,22 +77,6 @@ def setup_once() -> None: |
78 | 77 | SanicIntegration.version = parse_version(SANIC_VERSION) |
79 | 78 | _check_minimum_version(SanicIntegration, SanicIntegration.version) |
80 | 79 |
|
81 | | - if SANIC_VERSION.startswith("0.8."): |
82 | | - # Sanic 0.8 and older creates a logger named "root" and puts a |
83 | | - # stringified version of every exception in there (without exc_info), |
84 | | - # which our error deduplication can't detect. |
85 | | - # |
86 | | - # We explicitly check the version here because it is a very |
87 | | - # invasive step to ignore this logger and not necessary in newer |
88 | | - # versions at all. |
89 | | - # |
90 | | - # https://github.com/huge-success/sanic/issues/1332 |
91 | | - ignore_logger("root") |
92 | | - |
93 | | - if SanicIntegration.version is not None and SanicIntegration.version < (21, 9): |
94 | | - _setup_legacy_sanic() |
95 | | - return |
96 | | - |
97 | 80 | _setup_sanic() |
98 | 81 |
|
99 | 82 |
|
@@ -130,12 +113,6 @@ def _setup_sanic() -> None: |
130 | 113 | ErrorHandler.lookup = _sentry_error_handler_lookup |
131 | 114 |
|
132 | 115 |
|
133 | | -def _setup_legacy_sanic() -> None: |
134 | | - Sanic.handle_request = _legacy_handle_request |
135 | | - Router.get = _legacy_router_get |
136 | | - ErrorHandler.lookup = _sentry_error_handler_lookup |
137 | | - |
138 | | - |
139 | 116 | async def _startup(self: "Sanic") -> None: |
140 | 117 | # This happens about as early in the lifecycle as possible, just after the |
141 | 118 | # Request object is created. The body has not yet been consumed. |
@@ -300,54 +277,6 @@ async def sentry_wrapped_error_handler( |
300 | 277 | return sentry_wrapped_error_handler |
301 | 278 |
|
302 | 279 |
|
303 | | -async def _legacy_handle_request( |
304 | | - self: "Any", request: "Request", *args: "Any", **kwargs: "Any" |
305 | | -) -> "Any": |
306 | | - if sentry_sdk.get_client().get_integration(SanicIntegration) is None: |
307 | | - return await old_handle_request(self, request, *args, **kwargs) |
308 | | - |
309 | | - weak_request = weakref.ref(request) |
310 | | - |
311 | | - with sentry_sdk.isolation_scope() as scope: |
312 | | - scope.clear_breadcrumbs() |
313 | | - scope.add_event_processor(_make_request_processor(weak_request)) |
314 | | - |
315 | | - response = old_handle_request(self, request, *args, **kwargs) |
316 | | - if isawaitable(response): |
317 | | - response = await response |
318 | | - |
319 | | - return response |
320 | | - |
321 | | - |
322 | | -def _legacy_router_get(self: "Any", *args: "Union[Any, Request]") -> "Any": |
323 | | - rv = old_router_get(self, *args) |
324 | | - if sentry_sdk.get_client().get_integration(SanicIntegration) is not None: |
325 | | - with capture_internal_exceptions(): |
326 | | - scope = sentry_sdk.get_isolation_scope() |
327 | | - if SanicIntegration.version and SanicIntegration.version >= (21, 3): |
328 | | - # Sanic versions above and including 21.3 append the app name to the |
329 | | - # route name, and so we need to remove it from Route name so the |
330 | | - # transaction name is consistent across all versions |
331 | | - sanic_app_name = self.ctx.app.name |
332 | | - sanic_route = rv[0].name |
333 | | - |
334 | | - if sanic_route.startswith("%s." % sanic_app_name): |
335 | | - # We add a 1 to the len of the sanic_app_name because there is a dot |
336 | | - # that joins app name and the route name |
337 | | - # Format: app_name.route_name |
338 | | - sanic_route = sanic_route[len(sanic_app_name) + 1 :] |
339 | | - |
340 | | - scope.set_transaction_name( |
341 | | - sanic_route, source=TransactionSource.COMPONENT |
342 | | - ) |
343 | | - else: |
344 | | - scope.set_transaction_name( |
345 | | - rv[0].__name__, source=TransactionSource.COMPONENT |
346 | | - ) |
347 | | - |
348 | | - return rv |
349 | | - |
350 | | - |
351 | 280 | @ensure_integration_enabled(SanicIntegration) |
352 | 281 | def _capture_exception(exception: "Union[ExcInfo, BaseException]") -> None: |
353 | 282 | with capture_internal_exceptions(): |
|
0 commit comments