Personix.ServiceDefaults
1.0.0
See the version list below for details.
dotnet add package Personix.ServiceDefaults --version 1.0.0
NuGet\Install-Package Personix.ServiceDefaults -Version 1.0.0
<PackageReference Include="Personix.ServiceDefaults" Version="1.0.0" />
<PackageVersion Include="Personix.ServiceDefaults" Version="1.0.0" />
<PackageReference Include="Personix.ServiceDefaults" />
paket add Personix.ServiceDefaults --version 1.0.0
#r "nuget: Personix.ServiceDefaults, 1.0.0"
#:package Personix.ServiceDefaults@1.0.0
#addin nuget:?package=Personix.ServiceDefaults&version=1.0.0
#tool nuget:?package=Personix.ServiceDefaults&version=1.0.0
Personix.ServiceDefaults
One call that wires up the cross-cutting concerns every service needs: OpenTelemetry traces, metrics and logs over OTLP, Serilog, health check endpoints, service discovery, and HTTP resilience.
The design decision worth knowing up front: telemetry is best-effort. When the collector is not configured or not reachable, the service starts anyway and logs to the console. Observability must never be the reason a service is down.
Installation
<PackageReference Include="Personix.ServiceDefaults" Version="1.0.0" />
Usage
using Personix.ServiceDefaults;
var builder = WebApplication.CreateBuilder(args);
builder.AddServiceDefaults();
var app = builder.Build();
app.MapDefaultEndpoints();
app.Run();
With custom meters and activity sources:
builder.AddServiceDefaults(
customMetersNames: ["MyApp.Orders"],
customActivitySourceNames: ["MyApp.Application"],
serviceName: "orders-api");
Configuration
Two keys decide whether telemetry is exported at all. Both are read from configuration first, then from environment variables:
| Key | Purpose |
|---|---|
OTEL_EXPORTER_OTLP_ENDPOINT |
Collector endpoint. Missing → no export. |
OTEL_EXPORTER_OTLP_PROTOCOL |
http/protobuf or grpc. Missing → no export. |
OTEL_SERVICE_NAME |
Service name. Optional — see below. |
OTEL_RESOURCE_ATTRIBUTES |
Optional. service.instance.id is read from here when present, generated otherwise. |
Service name
Resolved most specific first:
- the
serviceNameargument, OTEL_SERVICE_NAMEfrom configuration or environment,- the host's
ApplicationName.
There is no package-level default — the name of a service belongs to that service.
Log levels
Serilog reads Serilog:MinimumLevel:Override from appsettings.json, which is how noisy sources
get quietened per service:
{
"Serilog": {
"MinimumLevel": {
"Override": {
"Polly": "Fatal",
"System.Net.Http": "Fatal"
}
}
}
}
What gets registered
- Serilog with a console sink, plus an OTLP sink when telemetry is configured.
- OpenTelemetry traces and metrics with ASP.NET Core, HttpClient, runtime, and Entity Framework instrumentation, exported over OTLP.
- Health checks —
MapDefaultEndpoints()exposes readiness and liveness. - Service discovery restricted to
httpandhttpsschemes. - HTTP resilience as the default handler for every
HttpClient.
Notes
- The Entity Framework instrumentation upstream has never shipped a stable release, so this package depends on a beta of it. That is the only prerelease dependency here.
UseHostingOptions()applies URLs from configuration, but yields toASPNETCORE_URLSwhen that is set — so running under an orchestrator keeps working unchanged.
Licence
MIT — see LICENSE.
| 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.Http.Resilience (>= 10.8.0)
- Microsoft.Extensions.ServiceDiscovery (>= 10.8.0)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.17.0)
- OpenTelemetry.Extensions.Hosting (>= 1.17.0)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.17.0)
- OpenTelemetry.Instrumentation.EntityFrameworkCore (>= 1.17.0-beta.1)
- OpenTelemetry.Instrumentation.Http (>= 1.17.0)
- OpenTelemetry.Instrumentation.Runtime (>= 1.17.0)
- Personix.Otel.Constants (>= 1.0.4)
- Serilog.AspNetCore (>= 10.0.0)
- Serilog.Settings.Configuration (>= 10.0.1)
- Serilog.Sinks.OpenTelemetry (>= 4.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.