Personix.ServiceDefaults 1.0.0

There is a newer version of this package available.
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
                    
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="Personix.ServiceDefaults" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Personix.ServiceDefaults" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Personix.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 Personix.ServiceDefaults --version 1.0.0
                    
#r "nuget: Personix.ServiceDefaults, 1.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 Personix.ServiceDefaults@1.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=Personix.ServiceDefaults&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Personix.ServiceDefaults&version=1.0.0
                    
Install as a Cake Tool

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:

  1. the serviceName argument,
  2. OTEL_SERVICE_NAME from configuration or environment,
  3. 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 checksMapDefaultEndpoints() exposes readiness and liveness.
  • Service discovery restricted to http and https schemes.
  • 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 to ASPNETCORE_URLS when that is set — so running under an orchestrator keeps working unchanged.

Licence

MIT — see LICENSE.

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.1.0 75 8/27/2026
1.0.0 78 8/1/2026