Elastic APM Azure Functions DiagnosticsSubscribers not working after first execution

Hi!

I'm trying to add Elastic APM to Azure functions, but I'm having limited success.

Could you please tell me If this is not supported, or am I doing something wrong?

I have azure functions that are successfully reporting the call of the http-triggered function. But I'm having trouble with other diagnostic subscribers working only on cold start. Could you please clarify the proper useage or if it's maybe not even intended to work like that? As I see in the manual [Azure Functions | APM .NET Agent Reference [1.x] | Elastic] that only the APMMiddleware is mentioned.

I'm using Azure Functions (.NET 6) in isolated mode with Elastic APM NuGet version 1.26.0.

Here's a a trace of same request right after Azure Functions App restart and a later (and all the next ones look similar) :


As you see - only the first execution got CosmosDB logged. The second one (an all the next ones until I restart the app) are getting only Http Logged. Since this is a PUT request where data is changing, there is no caching involved so the CosmosDB is actually executing here.

This is how I initialize the Function app:

var host = new HostBuilder()
//some other code 
.UseAllElasticApm()
.ConfigureFunctionsWorkerDefaults(builder =>
{
    builder.UseMiddleware<ApmMiddleware>();
})
.ConfigureAppConfiguration(...)
.ConfigureServices(...)
.Build();

 await host.RunAsync();

P.S.
I have also tried doing suggestions from this thread:
APM on Azure Functions - Elastic Observability / APM - Discuss the Elastic Stack

And adding manual subscription to all the diagnosticSubscribers in the HttpMiddleware after the agent is configured, but I got same results locally.

Any help and suggestions appreciated. :slight_smile:
Thank you!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.