configuring-opentelemetry-dotnet

Configure OpenTelemetry in ASP.NET Core for traces, metrics, and correlated logs.

Updated Aug 16, 2025
One-click install
npx skills add https://github.com/dodyg/blue-nile-pds --skill configuring-opentelemetry-dotnet
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: configuring-opentelemetry-dotnet
Source: https://github.com/dodyg/blue-nile-pds/tree/main/.agents/skills/dotnet-aspnet/skills/configuring-opentelemetry-dotnet
Command: npx skills add https://github.com/dodyg/blue-nile-pds --skill configuring-opentelemetry-dotnet

SYSTEM DOCUMENTATION & REQUIREMENTS

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.

Frequently Asked Questions about configuring-opentelemetry-dotnet

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

FAQPage Schema
How do I add OpenTelemetry tracing and metrics to an ASP.NET Core app?

To add OpenTelemetry tracing and metrics to an ASP.NET Core app, configure automatic instrumentation for HTTP requests and HttpClient calls, register custom ActivitySource spans via matching AddSource names, and export data using an OTLP exporter.

How do I correlate ILogger logs with OpenTelemetry traces in ASP.NET Core?

Correlating ILogger logs with OpenTelemetry traces requires integrating ILogger with the OpenTelemetry SDK, which automatically injects TraceId and SpanId into log outputs so exceptions can be traced back to specific spans.

Why are my custom OpenTelemetry spans or meters not exporting from my ASP.NET Core service?

Custom spans or meters fail to export when the string names used during ActivitySource or Meter creation do not exactly match the names registered in the OpenTelemetry configuration via AddSource and AddMeter.

Can I propagate OpenTelemetry context across HTTP and background message boundaries in .NET?

OpenTelemetry context propagation across HTTP and background message processing boundaries is supported by configuring standard instrumentation, allowing distributed traces to follow requests through web services and downstream message queues.

How do I record custom application metrics using OpenTelemetry in .NET?

Recording custom application metrics involves creating meters via dependency injection and using them to record counters, histograms, and up-down counters, which are then exported through the configured OTLP exporter.

What is needed to export ASP.NET Core telemetry to an OTLP-compatible backend like Jaeger?

Exporting telemetry to an OTLP-compatible backend like Jaeger requires adding the OpenTelemetry SDK to your ASP.NET Core project, enabling the OTLP exporter, and ensuring traces, metrics, and correlated logs are properly configured for collection.