Trellis.ServiceLevelIndicators.Asp.ApiVersioning 10.0.0

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

Trellis.ServiceLevelIndicators.Asp.ApiVersioning

NuGet Package

Adds API version as a metric dimension to Trellis.ServiceLevelIndicators.Asp SLI metrics. Works with the Asp.Versioning package.

When To Use This Package

Choose Trellis.ServiceLevelIndicators.Asp.ApiVersioning only when your ASP.NET Core application already uses Asp.Versioning and you want the resolved API version included in emitted SLI metrics.

This package extends Trellis.ServiceLevelIndicators.Asp; it is not a replacement for it.

Installation

dotnet add package Trellis.ServiceLevelIndicators.Asp.ApiVersioning

Requires Trellis.ServiceLevelIndicators.Asp (installed automatically as a dependency).

Usage

Chain AddApiVersion() onto the SLI builder:

builder.Services.AddServiceLevelIndicator(options =>
{
    options.LocationId = ServiceLevelIndicator.CreateLocationId("public", "westus3");
})
.AddMvc()
.AddApiVersion();

This registers ApiVersionEnrichment, which reads the resolved API version from the request and emits it as an attribute on every SLI measurement.

Already-resolved versions are retained on aborted MVC and Minimal API requests. The built-in enrichment opts into IEnrichment<WebEnrichmentContext>.EnrichOnCancellation because it performs bounded metadata access without I/O; arbitrary user async enrichments are still skipped after cancellation.

When ServiceLevelIndicatorOptions.LatencyThresholds enables operation.duration.threshold.count, the counter also retains http.api.version. Configure distinct positive whole-millisecond thresholds at startup, for example options.LatencyThresholds.Add(TimeSpan.FromSeconds(2)), and register the same SLI meter with OpenTelemetry.

Requirements

Emitted Attribute

Attribute Description
http.api.version The single resolved API version string (e.g. 1.0, 2024-01-15), Neutral for API-version-neutral endpoints, Unspecified when no version is requested and no default is assumed, or an empty string for invalid or ambiguous requests

This attribute is added alongside the standard dimensions emitted by Trellis.ServiceLevelIndicators.Asp. On aborts, the duration includes sli.request.aborted = true and omits http.response.status.code if headers have not started. The threshold counter omits HTTP status, method, and the abort-exception diagnostic.

Date-based versions remain date-only strings in library telemetry. Kusto may interpret a date-like value in dynamic Properties as a datetime; normalize it at the query boundary rather than changing the library's version format.

Optional AgentDocs setup

This package includes a versioned API reference, but restoring it does not install agent instructions. To opt in, restore your consuming project or solution, then run from its Git root:

dotnet new tool-manifest --output .config
dotnet tool install Trellis.AgentDocs --version 1.0.2 --tool-manifest .config/dotnet-tools.json
dotnet tool run agentdocs init <solution-or-project>

If the repository already has .config/dotnet-tools.json, reuse it instead of creating another manifest. Restoring a package never activates its guide: init lists Trellis.ServiceLevelIndicators.Asp.ApiVersioning as pending and prints the package IDs to add to approvedPackages in .agentdocs/policy.json. Add the ones you trust, then run dotnet tool run agentdocs sync to install the guides under Git-root .agentdocs/. The guide is on-demand: the generated index describes it, and an agent opens it when its task concerns SLI metrics. After a package upgrade, run dotnet restore --force and then dotnet tool run agentdocs sync.

Further Reading

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
10.0.0 191 10/19/2026
10.0.0-preview.43 90 10/17/2026
10.0.0-preview.37 72 10/16/2026
10.0.0-preview.34 166 10/4/2026
10.0.0-preview.32 233 10/1/2026
10.0.0-preview.31 72 9/30/2026
10.0.0-preview.30 66 9/29/2026
10.0.0-preview.29 72 9/28/2026
10.0.0-preview.28 70 9/28/2026
10.0.0-preview.27 75 9/28/2026
10.0.0-preview.26 501 7/6/2026
10.0.0-preview.25 228 6/24/2026
10.0.0-preview.24 195 6/19/2026
10.0.0-preview.21 138 5/19/2026
10.0.0-preview.10 95 4/24/2026
10.0.0-preview.9 80 4/23/2026