Instruments .NET services with OpenTelemetry traces, metrics, and logs, exporting to Jaeger, Tempo, Prometheus, or Azure Monitor with production defaults.
Ships in TheCodeMan .NET AI ToolKit. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Wire up OpenTelemetry in an ASP.NET Core or .NET worker app — traces, metrics, and logs — exported to the backend the user wants, with sensible production defaults.
Don't ask the user to paste Program.cs — point this at the project and inspect what's already there:
Program.cs / Startup.cs and any existing OTel wiring.git clone --depth 1 <url> /tmp/repo && cd /tmp/repoDiscover the current state yourself before generating, e.g.:
find <target> -name Program.cs -o -name Startup.cs | grep -vi "/obj/\|/bin/"
grep -rn "AddOpenTelemetry\|WithTracing\|WithMetrics\|AddOtlpExporter\|UseSerilog" --include=*.cs <target>
If OTel is already partly set up (e.g. metrics but no tracing), extend it rather than starting over, and call out the specific gap. Read the .csproj to see which instrumentation packages are already referenced.
The user wants observability in a .NET app: distributed tracing, metrics, structured logs, correlation across services, or export to a specific backend. Inspect the project first, then establish three things (ask only what you can't infer):
Program.cs wiring + required NuGet packages.Base:
dotnet add package OpenTelemetry.Extensions.Hosting
dotnet add package OpenTelemetry.Instrumentation.AspNetCore
dotnet add package OpenTelemetry.Instrumentation.Http
dotnet add package OpenTelemetry.Instrumentation.Runtime
dotnet add package OpenTelemetry.Exporter.OpenTelemetryProtocol
Add as needed: OpenTelemetry.Instrumentation.EntityFrameworkCore, OpenTelemetry.Exporter.Prometheus.AspNetCore, Azure.Monitor.OpenTelemetry.AspNetCore.
var builder = WebApplication.CreateBuilder(args);
const string serviceName = "my-service";
const string serviceVersion = "1.0.0";
var resource = ResourceBuilder.CreateDefault()
.AddService(serviceName, serviceVersion: serviceVersion)
.AddAttributes(new KeyValuePair<string, object>[]
{
new("deployment.environment", builder.Environment.EnvironmentName)
});
builder.Services.AddOpenTelemetry()
.ConfigureResource(r => r
.AddService(serviceName, serviceVersion: serviceVersion)
.AddAttributes(new[] {
new KeyValuePair<string, object>("deployment.environment", builder.Environment.EnvironmentName)
}))
.WithTracing(tracing => tracing
.AddAspNetCoreInstrumentation(o => o.RecordException = true)
.AddHttpClientInstrumentation()
.AddEntityFrameworkCoreInstrumentation(o => o.SetDbStatementForText = true)
.AddSource(serviceName) // your custom ActivitySource
.SetSampler(new ParentBasedSampler(new TraceIdRatioBasedSampler(1.0))) // tune ratio in prod
.AddOtlpExporter())
.WithMetrics(metrics => metrics
.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation()
.AddRuntimeInstrumentation()
.AddMeter(serviceName) // your custom Meter
.AddOtlpExporter());
// Logs through OpenTelemetry
builder.Logging.AddOpenTelemetry(logging =>
{
logging.SetResourceBuilder(resource);
logging.IncludeScopes = true;
logging.IncludeFormattedMessage = true;
logging.AddOtlpExporter();
});
var app = builder.Build();
OTLP endpoint is configured via env var (preferred — keeps it out of code):
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
OTEL_EXPORTER_OTLP_PROTOCOL=grpc
public class OrderService
{
private static readonly ActivitySource Activity = new("my-service");
public async Task PlaceOrderAsync(Order order, CancellationToken ct)
{
using var span = Activity.StartActivity("PlaceOrder");
span?.SetTag("order.id", order.Id);
span?.SetTag("order.total", order.Total);
try
{
await _repo.SaveAsync(order, ct);
}
catch (Exception ex)
{
span?.SetStatus(ActivityStatusCode.Error, ex.Message);
throw;
}
}
}
public class OrderMetrics
{
private readonly Counter<long> _ordersPlaced;
public OrderMetrics(IMeterFactory meterFactory)
{
var meter = meterFactory.Create("my-service");
_ordersPlaced = meter.CreateCounter<long>("orders.placed", unit: "{orders}");
}
public void OrderPlaced(string region) =>
_ordersPlaced.Add(1, new KeyValuePair<string, object?>("region", region));
}
OpenTelemetry.Exporter.Prometheus.AspNetCore, replace metrics exporter with .AddPrometheusExporter(), and app.MapPrometheusScrapingEndpoint();.builder.Services.AddOpenTelemetry().UseAzureMonitor(); (replaces exporters; set APPLICATIONINSIGHTS_CONNECTION_STRING).OTEL_EXPORTER_OTLP_ENDPOINT at the collector.A ready-to-run collector + Jaeger + Prometheus docker-compose is in references/otel-collector-compose.md.
ParentBasedSampler + a ratio (start 10–20%) or tail sampling at the collector.service.name, service.version, deployment.environment. Without them telemetry is unusable across services.RecordException = true on ASP.NET Core spans so errors attach to traces.SetDbStatementForText (may capture parameters).TraceContext manually.## What I'm setting up
<app type, backend, signals>
## Packages
<dotnet add package ...>
## Program.cs
<wiring>
## Custom instrumentation example
<span + metric relevant to their domain>
## Run it
<env vars / compose / how to see the data>
What SKILL.md sets; muted values are Claude Code's defaults
/dotnet-ai-toolkit:opentelemetry-setupfrom TheCodeMan .NET AI ToolKit
npx claudepluginhub stefanthecode/dotnet-ai-toolkit --plugin dotnet-ai-toolkit49 skills in this plugin
/adonet-data-access-auditorAudit and fix classic ADO.NET data-access code (SqlConnection / SqlCommand / SqlDataReader / DataSet) on .NET Framework. Use this skill whenever the user shares raw ADO.NET code, a DAL / repository built on SqlCommand, stored-proc calls, string-concatenated SQL, or mentions SQL injection, parameterized queries, connection leaks, "using / Dispose", reading the same column multiple times, transactions, or "why does my old data layer leak connections / is it safe". Always use this skill for classic ADO.NET review instead of answering from memory; it applies a fixed security + correctness + performance checklist and rewrites the code./async-await-auditorAudit C#/.NET code for async/await anti-patterns and concurrency bugs. Use this skill whenever the user shares async C# code or asks about deadlocks, async void, .Result/.Wait(), blocking calls, ConfigureAwait, sync-over-async, fire-and-forget tasks, CancellationToken usage, or "why does my async code hang/deadlock". Always use this skill for async correctness/performance reviews instead of answering from memory; it applies a fixed checklist and rewrites the code./authorization-policy-generatorDesign ASP.NET Core authorization — policy-based, role-based, and claims/requirement-based with custom authorization handlers and resource-based checks. Use this skill whenever the user wants authorization policies, role/claim checks, custom AuthorizationHandler, resource-based authorization, permission checks, or asks "how do I authorize this / policy vs role / restrict this endpoint to X". Always use this skill for authorization requests; it generates policies, handlers, and endpoint wiring./benchmarkdotnet-setupSet up BenchmarkDotNet for a .NET project and interpret the results — proper benchmark classes, memory diagnostics, baselines, and reading ns/op + allocations. Use this skill whenever the user wants to benchmark code, measure performance, compare two implementations, set up BenchmarkDotNet, or asks "which is faster / how do I benchmark this / interpret these benchmark results". Always use this skill for micro-benchmarking requests; it writes correct benchmarks and explains the numbers./caching-strategy-setupAdd the right caching to a .NET app — IMemoryCache, distributed cache, or HybridCache (.NET 9+) — with correct keys, expiration, stampede protection, and invalidation. Use this skill whenever the user wants caching, to cache a query/response, IMemoryCache, Redis/distributed cache, HybridCache, output caching, or asks "how do I cache this / add caching / avoid cache stampede". Always use this skill for caching requests; it picks the right layer and wires expiration + invalidation correctly./cicd-pipeline-generatorGenerate a CI/CD pipeline for a .NET app — GitHub Actions or Azure DevOps — with restore, build, test, coverage, vulnerability scan, container build, and deploy stages. Use this skill whenever the user wants a CI/CD pipeline, GitHub Actions workflow, Azure DevOps YAML, build/test automation, a release pipeline, or asks "how do I set up CI / pipeline for .NET / automate build and deploy". Always use this skill for CI/CD requests; it generates a complete, sensible pipeline.Other plugins' skills for the same job