Azure / azure-functions-dotnet-worker

Azure Functions out-of-process .NET language worker
MIT License
405 stars 167 forks source link

Dependency correlation missing for dotnet-isolated functions #609

Open roelofvdv opened 2 years ago

roelofvdv commented 2 years ago

This is my first contribution here, so apologies if this has already been asked and answered. I checked existing issues but could not find mine exactly.

I am running a couple of .net 5 (dotnet-isolated) functions with Application Insights added to them. I can see requests to my http triggered functions coming in to the livestream in the Azure Portal. So far so good.

Now, it is my understanding that it is a known issue that dependencies are not automatically tracked as of yet. I therefore modified my startup class by adding insights in code

public class Program
{
  public static void Main()
  {
    var host = new HostBuilder()
      .ConfigureServices((hostbuilderContext, services) => services.AddApplicationInsightsTelemetryWorkerService(options =>
      {

      }))
      .Build();

    host.Run();
  }
}

That seems to work too, I now see dependencies in the Azure Portal whenever I trigger my function. However, the requests and their corresponding dependencies are not correlated. I can see both apart from each other, but I do not get a neat timeline for a single operation.

My hunch is that this is due to the fact that I am running my functions out of process (isolated) and there is no way for Application Insights to correlate the two. I suspect the request telemetry comes from the host process (as I don't see it hitting a breakpoint I set in a custom TelemetryInitializer) and the dependency telemetry comes from my function process. Would I be right in assuming that? Or am I missing something else?

Is there anything I can do to make Application Insights telemetry correlation work for my case?

Also, notice I call AddApplicationInsightsTelemetryWorkerService with an empty configuration action. If I call the overload without parameters (AddApplicationInsightsTelemetryWorkerService()), dependencies still do not get tracked. This to me seems like a bug also.

v-anvari commented 2 years ago

Transferring issue to DotNet worker for more insights

fabiocav commented 2 years ago

@roelofvdv this is not currently supported, but we do have work planned to address the issue and enable the capability.

We'll keep this issue open to track and provide updates on the progress.

fabiocav commented 2 years ago

Linking to the primary issue tracking the enhancements: https://github.com/Azure/azure-functions-dotnet-worker/issues/619