ASP .NET 6.0 Agent seems to fail instantiation occasionally. No errors in logs

APM Agent language and version: Elastic.Apm.NetCoreAll (1.16.0) and .NET 6.0

Original install method (e.g. download page, yum, deb, from source, etc.) and version: Nuget

Fresh install or upgraded from other version? Fresh

Description of the problem including expected versus actual behavior. Please include screenshots (if relevant):

When I run my solution locally sometimes it seems that the APM Agent does not start. Seems to happen 10-20% of the times.

After calling

        DiagnosticListener.AllListeners.Subscribe(new Subscriber());
        return builder.UseElasticApm(configuration, new HttpDiagnosticsSubscriber());

I have tried running loglevel at trace and the log files seem nearly identical except we get the following when APM works

When the Agent does not generate Transactions or Spans it seems like it still is collecting metric data.

Agent Initialization stack

Hi @Mellow,

that's correct, the agent will collect metric data independently of transactions/spans.

From the log screenshots, it's hard to tell why you get transaction data in some cases and in others not. Can you confirm that the application and the scenario you are testing are always the same?
If you have a simple reproducer project, I can take a look.

Hey, It seems that I had missed this sentence in the documentation.

The app.UseAllElasticApm(...) line must be the first line in the Configure method, otherwise the agent won’t be able to properly measure the timing of your requests, and complete requests may potentially be missed by the agent

After I moved the line to the top it seems to fix the issue.

1 Like

Thanks for reporting back @Mellow.
I'm glad you could resolve your issue!

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