@@ -84,6 +84,7 @@ class StarletteIntegration(Integration):
8484 origin = f"auto.http.{ identifier } "
8585
8686 transaction_style = ""
87+ starlette_version = None
8788
8889 def __init__ (
8990 self ,
@@ -124,9 +125,9 @@ def __init__(
124125 @staticmethod
125126 def setup_once ():
126127 # type: () -> None
127- version = parse_version (STARLETTE_VERSION )
128+ StarletteIntegration . starlette_version = parse_version (STARLETTE_VERSION )
128129
129- if version is None :
130+ if StarletteIntegration . starlette_version is None :
130131 raise DidNotEnable (
131132 "Unparsable Starlette version: {}" .format (STARLETTE_VERSION )
132133 )
@@ -135,7 +136,7 @@ def setup_once():
135136 patch_asgi_app ()
136137 patch_request_response ()
137138
138- if version >= (0 , 24 ):
139+ if StarletteIntegration . starlette_version >= (0 , 24 ):
139140 patch_templates ()
140141
141142
@@ -365,10 +366,16 @@ def patch_middlewares():
365366 def _sentry_middleware_init (self , cls , * args , ** kwargs ):
366367 # type: (Any, Any, Any, Any) -> None
367368 if cls == SentryAsgiMiddleware :
368- return old_middleware_init (self , cls , * args , ** kwargs )
369+ if StarletteIntegration .starlette_version < (0 , 35 ):
370+ return old_middleware_init (self , cls , ** kwargs )
371+ else :
372+ return old_middleware_init (self , cls , * args , ** kwargs )
369373
370374 span_enabled_cls = _enable_span_for_middleware (cls )
371- old_middleware_init (self , span_enabled_cls , * args , ** kwargs )
375+ if StarletteIntegration .starlette_version < (0 , 35 ):
376+ old_middleware_init (self , span_enabled_cls , ** kwargs )
377+ else :
378+ old_middleware_init (self , span_enabled_cls , * args , ** kwargs )
372379
373380 if cls == AuthenticationMiddleware :
374381 patch_authentication_middleware (cls )
0 commit comments