Skip to content

Commit 584134a

Browse files
committed
Revert "Enable AspNetCoreDiagnosticObserver for Azure Functions isolated mode"
This reverts commit ac4184c.
1 parent 7e41a67 commit 584134a

1 file changed

Lines changed: 3 additions & 12 deletions

File tree

tracer/src/Datadog.Trace/ClrProfiler/Instrumentation.cs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -469,25 +469,16 @@ private static void StartDiagnosticManager()
469469
var functionsExtensionVersion = EnvironmentHelpers.GetEnvironmentVariable(Datadog.Trace.Configuration.ConfigurationKeys.AzureFunctions.FunctionsExtensionVersion);
470470
var functionsWorkerRuntime = EnvironmentHelpers.GetEnvironmentVariable(Datadog.Trace.Configuration.ConfigurationKeys.AzureFunctions.FunctionsWorkerRuntime);
471471

472-
// Check if this is an in-process Azure Function (not isolated)
473-
// In-process: worker runtime is empty or "dotnet" (the host process itself)
474-
// Isolated: worker runtime is "dotnet-isolated"
475-
var isInProcessFunction = !string.IsNullOrEmpty(functionsExtensionVersion)
476-
&& !string.IsNullOrEmpty(functionsWorkerRuntime)
477-
&& !functionsWorkerRuntime.Equals("dotnet-isolated", StringComparison.OrdinalIgnoreCase);
478-
479-
if (isInProcessFunction)
472+
if (!string.IsNullOrEmpty(functionsExtensionVersion) && !string.IsNullOrEmpty(functionsWorkerRuntime))
480473
{
481474
// Not adding the `AspNetCoreDiagnosticObserver` is particularly important for in-process Azure Functions.
482475
// The AspNetCoreDiagnosticObserver will be loaded in a separate Assembly Load Context, breaking the connection of AsyncLocal.
483476
// This is because user code is loaded within the functions host in a separate context.
484-
Log.Debug("Skipping AspNetCoreDiagnosticObserver in in-process Azure Functions.");
477+
// Even in isolated functions, we don't want the AspNetCore spans to be created.
478+
Log.Debug("Skipping AspNetCoreDiagnosticObserver in Azure Functions.");
485479
}
486480
else
487481
{
488-
// For isolated functions, enable AspNetCoreDiagnosticObserver to support ASP.NET Core integration
489-
// which uses HTTP proxying for HTTP triggers. In this scenario, the worker receives actual HTTP
490-
// requests that should be instrumented by the ASP.NET Core observer.
491482
observers.Add(new AspNetCoreDiagnosticObserver());
492483
observers.Add(new QuartzDiagnosticObserver());
493484
}

0 commit comments

Comments
 (0)