-
Notifications
You must be signed in to change notification settings - Fork 16
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
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.
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 telemetryA 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:
- Configure Prometheus to scrape your app's
/metricsendpoint - Add the Prometheus data source in Grafana
- Import
grafana-dashboard.jsonfrom the samples repo root - Select your data source when prompted
See Metrics for the full Prometheus configuration and all available metric names.
| 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.
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.
For any issues please use the GitHub issues