configuring-opentelemetry-dotnet

Configure OpenTelemetry tracing, metrics, and logging in ASP.NET Core applications.

Updated Aug 9, 2026
One-click install
npx skills add https://github.com/adinj00/player-performance --skill configuring-opentelemetry-dotnet-adinj00
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: configuring-opentelemetry-dotnet
Source: https://github.com/adinj00/player-performance/tree/main/.agents/skills/configuring-opentelemetry-dotnet
Command: npx skills add https://github.com/adinj00/player-performance --skill configuring-opentelemetry-dotnet-adinj00

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Setting up observability in .NET applications involves choosing the right NuGet packages, wiring up the OpenTelemetry SDK correctly in Program.cs, and avoiding silent failures like mismatched ActivitySource names. This Skill provides a complete, correct workflow for instrumenting ASP.NET Core apps with distributed tracing, metrics, and correlated logging. ## Core Features & Use Cases - Full SDK Setup: Install the correct OpenTelemetry packages and configure tracing, metrics, and logging with a single OTLP exporter in Program.cs. - Custom Instrumentation: Create custom spans with ActivitySource and custom metrics (counters, histograms, up-down counters) via IMeterFactory for business operations. - Distributed Context Propagation: Manually propagate trace context across message queues and other non-HTTP boundaries. - Use Case: You are adding observability to an order-processing microservice. Use this Skill to instrument HTTP requests automatically, add custom spans for payment and validation steps, record order metrics, and export everything to Jaeger or the Aspire dashboard via OTLP. ## Quick Start Configure OpenTelemetry tracing, metrics, and logging with an OTLP exporter in my ASP.NET Core project and add a custom ActivitySource for my order processing code.

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 to an ASP.NET Core application?

Install OpenTelemetry.Extensions.Hosting, OpenTelemetry.Instrumentation.AspNetCore, OpenTelemetry.Instrumentation.Http, and the OTLP exporter package. Then call AddOpenTelemetry() in Program.cs with WithTracing, WithMetrics, WithLogging, and UseOtlpExporter().

How do I create custom spans in .NET OpenTelemetry?

Create a static ActivitySource with a name like "MyApp.Orders", register it via AddSource() in the tracing configuration, then call StartActivity() to create spans. Add attributes with SetTag() and set status with SetStatus().

Why does ActivitySource.StartActivity return null in .NET?

StartActivity returns null when the ActivitySource name does not match any name registered via AddSource() in the OpenTelemetry configuration. Names must match exactly; unmatched sources are silently ignored, which is the most common debugging issue.

Does OpenTelemetry .NET support log and trace correlation?

Yes. Calling WithLogging() integrates ILogger with OpenTelemetry so each log entry automatically includes TraceId and SpanId. The OTLP exporter applies to logs alongside traces and metrics with no extra packages needed.

What port does the OTLP exporter use by default?

The OTLP exporter defaults to gRPC on port 4317, read from the OTEL_EXPORTER_OTLP_ENDPOINT environment variable. If your collector only accepts HTTP, use port 4318 and set the protocol to OtlpExportProtocol.HttpProtobuf.

When should I not use the OpenTelemetry .NET SDK?

Avoid it when you only need application-level logging (use ILogger or Serilog instead), when using the Application Insights SDK directly since it has a different API, or when a commercial APM vendor's proprietary SDK is required.