Atatus .NET APM traces SQL commands executed through System.Data.SqlClient and Microsoft.Data.SqlClient by subscribing to the diagnostics they emit, creating a span for each command inside an active transaction.

Package installation

SqlClientDiagnosticSubscriber ships in the core Atatus package, so no separate package installation is required.

Note:

If you are already using the Atatus.NetCoreAll package, SqlClient subscribers are wired automatically and no additional subscription code is required.

Subscribe to SqlClient diagnostics

In ASP.NET Core, pass the subscriber to UseAtatus:

using Atatus.Instrumentations.SqlClient;

// Enable tracing of outgoing database requests
app.UseAtatus(Configuration, new SqlClientDiagnosticSubscriber());

The Configuration input variable is the IConfiguration instance passed to your Startup type. Alternatively, register it with the Agent.Subscribe method:

using Atatus;
using Atatus.Instrumentations.SqlClient;

Agent.Subscribe(new SqlClientDiagnosticSubscriber());

Make sure the subscription code runs only once, otherwise the same database call would be captured multiple times.

What Atatus captures ?

  • A span for each SQL command executed through System.Data.SqlClient or Microsoft.Data.SqlClient, including the statement and the target database.