44
44
45
45
if TYPE_CHECKING :
46
46
from aiohttp .web_request import Request
47
- from aiohttp .abc import AbstractMatchInfo
47
+ from aiohttp .web_urldispatcher import UrlMappingMatchInfo
48
48
from aiohttp import TraceRequestStartParams , TraceRequestEndParams
49
49
from types import SimpleNamespace
50
50
from typing import Any
51
51
from typing import Dict
52
52
from typing import Optional
53
53
from typing import Tuple
54
- from typing import Callable
55
54
from typing import Union
56
55
57
56
from sentry_sdk .utils import ExcInfo
@@ -113,8 +112,9 @@ async def sentry_app_handle(self, request, *args, **kwargs):
113
112
scope .clear_breadcrumbs ()
114
113
scope .add_event_processor (_make_request_processor (weak_request ))
115
114
115
+ headers = dict (request .headers )
116
116
transaction = continue_trace (
117
- request . headers ,
117
+ headers ,
118
118
op = OP .HTTP_SERVER ,
119
119
# If this transaction name makes it to the UI, AIOHTTP's
120
120
# URL resolver did not find a route or died trying.
@@ -141,12 +141,12 @@ async def sentry_app_handle(self, request, *args, **kwargs):
141
141
transaction .set_http_status (response .status )
142
142
return response
143
143
144
- Application ._handle = sentry_app_handle
144
+ Application ._handle = sentry_app_handle # type: ignore[method-assign]
145
145
146
146
old_urldispatcher_resolve = UrlDispatcher .resolve
147
147
148
148
async def sentry_urldispatcher_resolve (self , request ):
149
- # type: (UrlDispatcher, Request) -> AbstractMatchInfo
149
+ # type: (UrlDispatcher, Request) -> UrlMappingMatchInfo
150
150
rv = await old_urldispatcher_resolve (self , request )
151
151
152
152
hub = Hub .current
@@ -173,12 +173,12 @@ async def sentry_urldispatcher_resolve(self, request):
173
173
174
174
return rv
175
175
176
- UrlDispatcher .resolve = sentry_urldispatcher_resolve
176
+ UrlDispatcher .resolve = sentry_urldispatcher_resolve # type: ignore[method-assign]
177
177
178
178
old_client_session_init = ClientSession .__init__
179
179
180
180
def init (* args , ** kwargs ):
181
- # type: (Any, Any) -> ClientSession
181
+ # type: (Any, Any) -> None
182
182
hub = Hub .current
183
183
if hub .get_integration (AioHttpIntegration ) is None :
184
184
return old_client_session_init (* args , ** kwargs )
@@ -190,7 +190,7 @@ def init(*args, **kwargs):
190
190
kwargs ["trace_configs" ] = client_trace_configs
191
191
return old_client_session_init (* args , ** kwargs )
192
192
193
- ClientSession .__init__ = init
193
+ ClientSession .__init__ = init # type: ignore[method-assign]
194
194
195
195
196
196
def create_trace_config ():
@@ -253,7 +253,7 @@ async def on_request_end(session, trace_config_ctx, params):
253
253
254
254
255
255
def _make_request_processor (weak_request ):
256
- # type: (Callable[[], Request]) -> EventProcessor
256
+ # type: (weakref.ReferenceType[ Request]) -> EventProcessor
257
257
def aiohttp_processor (
258
258
event , # type: Dict[str, Any]
259
259
hint , # type: Dict[str, Tuple[type, BaseException, Any]]
0 commit comments