observability-and-instrumentation

Instruments .NET applications with structured logging, metrics, and distributed tracing for production diagnosis.

7|Updated Jan 11, 2026
One-click install
npx skills add https://github.com/peterblazejewicz/claude-plugins --skill observability-and-instrumentation-peterblazejewicz
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: observability-and-instrumentation
Source: https://github.com/peterblazejewicz/claude-plugins/tree/main/plugins/dotnet-skills/skills/observability-and-instrumentation
Command: npx skills add https://github.com/peterblazejewicz/claude-plugins --skill observability-and-instrumentation-peterblazejewicz

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Production issues in .NET applications are hard to diagnose when logs, metrics, and traces were never added during development, leaving on-call engineers unable to answer basic questions about failures. ## Core Features & Use Cases - Structured Logging: Implements ILogger with the [LoggerMessage] source generator, stable EventIds, correlation via W3C trace IDs, and PII/secret scrubbing. - Metrics with RED/USE: Uses System.Diagnostics.Metrics and IMeterFactory for domain metrics, plus built-in ASP.NET Core, HttpClient, and EF Core meters, with strict tag cardinality discipline. - Distributed Tracing: Configures OpenTelemetry with ASP.NET Core, HttpClient, and EF Core auto-instrumentation, custom ActivitySource spans, and OTLP or Azure Monitor exporters. - Use Case: When a checkout endpoint intermittently fails in production, use this Skill to add structured logs with trace correlation, RED metrics per endpoint, and a custom span around payment settlement so the failing hop is visible in one trace. ## Quick Start Instrument my ASP.NET Core checkout service with structured logging, RED metrics, and OpenTelemetry tracing so I can diagnose production failures.

Frequently Asked Questions about observability-and-instrumentation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add structured logging in ASP.NET Core?

Use ILogger with message templates or the [LoggerMessage] source generator for allocation-free logging with stable EventIds. Attach a correlation ID via Activity.Current.TraceId or ILogger.BeginScope so every log line in a request shares the same trace identifier.

How do I add metrics to a .NET application?

Create a Meter through IMeterFactory and define Counter and Histogram instruments for domain events. ASP.NET Core, HttpClient, and EF Core already publish built-in metrics on .NET 8+, so subscribe to those before writing custom instruments.

Does OpenTelemetry work with ASP.NET Core and EF Core?

Yes, OpenTelemetry .NET provides AddAspNetCoreInstrumentation, AddHttpClientInstrumentation, and AddEntityFrameworkCoreInstrumentation for automatic trace and metric collection. Export via OTLP or Azure Monitor using the Azure.Monitor.OpenTelemetry.AspNetCore distro.

Why should metric tags avoid user IDs and order IDs?

Unbounded tag values like user IDs or raw URLs explode cardinality, which inflates storage costs and causes collectors to drop data. Keep metric tags to bounded sets like channel or status, and put high-cardinality identifiers in logs or traces instead.

How do I test that metrics are emitted in .NET?

Use MetricCollector<T> from Microsoft.Extensions.Diagnostics.Testing inside a WebApplicationFactory<Program> test to assert measurements without a backend. For live checks, run dotnet-counters monitor against the process with the relevant meter name.