How to get SQL statements using open telemetry and auto-instrumentation on IIS

28 views Asked by At

I would like to get the SQL statements executed when using the OpenTelemetry.Instrumentation.SqlClient library, it is documented that this is possible:

https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/src/OpenTelemetry.Instrumentation.SqlClient/README.md#net-framework

But I'm using the IIS auto instrumentation to enable tracing: https://opentelemetry.io/docs/languages/net/automatic/#instrument-an-aspnet-application-deployed-on-iis

So I'm not sure how to enable the option I'd like to use. Does anyone know how or any docs that might explain how I can achieve what I'm trying to do.

1

There are 1 answers

2
Kielek On

You need to use OpenTelemetry .NET Automatic Instrumentation v1.4.0+. It is possible to enable this functionality by OTEL_DOTNET_AUTO_SQLCLIENT_SET_DBSTATEMENT_FOR_TEXT environmental variable.

Ref. documentation.