Open roji opened 8 months ago
Hi @roji we are trying to integrate Datadog pg_tracing in our services.
Since we are using EF, we can use interceptors to add the trace info as a comment ahead of each query. This works for us but I was wondering if we could have some support in npgsql so that we could do the same at a lower level. For example we are also using Masstransit with npgsql and there we don't have an interceptor option.
At the lowest level, theoretically, you can already do that by using Activity.Current
.
using var cmd = new NpgsqlCommand(...);
using var reader = cmd.ExecuteReader();
Activity.Current?.SetTag("SomeKey", "SomeValue");
// Handle reader
Yeah but I would like to do it from configuration as I don’t always have access to npgsql directly.
something like otel.addnpgsql(options=> { options.addW3cTracingContext = true; }
To help view and process tracing data, we could allow users to set an arbitrary string tag on NpgsqlCommand, which would get reported when tracing via OpenTelemetry.
Originally raised in https://github.com/dotnet/efcore/issues/33149#issuecomment-1962348729