Skip to content

usausa/mini-data-profiler

Repository files navigation

mini-data-profiler

Package Info Description
MiniDataProfiler NuGet Badge Core
MiniDataProfiler.Listener.Logging NuGet Badge Microsoft.Extensions.Logging Listener
MiniDataProfiler.Listener.OpenTelemetry NuGet Badge OpenTelemetry Listener

What is this?

  • Simple profiler for ADO.NET

Usage

// Setup Logger
using var loggerFactory = LoggerFactory.Create(builder =>
{
    builder
        .AddFilter("MiniDataProfiler.Listener.Logging", LogLevel.Information)
        .AddConsole();
});
var logListener = new LoggingListener(loggerFactory.CreateLogger<LoggingListener>(), new LoggingListenerOption());

// Setup OpenTelemetry
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
    .ConfigureResource(config =>
    {
        config.AddService("Example", serviceInstanceId: Environment.MachineName);
    })
    .AddMiniDataProfilerInstrumentation()
    .AddOtlpExporter(config =>
    {
        config.Endpoint = new Uri("http://otlp-exporter:4317");
    })
    .Build();

// Listeners
var listener = new ChainListener(logListener, new OpenTelemetryListener(new OpenTelemetryListenerOption()));

// Use ProfileDbConnection
using var con = new ProfileDbConnection(listener, new SqliteConnection(connectionString));
...