configuring-opentelemetry-dotnet

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

1|Updated Jun 1, 2026
One-click install
npx skills add https://github.com/D1ssolve/craft-agents --skill configuring-opentelemetry-dotnet-d1ssolve
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: configuring-opentelemetry-dotnet
Source: https://github.com/D1ssolve/craft-agents/tree/main/skills/configuring-opentelemetry-dotnet
Command: npx skills add https://github.com/D1ssolve/craft-agents --skill configuring-opentelemetry-dotnet-d1ssolve

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Setting up observability in ASP.NET Core involves choosing the right NuGet packages, wiring up the OpenTelemetry SDK correctly, and avoiding silent failures like unmatched ActivitySource names. This Skill provides a complete, validated workflow for instrumenting .NET applications with distributed tracing, metrics, and correlated logging. ## Core Features & Use Cases - Full SDK Setup: Installs the correct OpenTelemetry packages and configures tracing, metrics, and logging in Program.cs with a single OTLP exporter. - Custom Telemetry: Creates custom spans with ActivitySource and custom metrics (Counter, Histogram, UpDownCounter) via IMeterFactory for business operations. - Distributed Context Propagation: Handles manual trace context propagation across message queues and non-HTTP scenarios. - Use Case: You are adding observability to an order-processing microservice. Use this Skill to instrument HTTP requests automatically, create custom spans for payment and validation steps, export everything to Jaeger via OTLP, and correlate logs with traces. ## 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, and WithLogging, finishing with UseOtlpExporter().

How to create custom spans in .NET with ActivitySource?

Create a static ActivitySource with a name, register that exact name via AddSource() in the OpenTelemetry configuration, then call StartActivity() to begin spans. Add attributes with SetTag() and set status with SetStatus() for error tracking.

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, as unmatched sources are silently ignored.

Does OpenTelemetry .NET support log and trace correlation?

Yes, the WithLogging() call 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.

When should I not use the OpenTelemetry .NET SDK?

Avoid it when you only need application-level logging (use ILogger or Serilog), when using the Application Insights SDK directly with its different API, or when a commercial APM vendor requires its proprietary SDK.

Why are my OpenTelemetry traces not appearing in the exporter?

Check the OTLP endpoint port: gRPC uses 4317 while HTTP uses 4318. If your collector only accepts HTTP, set OtlpExportProtocol.HttpProtobuf, and verify the OTEL_EXPORTER_OTLP_ENDPOINT environment variable.