Skip to content

Commit a11314c

Browse files
[Azure Functions] Skip instrumenting orchestrator functions (#7640)
## Summary of changes `[PreserveContext]` on `Microsoft.Azure.Functions.Worker.Pipeline.FunctionExecutionMiddleware.Invoke` to force `ConfigureAwait(continueOnCapturedContext: true)` on returned tasks ## Reason for change Orchestrator functions have special constraints: https://learn.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-code-constraints?tabs=csharp#orchestrator-code-constraints We are currently breaking applications for users of Azure durable functions, as we are interferring with the determinism of the orchestrator functions by wrapping the returned tasks and continuing in a different context.
1 parent 4626c34 commit a11314c

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Azure/Functions/Isolated/FunctionExecutionMiddlewareInvokeIntegration.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ internal static CallTargetState OnMethodBegin<TTarget, TFunctionContext>(TTarget
4242
/// <param name="exception">Exception instance in case the original code threw an exception.</param>
4343
/// <param name="state">Calltarget state value</param>
4444
/// <returns>A response value, in an async scenario will be T of Task of T</returns>
45+
[PreserveContext]
4546
internal static TReturn OnAsyncMethodEnd<TTarget, TReturn>(TTarget instance, TReturn returnValue, Exception exception, in CallTargetState state)
4647
{
4748
state.Scope?.DisposeWithException(exception);

0 commit comments

Comments
 (0)