What problem does it solve?
Instrumenting ASP.NET Core applications to capture distributed traces, metrics, and correlated logs is repetitive and error-prone; this guide standardizes configuration so services reliably emit observability data for debugging, performance analysis, and operational monitoring.
Core Features & Use Cases
- Traces and Spans: Configure automatic ASP.NET Core and HttpClient instrumentation and create custom ActivitySource spans for business operations.
- Metrics: Register meters via DI and record counters, histograms, and up/down counters for application-level metrics.
- Logging Correlation and Export: Integrate ILogger with OpenTelemetry so logs include TraceId/SpanId, and export traces, metrics, and logs via OTLP to collectors like Jaeger or an OTLP-compatible backend.
- Use Case: Add this configuration to a web API to trace request flows, correlate exceptions to spans via ILogger, and export metrics for latency and throughput to your backend.
Quick Start
Add OpenTelemetry to your ASP.NET Core project, enable the OTLP exporter, register matching AddSource and AddMeter names, and start collecting traces, metrics, and correlated logs.