I would like to get the SQL statements executed when using the OpenTelemetry.Instrumentation.SqlClient library, it is documented that this is possible:
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.
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_TEXTenvironmental variable.Ref. documentation.