# Opentelemetry Net Instrumentation

Provides guidance for implementing OpenTelemetry instrumentation in .NET codebases...

- Repository: https://github.com/Aaronontheweb/dotnet-skills (1244 stars)
- Category: Design
- License: MIT
- Last updated: 2026-10-28
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add Aaronontheweb/dotnet-skills --skill opentelemetry-net-instrumentation -g -a claude-code -y`
Codex: `npx skills add Aaronontheweb/dotnet-skills --skill opentelemetry-net-instrumentation -g -a codex -y`
Cursor: `npx skills add Aaronontheweb/dotnet-skills --skill opentelemetry-net-instrumentation -g -a cursor -y`
Gemini CLI: `npx skills add Aaronontheweb/dotnet-skills --skill opentelemetry-net-instrumentation -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add Aaronontheweb/dotnet-skills`

## Description

Provides guidance for implementing OpenTelemetry instrumentation in .NET codebases, covering tracing (Activities/Spans), metrics, logs, naming conventions, error handling, performance, SDK setup, resources, context propagation, and API design best practices.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# OpenTelemetry .NET Instrumentation Skill

## When to Use

- Adding OpenTelemetry instrumentation to .NET code (traces, metrics, logs)
- Creating or modifying ActivitySources, Meters, or ILogger usage
- Setting up the OpenTelemetry SDK, resources, exporters, or sampling
- Reviewing telemetry implementations for spec compliance
- Optimizing instrumentation performance
- Designing telemetry APIs that become part of the public surface
- Implementing context propagation across service boundaries

## Architecture: .NET Is Different

**CRITICAL**: The .NET OpenTelemetry implementation is fundamentally different from other platforms. .NET provides tracing, metrics, and logging APIs **in the framework itself**.
That means **OTel does not provide a separate instrumentation API**, it uses the built-in .NET APIs and acts as the collection/export layer.

### The Three Built-in .NET APIs (Primary, Zero Dependencies)

| Signal | .NET Framework API | Namespace |
|--------|-------------------|-----------|
| **Tracing** | `ActivitySource` / `Activity` | `System.Diagnostics` |
| **Metrics** | `Meter` / `Counter<T>` / `Histogram<T>` / etc. | `System.Diagnostics.Metrics` |
| **Logging** | `ILogger<T>` | `Microsoft.Extensions.Logging` |

These are **the primary and only APIs** library authors should use for instrumentation.
They ship with the .NET runtime, **no NuGet packages required**.

### The OTel Collection/Export Layer (Secondary, Application Root Only)

OTel NuGet packages are the **collection and export layer**, added only at the application
composition root (not in libraries):

The rest: https://github.com/Aaronontheweb/dotnet-skills/blob/HEAD/skills/opentelementry-dotnet-instrumentation/SKILL.md
