@@ -118,7 +118,7 @@ public async Task InvokeAsync(HttpContext context, RequestDelegate next)
118118 context . Items . TryAdd ( BaggageHeaderItemKey , baggageHeader ) ;
119119 context . Items . TryAdd ( TransactionContextItemKey , transactionContext ) ;
120120
121- hub . ConfigureScope ( scope =>
121+ hub . ConfigureScope ( static ( scope , arg ) =>
122122 {
123123 // At the point lots of stuff from the request are not yet filled
124124 // Identity for example is added later on in the pipeline
@@ -131,16 +131,16 @@ public async Task InvokeAsync(HttpContext context, RequestDelegate next)
131131 // when the event fires. Use `activeScope`, not `scope` or `hub`.
132132 scope . OnEvaluating += ( _ , activeScope ) =>
133133 {
134- SyncOptionsScope ( activeScope ) ;
135- PopulateScope ( context , activeScope ) ;
134+ arg . middleware . SyncOptionsScope ( activeScope ) ;
135+ arg . middleware . PopulateScope ( arg . context , activeScope ) ;
136136 } ;
137- } ) ;
137+ } , ( middleware : this , context ) ) ;
138138
139139 // Pre-create the Sentry Event ID and save it on the scope it so it's available throughout the pipeline,
140140 // even if there's no event actually being sent to Sentry. This allows for things like a custom exception
141141 // handler page to access the event ID, enabling user feedback, etc.
142142 var eventId = SentryId . Create ( ) ;
143- hub . ConfigureScope ( scope => scope . LastEventId = eventId ) ;
143+ hub . ConfigureScope ( static ( scope , eventId ) => scope . LastEventId = eventId , eventId ) ;
144144
145145 try
146146 {
@@ -167,7 +167,7 @@ public async Task InvokeAsync(HttpContext context, RequestDelegate next)
167167 {
168168 // The middleware pipeline finishes up before the Otel Activity.OnEnd callback is invoked so we need
169169 // so save a copy of the scope that can be restored by our SentrySpanProcessor
170- hub . ConfigureScope ( scope => activity . SetFused ( scope ) ) ;
170+ hub . ConfigureScope ( static ( scope , activity ) => activity . SetFused ( scope ) , activity ) ;
171171 }
172172
173173 // When an exception was handled by other component (i.e: UseExceptionHandler feature).
@@ -179,12 +179,12 @@ public async Task InvokeAsync(HttpContext context, RequestDelegate next)
179179 "The web server likely returned a customized error page as a result of this exception." ;
180180
181181#if NET6_0_OR_GREATER
182- hub . ConfigureScope ( scope =>
182+ hub . ConfigureScope ( static ( scope , arg ) =>
183183 {
184184 scope . ExceptionProcessors . Add (
185- new ExceptionHandlerFeatureProcessor ( originalMethod , exceptionFeature )
185+ new ExceptionHandlerFeatureProcessor ( arg . originalMethod , arg . exceptionFeature )
186186 ) ;
187- } ) ;
187+ } , ( originalMethod , exceptionFeature ) ) ;
188188#endif
189189 CaptureException ( exceptionFeature . Error , eventId , "IExceptionHandlerFeature" , description ) ;
190190 }
0 commit comments