Loading

Set up Azure Cosmos DB instrumentation

Package Supported versions
Microsoft.Azure.Cosmos ≥3.0.0 <4.0.0
Microsoft.Azure.DocumentDB.Core (legacy) ≥2.4.1 <3.0.0
Microsoft.Azure.DocumentDB (legacy) ≥2.4.1 <3.0.0

For the full compatibility matrix including supported installation methods, refer to Data access technologies.

Note

Microsoft.Azure.DocumentDB.Core and Microsoft.Azure.DocumentDB are deprecated. The recommended replacement is Microsoft.Azure.Cosmos.

This page assumes the core agent is already set up. If not, see Set up the APM .NET Agent first.

Add the Elastic.Apm.Azure.CosmosDb NuGet package to your project:

dotnet add package Elastic.Apm.Azure.CosmosDb
		

Subscribe to diagnostic events once at application startup:

using Elastic.Apm;
using Elastic.Apm.Azure.CosmosDb;

Agent.Subscribe(new AzureCosmosDbDiagnosticsSubscriber());
		

Diagnostic events from Microsoft.Azure.Cosmos, Microsoft.Azure.DocumentDb, and Microsoft.Azure.DocumentDb.Core are captured as DB spans.