IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
SqlClient
editSqlClient
editQuick start
editYou can enable auto instrumentation for System.Data.SqlClient
or Microsoft.Data.SqlClient
by referencing Elastic.Apm.SqlClient
package
and passing SqlClientDiagnosticSubscriber
to the UseElasticApm
method in case of ASP.NET Core as it shown in example:
app.UseElasticApm(Configuration, new SqlClientDiagnosticSubscriber()); /* Enable tracing of outgoing db requests */
or passing SqlClientDiagnosticSubscriber
to the Subscribe
method and make sure that the code is called only once, otherwise the same database call could be captured multiple times:
// you need add custom code to be sure that Subscribe called only once and in a thread-safe manner if (Agent.IsConfigured) Agent.Subscribe(new SqlClientDiagnosticSubscriber()); /* Enable tracing of outgoing db requests */
Auto instrumentation for System.Data.SqlClient
is available for both, .NET Core and .NET Framework applications, however, support of .NET Framework has one limitation:
command text cannot be captured. In case of auto instrumentation for Microsoft.Data.SqlClient
, only .NET Core is supported, at the moment.