ANcpSdk.AspNetCore.ServiceDefaults
1.6.15
Additional Details
merged into my qyl. opentelemtry as generator
The owner has unlisted this package.
This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package ANcpSdk.AspNetCore.ServiceDefaults --version 1.6.15
NuGet\Install-Package ANcpSdk.AspNetCore.ServiceDefaults -Version 1.6.15
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.15" />
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.15" />
<PackageReference Include="ANcpSdk.AspNetCore.ServiceDefaults" />
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.15
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ANcpSdk.AspNetCore.ServiceDefaults, 1.6.15"
#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.15
#: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.15
#tool nuget:?package=ANcpSdk.AspNetCore.ServiceDefaults&version=1.6.15
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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 namegen_ai.operation.name- Operation typegen_ai.request.model- Model namegen_ai.usage.input_tokens- Input token countgen_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 textdb.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
- Add
ActivitySourcetoActivitySources.cs - Add semantic conventions to
SemanticConventions.cs - Create instrumentation class in appropriate subfolder
- Subscribe to source in
ANcpSdkOpenTelemetryConfiguration.cs
| 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Microsoft.AspNetCore.Diagnostics.Middleware (>= 10.2.0)
- Microsoft.AspNetCore.OpenApi (>= 10.0.2)
- Microsoft.Extensions.Compliance.Redaction (>= 10.2.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.2)
- Microsoft.Extensions.Http.Resilience (>= 10.2.0)
- Microsoft.Extensions.Logging (>= 10.0.2)
- Microsoft.Extensions.ServiceDiscovery (>= 10.2.0)
- Microsoft.Extensions.Telemetry (>= 10.2.0)
- Microsoft.Extensions.Telemetry.Abstractions (>= 10.2.0)
- Microsoft.OpenApi (>= 2.0.0)
- OpenTelemetry.Exporter.Console (>= 1.14.0)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.14.0)
- OpenTelemetry.Extensions.Hosting (>= 1.14.0)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.14.0)
- OpenTelemetry.Instrumentation.Http (>= 1.14.0)
- OpenTelemetry.Instrumentation.Runtime (>= 1.14.0)
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 |
|---|