elastic / apm-agent-dotnet

https://www.elastic.co/guide/en/apm/agent/dotnet/current/index.html
Apache License 2.0
585 stars 208 forks source link

[BUG] Http triggered Azure Function throws System.UriFormatException, no support for Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore integration? #2311

Open oysteinthoensisjord opened 8 months ago

oysteinthoensisjord commented 8 months ago

APM Agent version

Elastic.Apm.Azure.Functions version 1.26.0

Environment

Operating system and version: At least Windows, but I guess this isn't OS spesific.. .NET Framework/Core name and version Dotnet 8, Azure Functions

Describe the bug

Using the APM package for a HTTP Triggered Azure Function fails when the Azure Function uses the 'Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore' integration. This integration seems to be the default when creating a HTTP Triggerend function app in Visual Studio as well.

When triggering the function, the APM Middleware throws an System.UriFormatException . The exception is thrown in the method Elastic.Apm.Azure.Functions.ApmMiddleware.GetTriggerSpecificData.

To Reproduce

Steps to reproduce the behavior:

  1. Create HTTP Triggered function app and add the middelware ApmMiddelware
  2. Trigger the Function
  3. Watch it failing... AzureFunction APM fail

Expected behavior

The APM integration for Azure Functions should support the default behaviour implemented by Microsofts own templates.

SparkenV commented 5 months ago

Do we have any updates on this? I faced this issue too with 1.27.1 Elastic.Apm.Azure.Functions version

willosbourne commented 2 months ago

I'm also experiencing this issue on .NET 8 with 1.28.5 Elastic.Apm.Azure.Functions, so I'm guessing its not going to be fixed soon. I'm surprised more aren't running into this. @oysteinthoensisjord or @SparkenV, did you folks ever find solutions for this? Or do we have to omit APM tracking for HTTP triggers now?

oysteinthoensisjord commented 2 months ago

The only way I found to add APM to Http triggered functions was to "downgrade" the function to not use the "Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore"-package. This makes it possible to have APM-tracking. The downside is, of course, that we cannot make use of the functionality provided by the extension package.