The agent ships as a set of NuGet packages via nuget.org.
The following packages are available:
-
Elastic.Apm.NetCoreAll: This is a meta package that references every other Elastic APM .NET agent package. If you plan to monitor a typical ASP.NET Core application that depends on the Microsoft.AspNetCore.All package and uses Entity Framework Core then you should reference this package. In order to avoid adding unnecessary dependencies in applications that aren’t depending on the Microsoft.AspNetCore.All package we also offer some other packages - those are all referenced by the
Elastic.Apm.NetCoreAll
package. -
Elastic.Apm: This is the core of the agent, which we didn’t name “Core”, because someone already took that name :) This package also contains the [public-api] and it is a .NET Standard 2.0 package. We also ship every tracing component that traces classes that are part of .NET Standard 2.0 in this package, which includes the monitoring part for HttpClient. Every other Elastic APM package references this package.
-
Elastic.Apm.AspNetCore: This package contains ASP.NET Core monitoring related code. The main difference between this package and the
Elastic.Apm.NetCoreAll
package is that this package does not reference theElastic.Apm.EntityFrameworkCore
package, so if you have an ASP.NET Core application that does not use EF Core and you want to avoid adding additional unused references, you should use this package. -
Elastic.Apm.EntityFrameworkCore: This package contains EF Core monitoring related code.
You simply add the agent to your .NET application by referencing one of these packages.
For ASP.NET Core, once you referenced the Elastic.Apm.NetCoreAll
package, you can enable auto instrumentation by calling UseAllElasticApm()
extension method:
public class Startup
{
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseAllElasticApm(Configuration);
//…rest of the method
}
//…rest of the class
}
With this you enable every agent component including ASP.NET Core tracing, monitoring of outgoing HTTP request, Entity Framework Core database tracing, etc.
In case you only reference the Elastic.Apm.AspNetCore
package, you won’t find the UseAllElasticApm
. Instead you need to use the UseElasticApm()
method from the Elastic.Apm.AspNetCore
namespace. This method turns on ASP.NET Core tracing, and gives you the opportunity to manually turn on other components. By default it will only trace ASP.NET Core requests - No HTTP request tracing, database call tracing or any other tracing component will be turned on.
In case you only want to use the [public-api], you don’t need to do any initialization, you can simply start using the API and the agent will send the data to the APM Server.