Fail to create AgentComponents using ElasticApmModule.CreateAgentComponents

Kibana version :
Elasticsearch version :
APM Server version :
APM Agent language and version :
dotnet framework 4.8 - Elastic.Apm 1.12.0 Elastic.Apm.AspNetFullFramework 1.12.0

Hello, I'm performing a PoC in a .NET Framework 4.8 application that works with Selfhost, I managed to configure Elasticsearch, Kitana and the server-apm on a remote machine. Now I'm testing how to configure the apm agent in the application:

When passing through the breakpoint, the application does not initialize the service and does not throw any exceptions.

Hi @juliano.maciel,

tldr: I'm afraid full framework self hosting won't be supported out of the box for auto instrumentation.

So, what the marked line with ElasticApmModule.CreateAgentComponents() and Agent.Setup() do is that they will set everything up for the agent to work - so the agent will know where to send data (which is the url of the APM Server), how to log things and that kind of stuff. But that's it, nothing more. So with that you are good to go, but nothing is captured at that point. Only thing which may happen is that it also sets up metrics collection and it'll start capturing metrics.

But the agent won't capture traces at that point. Trace capturing happens when one of the 2 things happen:

  • there is auto instrumentation for the app you use. Typically this would be something like an incoming HTTP request. So once a request comes in, then the agent will capture a trace for it.
  • you captured a transaction/span manually with the public agent API. Docs here.

Now, ideally, for a web app we'd do this automatically. We have this for ASP.NET Core (and 5 and 6) and for apps hosted in IIS.. The Elastic.Apm.AspNetFullFramework contains an IIS module which you can register for IIS based apps (docs here). I think the issue in your case is that this is a self hosted app and that's why nothing happens.

In that case the only thing you can do (other than hosting in IIS) is that you manually capture the traces with the API (docs linked above), but that'll be some manual work.

Thank's Greg, here a sample for the solution.

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