ServiceLevelIndicators 10.0.0-preview.2
See the version list below for details.
dotnet add package ServiceLevelIndicators --version 10.0.0-preview.2
NuGet\Install-Package ServiceLevelIndicators -Version 10.0.0-preview.2
<PackageReference Include="ServiceLevelIndicators" Version="10.0.0-preview.2" />
<PackageVersion Include="ServiceLevelIndicators" Version="10.0.0-preview.2" />
<PackageReference Include="ServiceLevelIndicators" />
paket add ServiceLevelIndicators --version 10.0.0-preview.2
#r "nuget: ServiceLevelIndicators, 10.0.0-preview.2"
#:package ServiceLevelIndicators@10.0.0-preview.2
#addin nuget:?package=ServiceLevelIndicators&version=10.0.0-preview.2&prerelease
#tool nuget:?package=ServiceLevelIndicators&version=10.0.0-preview.2&prerelease
ServiceLevelIndicators
A .NET library for emitting Service Level Indicator (SLI) latency metrics via the standard System.Diagnostics.Metrics API. Use it to measure operation duration across any .NET application — console apps, background services, worker processes, and more.
For ASP.NET Core applications, see ServiceLevelIndicators.Asp.
Installation
dotnet add package ServiceLevelIndicators
Quick Start
1. Register with OpenTelemetry
builder.Services.AddOpenTelemetry()
.WithMetrics(metrics =>
{
metrics.AddServiceLevelIndicatorInstrumentation();
metrics.AddOtlpExporter();
});
2. Configure options
builder.Services.AddServiceLevelIndicator(options =>
{
options.LocationId = ServiceLevelIndicator.CreateLocationId("public", "westus3");
options.CustomerResourceId = "my-customer";
});
3. Measure operations
Wrap any block of code in a using StartMeasuring scope:
async Task DoWork(ServiceLevelIndicator sli)
{
using var op = sli.StartMeasuring("ProcessOrder");
// Do work...
op.SetActivityStatusCode(ActivityStatusCode.Ok);
}
You can also pass custom attributes:
var attribute = new KeyValuePair<string, object?>("Event", "OrderCreated");
using var op = sli.StartMeasuring("ProcessOrder", attribute);
Emitted Metrics
A meter named ServiceLevelIndicator with instrument operation.duration (milliseconds) is emitted with the following attributes:
| Attribute | Description |
|---|---|
Operation |
The name of the measured operation |
CustomerResourceId |
Identifies the customer, customer group, or calling service |
LocationId |
Where the service is running (e.g. ms-loc://az/public/westus3) |
activity.status.code |
Ok, Error, or Unset based on the operation outcome |
Key APIs
| Type / Method | Description |
|---|---|
ServiceLevelIndicator.StartMeasuring(operation, attributes) |
Start a measured operation scope |
MeasuredOperation.SetActivityStatusCode(code) |
Set the outcome status |
MeasuredOperation.AddAttribute(name, value) |
Add a custom metric attribute |
MeasuredOperation.CustomerResourceId |
Get/set the customer resource ID |
ServiceLevelIndicator.CreateLocationId(cloud, region?, zone?) |
Helper to build a location ID string |
ServiceLevelIndicator.CreateCustomerResourceId(guid) |
Helper to build a customer resource ID from a service tree GUID |
Further Reading
| 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.Extensions.DependencyInjection.Abstractions (>= 10.0.3)
- Microsoft.Extensions.Options (>= 10.0.3)
- OpenTelemetry (>= 1.15.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on ServiceLevelIndicators:
| Package | Downloads |
|---|---|
|
ServiceLevelIndicators.Asp
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.0.0-preview.6 | 42 | 3/14/2026 |
| 10.0.0-preview.2 | 68 | 3/5/2026 |
| 8.0.1 | 387 | 2/11/2025 |
| 8.0.0-alpha.25 | 121 | 11/22/2024 |
| 8.0.0-alpha.24 | 113 | 11/20/2024 |
| 8.0.0-alpha.17 | 173 | 5/21/2024 |
| 8.0.0-alpha.12 | 165 | 3/29/2024 |
| 8.0.0-alpha.7 | 128 | 1/24/2024 |
| 8.0.0-alpha.6 | 112 | 1/23/2024 |
| 1.1.2 | 390 | 12/14/2023 |
| 1.1.1 | 320 | 11/10/2023 |
| 1.0.1 | 333 | 10/3/2023 |
| 0.1.0-alpha.20 | 166 | 9/27/2023 |
| 0.1.0-alpha.19 | 137 | 9/27/2023 |
| 0.1.0-alpha.18 | 196 | 9/14/2023 |
| 0.1.0-alpha.10 | 190 | 8/23/2023 |