Telemetry

Learn on how to start capturing and publishing RepoDB operation telemetry using RepoDb.Telemetry.Default.

RepoDB ships with opt-in, drop-in telemetry via RepoDb.Telemetry.Default. It wires up a default ITrace that captures every operation (Insert, Query, Update, Delete, etc.) and publishes it to an insights collector.

Installation

Install the library via NuGet using the Package Manager Console.

> Install-Package RepoDb.Telemetry.Default

Setting up Docker

Download the docker-compose.yml and .env files into any directory and run the command below:

cd c:/folder-location
docker compose up -d

Once the stack is up, the collector Collector API runs at http://localhost:5000 by default and the Grafana dashboard is at http://localhost:3000.

Local defaults (e.g. RepoDB2026) are for trying things out — override them via a .env file before deploying to production.

Enable Telemetry

Build a DefaultTelemetryOption and pass it to the globalized setup method once at application startup, instead of threading a growing list of individual arguments through the call.

var telemetryOption = new DefaultTelemetryOption("<YOUR_APPLICATION_NAME>")
{
    Host = "https://your-collector-host",
    ApiKey = "YOUR_API_KEY",
    Group = "<YOUR_APPLICATION_GROUP>"
};

GlobalConfiguration
    .Setup(new GlobalConfigurationOptions { UseRegisteredGlobalTraces = true })
    .UseDefaultTelemetry(telemetryOption);

That’s it, you are now done! Every operation across every connection in the application is now traced automatically.

UseRegisteredGlobalTraces = true is required — it runs every globally registered tracer (this one included) for every operation without an explicit trace argument.

Keeping the settings on one DefaultTelemetryOption object, rather than as loose parameters on UseDefaultTelemetry, means new settings land on that class without ever touching the call site — adding Frequency, an errorCallback, or a logger later is a property or an extra argument on the existing option, not a signature change everywhere it’s called.

GlobalConfiguration
    .Setup(new GlobalConfigurationOptions { UseRegisteredGlobalTraces = true })
    .UseDefaultTelemetry(telemetryOption,
        errorCallback: ex => logger.LogError(ex, "Telemetry publish failed"),
        logger: logger);

Trusting a Self-Signed Collector Certificate

If your collector API is deployed over HTTPS with a self-signed or otherwise untrusted certificate, set CertificateValidationCallback on the option to validate (or bypass) the certificate check.

var telemetryOption = new DefaultTelemetryOption("<YOUR_APPLICATION_NAME>")
{
    Host = "https://your-collector-host",
    ApiKey = "YOUR_API_KEY",
    Group = "<YOUR_APPLICATION_GROUP>",
    CertificateValidationCallback = (request, certificate, chain, errors) => true
};

GlobalConfiguration
    .Setup(new GlobalConfigurationOptions { UseRegisteredGlobalTraces = true })
    .UseDefaultTelemetry(telemetryOption);

Only bypass certificate validation like the example above for a trusted, self-signed collector (e.g. local development). For production, validate the presented certificate/chain yourself instead of unconditionally returning true.