Azure/azure-functions-dotnet-worker

ApplicationInsights dependency tracking not working

allanlw opened this issue · 4 comments

Since I upgraded to the new runtime, dependency tracking is not working. It would seem that it is necessary to manually enable this (not documented).

Is there a recommended way to configure Application Insights and/or an example?

@allanlw indeed, this would require some manual wire up at the moment.

Tagging @brettsam so we can discuss how we can automate this to remove that friction.

Tried using DependencyTrackingTelemetryModule to add application insights into a .NET 5.0 function app. However I got a number of these messages in application insights logs:

AI (Internal): [Microsoft-ApplicationInsights-Extensibility-DependencyCollector] HttpCoreDiagnosticSourceListener OnNext failed to call event handler. Error details 'System.InvalidCastException: [A]ActivityStartData cannot be cast to [B]ActivityStartData. Type A originates from 'System.Net.Http, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' in the context 'Default' at location 'C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App\5.0.4\System.Net.Http.dll'. Type B originates from 'Grpc.Net.Client, Version=2.0.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad' in the context 'Default' at location 'C:\home\site\wwwroot\Grpc.Net.Client.dll'.
   at Microsoft.ApplicationInsights.Common.PropertyFetcher.PropertyFetch.TypedFetchProperty`2.Fetch(Object obj)
   at Microsoft.ApplicationInsights.Common.PropertyFetcher.Fetch(Object obj)
   at Microsoft.ApplicationInsights.DependencyCollector.Implementation.HttpCoreDiagnosticSourceListener.OnNext(KeyValuePair`2 evnt)'

None of the http or table storage dependency events that I was hoping to see appeared in the logs.

The only dependency event type was:

http://127.0.0.1:51170/AzureFunctionsRpcMessages.FunctionRpc/EventStream

See Setup automatic dependency tracking in Console Apps for details.

Using the Microsoft.ApplicationInsights.WorkerService package works for getting dependencies logged, but the telemetry isn't associated with the function execution. Is there an easy way to bridge that gap?

This is now supported with the ApplicationInsights package: #944