用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/bradygaster/SqncR --skill dotnet-otel-instrumentation命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | dotnet-otel-instrumentation |
| description | Pattern for adding OpenTelemetry tracing to .NET projects with clean library/host separation |
| domain | observability |
| confidence | low |
| source | earned |
When instrumenting .NET applications with OpenTelemetry, the standard pattern separates instrumentation (library code) from collection/export (host code). This keeps libraries lightweight and lets the host decide where telemetry goes.
Library projects use System.Diagnostics.ActivitySource and Activity for instrumentation. No OpenTelemetry NuGet packages in libraries. ActivitySource is declared as internal static readonly on the class that owns the operations:
public class MyService
{
internal static readonly ActivitySource ActivitySource = new("MyApp.MySubsystem");
public void DoWork()
{
using var activity = ActivitySource.StartActivity("mysubsystem.do_work");
activity?.SetTag("work.param", value);
// actual work
}
}
Only the composition root (CLI, web host, AppHost) references OpenTelemetry packages and registers sources by name:
var tracerProvider = Sdk.CreateTracerProviderBuilder()
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("MyApp"))
.AddSource("MyApp.MySubsystem")
.AddOtlpExporter()
.Build();
Use {subsystem}.{attribute} naming for span tags: midi.channel, note.name, sequence.title.
ActivitySource.StartActivity() returns null when no listener is registered. Always use activity?.SetTag() — never assume the activity exists.
Dispose TracerProvider before exit to flush pending spans. In CLI apps, do this explicitly. In hosted apps, use OpenTelemetry.Extensions.Hosting.
OpenTelemetry.* packages. Use System.Diagnostics only.AddSource() in the host.TracerProvider isn't disposed, the last batch of spans may be lost..SetTag() without null-conditional. Activity is null when no collector is listening.