Sparkdo.Instrumentation
2.0.0-preview.2
dotnet add package Sparkdo.Instrumentation --version 2.0.0-preview.2
NuGet\Install-Package Sparkdo.Instrumentation -Version 2.0.0-preview.2
<PackageReference Include="Sparkdo.Instrumentation" Version="2.0.0-preview.2" />
<PackageVersion Include="Sparkdo.Instrumentation" Version="2.0.0-preview.2" />
<PackageReference Include="Sparkdo.Instrumentation" />
paket add Sparkdo.Instrumentation --version 2.0.0-preview.2
#r "nuget: Sparkdo.Instrumentation, 2.0.0-preview.2"
#:package Sparkdo.Instrumentation@2.0.0-preview.2
#addin nuget:?package=Sparkdo.Instrumentation&version=2.0.0-preview.2&prerelease
#tool nuget:?package=Sparkdo.Instrumentation&version=2.0.0-preview.2&prerelease
Sparkdo.Instrumentation
Sparkdo.Instrumentation 是 instrumentation 的运行时产品包。它把 generated metadata 转换为 activity、metric 和 recorder 生命周期。
职责
- 实现
IRuntimeInstrumentationHook,处理Start、Complete、Cancel和Fail。 - 根据
SparkdoInstrumentationOptions控制 tracing、metrics、stream、异常记录和错误策略。 - 解析显式 include/exclude 或框架提供的 source names。
- 暴露
SparkdoInstrumentationRegistry,供 OpenTelemetry 等适配包消费。 - 携带
Sparkdo.Instrumentation.Compileranalyzer,并提供 generated application bootstrap。
非职责
- 不定义 descriptor 编译规则;该职责属于
Sparkdo.Instrumentation.Compiler。 - 不配置 OpenTelemetry exporter、sampler 或 resource。
- 不通过程序集扫描发现 source、operation 或 recorder。
关键入口
| API | 用途 |
|---|---|
SparkdoApplicationBuilder.UseSparkdoInstrumentation(...) |
配置 Sparkdo application builder。 |
SparkdoHostBuilderOptions.UseSparkdoInstrumentation(...) |
配置 Generic Host 集成。 |
IServiceCollection.AddSparkdoInstrumentation(...) |
直接注册 runtime、registry 与 hook。 |
SparkdoInstrumentationRuntime |
operation runtime。 |
IInstrumentationRecorder |
接收 Started/Completed/Cancelled/Failed 回调。 |
依赖
运行时面向 netstandard2.0,依赖 Sparkdo.Instrumentation.Abstractions、Sparkdo.Manifest、Sparkdo.Hosting、Sparkdo.Runtime、Microsoft.Extensions.DependencyInjection 和 System.Diagnostics.DiagnosticSource。对 Sparkdo.Package 的引用仅用于仓库内 package authoring,不传播为运行时引用。
集成
using Sparkdo;
using var application = SparkdoApplication.CreateBuilder(args)
.UseSparkdoInstrumentation(options =>
{
options.Tracing = true;
options.Metrics = true;
options.Sources.Include("Orders");
})
.Build();
纯 DI 场景可直接调用 services.AddSparkdoInstrumentation(...)。OpenTelemetry 接入由独立的 Sparkdo.Instrumentation.OpenTelemetry 包完成。
验证
dotnet test src/instrumentation/test/Sparkdo.Instrumentation.Tests/Sparkdo.Instrumentation.Tests.csproj --no-restore -p:UseSharedCompilation=false -nr:false
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.8)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.8)
- Microsoft.Extensions.DependencyInjection (>= 10.0.8)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.8)
- Microsoft.Extensions.FileProviders.Abstractions (>= 10.0.8)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.8)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.8)
- Microsoft.Extensions.Options (>= 10.0.8)
- Sparkdo.Hosting (>= 2.0.0-preview.2)
- Sparkdo.Instrumentation.Abstractions (>= 2.0.0-preview.2)
- Sparkdo.Manifest (>= 2.0.0-preview.2)
- Sparkdo.Runtime (>= 2.0.0-preview.2)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Sparkdo.Instrumentation:
| Package | Downloads |
|---|---|
|
Sparkdo.Instrumentation.OpenTelemetry
Sparkdo instrumentation 的 OpenTelemetry 宿主集成。 |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.0-preview.2 | 45 | 7/20/2026 |
| 2.0.0-preview.1 | 55 | 7/18/2026 |