This is a cache of https://www.elastic.co/guide/en/apm/agent/dotnet/current/setup-elasticsearch.html. It is a snapshot of the page at 2024-10-06T01:01:04.294+0000.
Elasticsearch | APM .NET Agent Reference [1.x] | Elastic

Elasticsearch

edit

Quick start

edit

Instrumentation can be enabled for Elasticsearch when using the official Elasticsearch clients, Elasticsearch.Net and Nest, by referencing Elastic.Apm.Elasticsearch package and passing ElasticsearchDiagnosticsSubscriber to the UseElasticApm method in case of ASP.NET Core as following

app.UseElasticApm(Configuration, new ElasticsearchDiagnosticsSubscriber()); 

Configuration is the IConfiguration instance passed to your Startup type

or passing ElasticsearchDiagnosticsSubscriber to the Subscribe method

Agent.Subscribe(new ElasticsearchDiagnosticsSubscriber());

Instrumentation listens for activities raised by Elasticsearch.Net and Nest 7.6.0+, creating spans for executed requests.

If you’re using Elasticsearch.Net and Nest 7.10.1 or 7.11.0, upgrade to at least 7.11.1 which fixes a bug in span capturing.