You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using AddAzureFunctionsProject with Aspire and the standard service defaults (AddServiceDefaults()). I wasn't seeing telemetry correlation between the Functions host process and the worker process in Application Insights -- traces appeared as separate, disconnected operations with no end-to-end distributed trace linking the host invocation to my function code.
After some digging, I found that adding UseFunctionsWorkerDefaults() from the Microsoft.Azure.Functions.Worker.OpenTelemetry package resolved this:
Correlates traces and logs between the host process and the worker process
Configures a resource detector for Azure Functions
Helps avoid duplicate telemetry between host and worker
Questions
Is this expected? Does AddServiceDefaults() intentionally not cover this, or is it an oversight that the Azure Functions template doesn't include it?
Should the Aspire Azure Functions project template include this call in the generated Program.cs? It seems like anyone using AddAzureFunctionsProject with Application Insights would hit this.
Should AddServiceDefaults() handle this automatically when it detects it's running in an Azure Functions worker? Or would that conflict with the host-level OpenTelemetry configuration?
What I observed without UseFunctionsWorkerDefaults()
Host traces and worker traces had different operation IDs in Application Insights
Distributed tracing across Service Bus triggers didn't connect the host invocation to the worker execution
Log correlation between host and worker was missing
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using
AddAzureFunctionsProjectwith Aspire and the standard service defaults (AddServiceDefaults()). I wasn't seeing telemetry correlation between the Functions host process and the worker process in Application Insights -- traces appeared as separate, disconnected operations with no end-to-end distributed trace linking the host invocation to my function code.After some digging, I found that adding
UseFunctionsWorkerDefaults()from theMicrosoft.Azure.Functions.Worker.OpenTelemetrypackage resolved this:The Azure Functions OpenTelemetry documentation shows this call as required for .NET isolated worker apps. It:
Questions
AddServiceDefaults()intentionally not cover this, or is it an oversight that the Azure Functions template doesn't include it?Program.cs? It seems like anyone usingAddAzureFunctionsProjectwith Application Insights would hit this.AddServiceDefaults()handle this automatically when it detects it's running in an Azure Functions worker? Or would that conflict with the host-level OpenTelemetry configuration?What I observed without
UseFunctionsWorkerDefaults()Beta Was this translation helpful? Give feedback.
All reactions