ANcpSdk.AspNetCore.ServiceDefaults 1.6.11

dotnet add package ANcpSdk.AspNetCore.ServiceDefaults --version 1.6.11
                    
NuGet\Install-Package ANcpSdk.AspNetCore.ServiceDefaults -Version 1.6.11
                    
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="ANcpSdk.AspNetCore.ServiceDefaults" Version="1.6.11" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ANcpSdk.AspNetCore.ServiceDefaults" Version="1.6.11" />
                    
Directory.Packages.props
<PackageReference Include="ANcpSdk.AspNetCore.ServiceDefaults" />
                    
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 ANcpSdk.AspNetCore.ServiceDefaults --version 1.6.11
                    
#r "nuget: ANcpSdk.AspNetCore.ServiceDefaults, 1.6.11"
                    
#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 ANcpSdk.AspNetCore.ServiceDefaults@1.6.11
                    
#: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=ANcpSdk.AspNetCore.ServiceDefaults&version=1.6.11
                    
Install as a Cake Addin
#tool nuget:?package=ANcpSdk.AspNetCore.ServiceDefaults&version=1.6.11
                    
Install as a Cake Tool

ANcpSdk.AspNetCore.ServiceDefaults

Runtime library for ASP.NET Core service defaults and OpenTelemetry instrumentation.

Overview

Provides:

  • Service defaults configuration - OpenTelemetry, health checks, resilience
  • Instrumentation runtime - Activity wrappers for GenAI and database calls
  • [OTel] attribute - Marker for compile-time tag generation

Architecture

Instrumentation/
├── ActivitySources.cs       ← Centralized ActivitySource definitions
├── SemanticConventions.cs   ← OTel semantic convention constants
├── OTelAttribute.cs         ← [OTel] marker attribute
├── GenAi/
│   ├── GenAiInstrumentation.cs ← Execute/ExecuteAsync wrappers
│   └── TokenUsage.cs           ← Token count record
└── Db/
    └── DbInstrumentation.cs    ← DbCommand wrappers

Instrumentation

GenAI

Wraps AI SDK calls with OpenTelemetry spans:

// Called by generated interceptors
GenAiInstrumentation.ExecuteAsync(
    provider: "openai",
    operation: "chat",
    model: "gpt-4",
    execute: () => client.CompleteChatAsync(messages),
    extractUsage: r => new TokenUsage(r.Usage.InputTokenCount, r.Usage.OutputTokenCount));

Emits spans with:

  • gen_ai.system - Provider name
  • gen_ai.operation.name - Operation type
  • gen_ai.request.model - Model name
  • gen_ai.usage.input_tokens - Input token count
  • gen_ai.usage.output_tokens - Output token count

Database

Wraps DbCommand methods with OpenTelemetry spans:

// Called by generated interceptors
DbInstrumentation.ExecuteReaderAsync(command, cancellationToken);

Emits spans with:

  • db.system.name - Database system (postgresql, mysql, etc.)
  • db.operation.name - Operation type (ExecuteReader, ExecuteNonQuery, etc.)
  • db.query.text - SQL command text
  • db.namespace - Database name

[OTel] Attribute

Mark properties for automatic tag generation:

using ANcpSdk.AspNetCore.ServiceDefaults.Instrumentation;

public record ChatRequest(
    [OTel("gen_ai.request.model")] string Model,
    [OTel("gen_ai.request.max_tokens")] int? MaxTokens,
    [OTel("gen_ai.request.temperature", SkipIfNull = false)] double? Temperature);

The source generator creates extension methods:

// Generated
activity.SetTagsFromChatRequest(request);

ActivitySources

Source Description
ANcpSdk.GenAi GenAI SDK instrumentation
ANcpSdk.Db Database instrumentation

Infrastructure wiring in ANcpSdkServiceDefaults.cs:

.AddSource("ANcpSdk.*")  // Subscribes to all ANcpSdk sources

Semantic Conventions

Constants in SemanticConventions.cs follow OpenTelemetry standards:

SemanticConventions.GenAi.System       // "gen_ai.system"
SemanticConventions.GenAi.RequestModel // "gen_ai.request.model"
SemanticConventions.Db.SystemName      // "db.system.name"
SemanticConventions.Db.QueryText       // "db.query.text"

Adding New Instrumentation

  1. Add ActivitySource to ActivitySources.cs
  2. Add semantic conventions to SemanticConventions.cs
  3. Create instrumentation class in appropriate subfolder
  4. Subscribe to source in ANcpSdkOpenTelemetryConfiguration.cs
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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.6.11 0 1/17/2026
1.6.10 32 1/16/2026
1.6.9 35 1/15/2026
1.6.8 46 1/15/2026
1.6.7 40 1/15/2026
1.6.6 36 1/14/2026
1.6.5 62 1/14/2026
1.6.4 65 1/14/2026
1.6.3 83 1/13/2026
1.6.2 105 1/10/2026
1.6.1 79 1/10/2026
1.6.0 84 1/9/2026
1.5.1 85 1/8/2026
1.5.0 92 1/2/2026
1.4.2 85 1/1/2026
1.4.1 85 1/1/2026
1.4.0 80 1/1/2026
1.3.31 78 1/9/2026
1.3.30 77 1/9/2026
1.3.29 86 1/9/2026
1.3.28 82 1/9/2026
1.3.27 84 1/9/2026
1.3.26 86 1/9/2026
1.3.25 80 1/9/2026
1.3.24 80 1/9/2026
1.3.23 84 1/6/2026
1.3.22 86 1/6/2026
1.3.20 82 1/2/2026
1.3.19 86 1/2/2026
1.3.18 89 1/1/2026
1.3.17 84 1/1/2026
1.3.16 80 12/31/2025
1.3.15 85 12/31/2025
1.3.14 77 12/31/2025
1.3.13 86 12/31/2025
1.3.12 86 12/31/2025
1.3.10 79 12/31/2025
1.3.9 82 12/31/2025
1.3.8 87 12/30/2025
1.3.7 78 12/30/2025
1.3.6 81 12/30/2025
1.3.5 86 12/30/2025
1.3.4 85 12/30/2025
1.3.3 85 12/30/2025
1.3.2 89 12/30/2025
1.3.1 79 12/30/2025
1.3.0 84 12/30/2025
1.2.4 85 12/29/2025
1.2.3 84 12/29/2025
1.2.2 84 12/29/2025
1.2.1 173 12/25/2025
1.2.0 169 12/24/2025
1.1.8 277 12/16/2025
1.1.7 261 12/16/2025
1.0.0 300 12/15/2025