Adjustment of SqlClientDiagnostics
WorldIsM opened this issue · comments
I would like to cut some info from SqlClientDiagnostics (sql queries) and also exclude some spans with specific queries.
To kick out this diagnostics from my project, I do:
services.Remove(services.Single(src => src.ImplementationType != null && src.ImplementationType.ToString().Contains("OpenTracing.Contrib.NetCore.CoreFx.SqlClientDiagnostics")));
I would like to add my custom DiagnosticListenerObserver. But DiagnosticListenerObserver internal.
internal abstract class DiagnosticListenerObserver : DiagnosticObserver, IObserver<KeyValuePair<string, object>>
How can I add my own SqlClientDiagnostics?
With the next release it will be possible to ignore SQL commands by doing the following:
services.AddOpenTracing(builder =>
{
builder.ConfigureSqlClientDiagnostics(options =>
{
// Ignore all SELECT statements
options.IgnorePatterns.Add(cmd => cmd.CommandText.StartsWith("SELECT "));
});
});
However, it will not be possible to modify the data that's sent to the tracer.
If you want to completely replace the built-in SqlClientDiagnostics, you can remove the existing service from the DI container and add your own after you've called .AddOpenTracing()
.