Skip to content

Monitoring

Brian Lehnen edited this page Apr 9, 2026 · 1 revision

Monitoring

DotNetWorkQueue emits metrics and traces via System.Diagnostics APIs. This page shows how to wire up observability for your queue application using OpenTelemetry.

For detailed reference, see:

  • Metrics -- all available metrics and instrument types
  • Trace -- all activity/span names and trace context propagation
Quick Setup

Add the OpenTelemetry packages for your preferred exporters:

dotnet add package OpenTelemetry.Extensions.Hosting
dotnet add package OpenTelemetry.Exporter.Prometheus.AspNetCore
dotnet add package OpenTelemetry.Exporter.OpenTelemetryProtocol

Wire up both metrics and tracing in one block:

builder.Services.AddOpenTelemetry()
    .WithMetrics(metrics =>
    {
        metrics.AddMeter("DotNetWorkQueue");
        metrics.AddPrometheusExporter();
    })
    .WithTracing(tracing =>
    {
        tracing.AddSource("dotnetworkqueue.instrumentationlibrary");
        tracing.AddOtlpExporter();   // or AddJaegerExporter(), AddZipkinExporter(), etc.
    });

var app = builder.Build();
app.MapPrometheusScrapingEndpoint();   // exposes GET /metrics for Prometheus
app.Run();

Note: DotNetWorkQueue does not ship any exporter packages. You choose your own: Prometheus, OTLP, Jaeger, Zipkin, Console, etc.

Non-ASP.NET Core Hosts

For console apps, Windows services, or other non-web hosts:

using var tracerProvider = Sdk.CreateTracerProviderBuilder()
    .AddSource("dotnetworkqueue.instrumentationlibrary")
    .AddOtlpExporter()
    .Build();

using var meterProvider = Sdk.CreateMeterProviderBuilder()
    .AddMeter("DotNetWorkQueue")
    .AddPrometheusHttpListener(options =>
    {
        options.UriPrefixes = new[] { "http://localhost:9464/" };
    })
    .Build();

// run your consumer/producer
// dispose providers on shutdown to flush pending telemetry
Prometheus + Grafana

A pre-built Grafana dashboard is included in the samples repo. It covers message throughput, handler duration, error and retry rates, heartbeat counters, serialization time, and message sizes.

To set it up:

  1. Configure Prometheus to scrape your app's /metrics endpoint
  2. Add the Prometheus data source in Grafana
  3. Import grafana-dashboard.json from the samples repo root
  4. Select your data source when prompted

See Metrics for the full Prometheus configuration and all available metric names.

What You Get
Signal Source Name What it covers
Metrics DotNetWorkQueue Send/receive timers, commit/rollback counters, error rates, serialization sizes, heartbeat counters
Traces dotnetworkqueue.instrumentationlibrary 18 activity types: send, receive, handler, commit, rollback, heartbeat, serializer, interceptor, scheduler, error, poison message

Trace context propagates automatically from producer to consumer via message headers (W3C TraceContext format). No configuration required.

Dashboard Integration

The Dashboard provides a web UI and REST API for real-time queue monitoring (message counts, consumer tracking, job status, message history). It is complementary to metrics/tracing -- the dashboard shows current state while metrics/tracing show historical trends.

Clone this wiki locally