How to enable Elastic APM for c# console application

How can we use elastic APM for the C# console application, for ast .net core we can do it using ```
app.UseAllElasticApm(Configuration) but for console app we cant access app instance .

Have you seen the profilter auto instrumentation? See Profiler Auto instrumentation | APM .NET Agent Reference [1.12] | Elastic

I am using .net Core Console application and tried this but I cant find any tracing after applying suggested changes like below ..

  1. Download the elastic_apm_profiler_<version>.zip file from the Releases page of the .NET APM Agent GitHub repository, where <version> is the version number to download. You can find the file under Assets.
  2. Unzip the zip file into a folder on the host that is hosting the application to instrument.
  3. Configure the following environment variables
    set CORECLR_ENABLE_PROFILING = "1"
    set CORECLR_PROFILER = "{FA65FE15-F085-4681-9B20-95E04F6C03CC}"
    set CORECLR_PROFILER_PATH = "\elastic_apm_profiler.dll"
    set ELASTIC_APM_PROFILER_HOME = ""
    set ELASTIC_APM_PROFILER_INTEGRATIONS = "\integrations.yml"

@spinscale can u help on this?

Hi @Sachin_Agarwal2

for a console app, the best way to go will be to use manual code instrumentation. So you won't be able to just add the agent with a single line and see transactions automatically. This is because it's hard to automatically know what a transaction is in a console app - in a web app it's very well defined: it's a web request, but a console app can do anything, so the agent won't start a transaction automatically.

Here is the documentation on how the public API of the agent works. With that you can start your transactions and capture spans manually.

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