Closed logamanig closed 3 days ago
@logamanig FYI this should be more or less possible now in 1.4.0-rc.1 and forward (see #3994).
Set up your host something like this:
var appBuilder = WebApplication.CreateBuilder(args);
appBuilder.Services.Configure<SqlClientInstrumentationOptions>(
appBuilder.Configuration.GetSection("OpenTelemetry:Sql"));
appBuilder.Services.AddOpenTelemetry()
.WithTracing(builder => builder.AddSqlClientInstrumentation())
.StartWithHost();
What that does is bind SqlClientInstrumentationOptions
to the "OpenTelemetry:Sql" IConfiguration
path. You can then use the standard syntax for setting that via an environment variable. IIRC that would be: OPENTELEMETRY__SQL__SETDBSTATEMENTFORTEXT=true
. Notes: 1) The double underscore ("__") is not a typo! That is a requirement. 2) All caps make it work for both *nix & Windows.
/cc @alanwest
This issue was marked stale due to lack of activity and will be closed in 7 days. Commenting will instruct the bot to automatically remove the label. This bot runs once per day.
Closed as inactive. Feel free to reopen if this issue is still a concern.
I would like to enable options.SetDbStatementForText to true to capture sql statements in traces which is turned off by default in the sdk. SDK has the instructions to enable it (https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/src/OpenTelemetry.Instrumentation.SqlClient/README.md#capturing-database-statements). Is it possible to add configure it through env var which will be handy to configure it through auto-instrumentation just like java without making changes into application source code?
the plugin option might be an option to implement but it does require making changes into application source code.