@@ -474,25 +474,16 @@ private static void StartDiagnosticManager()
474474 var functionsExtensionVersion = EnvironmentHelpers . GetEnvironmentVariable ( PlatformKeys . AzureFunctions . FunctionsExtensionVersion ) ;
475475 var functionsWorkerRuntime = EnvironmentHelpers . GetEnvironmentVariable ( PlatformKeys . AzureFunctions . FunctionsWorkerRuntime ) ;
476476
477- // Check if this is an in-process Azure Function (not isolated)
478- // In-process: worker runtime is empty or "dotnet" (the host process itself)
479- // Isolated: worker runtime is "dotnet-isolated"
480- var isInProcessFunction = ! string . IsNullOrEmpty ( functionsExtensionVersion )
481- && ! string . IsNullOrEmpty ( functionsWorkerRuntime )
482- && ! functionsWorkerRuntime . Equals ( "dotnet-isolated" , StringComparison . OrdinalIgnoreCase ) ;
483-
484- if ( isInProcessFunction )
477+ if ( ! string . IsNullOrEmpty ( functionsExtensionVersion ) && ! string . IsNullOrEmpty ( functionsWorkerRuntime ) )
485478 {
486479 // Not adding the `AspNetCoreDiagnosticObserver` is particularly important for in-process Azure Functions.
487480 // The AspNetCoreDiagnosticObserver will be loaded in a separate Assembly Load Context, breaking the connection of AsyncLocal.
488481 // This is because user code is loaded within the functions host in a separate context.
489- Log . Debug ( "Skipping AspNetCoreDiagnosticObserver in in-process Azure Functions." ) ;
482+ // Even in isolated functions, we don't want the AspNetCore spans to be created.
483+ Log . Debug ( "Skipping AspNetCoreDiagnosticObserver in Azure Functions." ) ;
490484 }
491485 else
492486 {
493- // For isolated functions, enable AspNetCoreDiagnosticObserver to support ASP.NET Core integration
494- // which uses HTTP proxying for HTTP triggers. In this scenario, the worker receives actual HTTP
495- // requests that should be instrumented by the ASP.NET Core observer.
496487 observers . Add ( new AspNetCoreDiagnosticObserver ( ) ) ;
497488 observers . Add ( new QuartzDiagnosticObserver ( ) ) ;
498489 }
0 commit comments