Sparkdo.Instrumentation 2.0.0-preview.2

This is a prerelease version of Sparkdo.Instrumentation.
dotnet add package Sparkdo.Instrumentation --version 2.0.0-preview.2
                    
NuGet\Install-Package Sparkdo.Instrumentation -Version 2.0.0-preview.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Sparkdo.Instrumentation" Version="2.0.0-preview.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Sparkdo.Instrumentation" Version="2.0.0-preview.2" />
                    
Directory.Packages.props
<PackageReference Include="Sparkdo.Instrumentation" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Sparkdo.Instrumentation --version 2.0.0-preview.2
                    
#r "nuget: Sparkdo.Instrumentation, 2.0.0-preview.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Sparkdo.Instrumentation@2.0.0-preview.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Sparkdo.Instrumentation&version=2.0.0-preview.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Sparkdo.Instrumentation&version=2.0.0-preview.2&prerelease
                    
Install as a Cake Tool

Sparkdo.Instrumentation

Sparkdo.Instrumentation 是 instrumentation 的运行时产品包。它把 generated metadata 转换为 activity、metric 和 recorder 生命周期。

职责

  • 实现 IRuntimeInstrumentationHook,处理 StartCompleteCancelFail
  • 根据 SparkdoInstrumentationOptions 控制 tracing、metrics、stream、异常记录和错误策略。
  • 解析显式 include/exclude 或框架提供的 source names。
  • 暴露 SparkdoInstrumentationRegistry,供 OpenTelemetry 等适配包消费。
  • 携带 Sparkdo.Instrumentation.Compiler analyzer,并提供 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.AbstractionsSparkdo.ManifestSparkdo.HostingSparkdo.RuntimeMicrosoft.Extensions.DependencyInjectionSystem.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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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