TaskHub.Shared

Observability

Observability is a first-class concern in TaskHub.Shared. Every service is instrumented for logs, metrics, and traces out of the box, with a single shared backend (Loki + Prometheus + Tempo, all behind Grafana).

🎯 Design Goals

  1. No service ships without telemetry. The FullHostBuilder wires the full observability stack β€” opting in is the default, opting out is explicit.
  2. One set of conventions across services. Same span names, same metric labels, same log levels β€” so cross-service dashboards work without per-service tweaks.
  3. Three signals, one correlation key. A request’s TraceId lives in every related log line, every span, and every metric exemplar. Click in Grafana, see the full picture.

πŸ“¦ Modules

Logging

Metrics

Tracing

πŸ”— How They Fit Together

   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚                        Your Service                            β”‚
   β”‚                                                                β”‚
   β”‚   Serilog ───► Loki         (logs, enriched with TraceId)     β”‚
   β”‚   Activity ──► Tempo        (spans, the request shape)        β”‚
   β”‚   Prometheus ─► Prometheus  (counters/gauges/histograms)      β”‚
   β”‚                                                                β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚
                                β–Ό
                          Grafana (single pane)

The shared TraceId makes the three signals click together in Grafana β€” go from a slow histogram bucket to the actual log lines of the offending request in two clicks.

βœ… When to Reach for Each

Question Use
β€œWhat happened in this one request?” Logs (with TraceId filter)
β€œHow’s the system doing right now?” Metrics (rates, latencies, error rates)
β€œWhere is this request spending its time?” Traces (Tempo span waterfall)
β€œDid the rate of failures change?” Metrics + alerts
β€œWhy did this request fail?” Trace β†’ linked logs

πŸš€ Bootstrap in One Line

The FullHostBuilder registers the whole stack:

new FullHostBuilder(args).Start<MyDbContext>();
// Includes: AddAppSerilog() + AddAppMetrics() + AddAppOpenTelemetry()

For services using BasicHostBuilder, opt in module by module β€” see each module’s usage doc.