LevelUp.ServiceDefaults
0.5.0
dotnet add package LevelUp.ServiceDefaults --version 0.5.0
NuGet\Install-Package LevelUp.ServiceDefaults -Version 0.5.0
<PackageReference Include="LevelUp.ServiceDefaults" Version="0.5.0" />
<PackageVersion Include="LevelUp.ServiceDefaults" Version="0.5.0" />
<PackageReference Include="LevelUp.ServiceDefaults" />
paket add LevelUp.ServiceDefaults --version 0.5.0
#r "nuget: LevelUp.ServiceDefaults, 0.5.0"
#:package LevelUp.ServiceDefaults@0.5.0
#addin nuget:?package=LevelUp.ServiceDefaults&version=0.5.0
#tool nuget:?package=LevelUp.ServiceDefaults&version=0.5.0
LevelUp.ServiceDefaults
The lean, AOT-safe paved-road core for lvlup-sw services. One call wires
OpenTelemetry (logging, metrics, tracing with ASP.NET Core, HttpClient, and runtime
instrumentation), default health checks, service discovery, and the standard
HttpClient resilience handler, with validated options bound from the
LevelUp:ServiceDefaults configuration section.
Heavy dependencies (Sentry, Azure Monitor, Microsoft.Identity.Web) live in the
satellite packages — LevelUp.ServiceDefaults.Sentry, .Azure, and .Auth — so this
core stays trim/AOT-clean.
Usage
var builder = WebApplication.CreateBuilder(args);
builder.AddLevelUpServiceDefaults();
var app = builder.Build();
app.MapDefaultEndpoints(); // /health and /alive (absent in Production by default)
app.Run();
The OTLP exporter is registered only when an endpoint is configured (via
OtlpEndpoint or the OTEL_EXPORTER_OTLP_ENDPOINT environment variable). The
team and tier resource attributes resolve from options → configuration →
environment (LVLUP_TEAM/LVLUP_TIER); when neither is set they fall back to
"unknown" and a single warning is logged at startup naming which fell back.
Optional health hardening (opt-in, default off)
Three capabilities lifted from the Ares aegis host are available as opt-in options; they are off by default, so existing consumers are unaffected.
EnableReadinessEndpointmaps a/health/readyprobe reporting only the checks taggedReadinessTag(default"ready") — the host's hard dependencies. Register hard dependencies (migrations, FHIR, …) with that tag and soft dependencies (cache) without it, so a cache outage cannot fail readiness and evict the pod (incident #341).ExcludeProbePathsFromTracingdrops/health,/health/ready, and/alivefrom ASP.NET Core traces, removing in-cluster probe noise/cost.EnableHealthResponseCachingapplies a request-timeout (HealthCheckTimeout, default 5s) and an output-cache (HealthResponseCacheDuration, default 10s) policy to the health endpoints.
Correlation id (default on)
AddLevelUpServiceDefaults puts a correlation middleware at the head of the request
pipeline. You do not call anything to get it. It runs before authentication,
authorization, and endpoint routing.
For each request the middleware does this:
- It adopts the inbound
X-Correlation-IDheader when the value is well formed. - It mints a new lower-case UUID when the header is absent or malformed. A malformed value is discarded. It is never propagated and never written to the log.
- It writes the resolved value back to the request header and to
HttpContext.Items["LevelUp.CorrelationId"]. - It puts the value on
Activity.Currentas the tag and baggage keylevelup.correlation_id. W3C trace-context continues to flow. The tag lets a trace and an audit record join on one key. - It writes the value to the response header, and it opens a log scope with the
property
CorrelationId.
A value is well formed when it has 1 to 128 characters from the set [A-Za-z0-9._:-].
The rule is strict because the value comes from the caller and it lands in an audit
record and in Log Analytics.
Options bind from LevelUp:ServiceDefaults:Correlation. A bad value stops the start
and names the property.
| Option | Default | Purpose |
|---|---|---|
Enabled |
true |
Runs the middleware. |
HeaderName |
X-Correlation-ID |
The header to read, normalize, and echo. |
EchoOnResponse |
true |
Writes the value to the response. |
MaxLength |
128 |
The maximum length of an adopted inbound value. 128 is also the ceiling: the BFF and the health packages reject longer values, so you can only narrow it. |
Do not change HeaderName. The BFF and the health packages use the same literal. A
different name breaks the chain.
On a worker or another non-web host the registration is inert.
| 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
- LevelUp.Bifrost.Resilience (>= 0.5.2)
- Microsoft.Extensions.Http.Resilience (>= 10.9.0)
- Microsoft.Extensions.ServiceDiscovery (>= 10.9.0)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.17.0)
- OpenTelemetry.Extensions.Hosting (>= 1.17.0)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.17.0)
- OpenTelemetry.Instrumentation.Http (>= 1.17.0)
- OpenTelemetry.Instrumentation.Runtime (>= 1.17.0)
NuGet packages (6)
Showing the top 5 NuGet packages that depend on LevelUp.ServiceDefaults:
| Package | Downloads |
|---|---|
|
LevelUp.ServiceDefaults.Caching
Caching satellite for LevelUp.ServiceDefaults: FusionCache .AsHybridCache() with Redis L2 + backplane and optional at-rest encryption. L2/backplane self-disable without a cache connection string. |
|
|
LevelUp.ServiceDefaults.Azure
Azure satellite for LevelUp.ServiceDefaults: Azure Monitor OpenTelemetry distro and Key Vault configuration provider, each gated on config. No-op otherwise. |
|
|
LevelUp.ServiceDefaults.Marten
Marten satellite for LevelUp.ServiceDefaults: registers a Wolverine-integrated Marten document store with lightweight sessions and an Npgsql health check over an injected connection string. Client-side only; never references Aspire.Hosting. |
|
|
LevelUp.ServiceDefaults.Sentry
Sentry-over-OpenTelemetry satellite for LevelUp.ServiceDefaults. No-op without a configured DSN. |
|
|
LevelUp.ServiceDefaults.Auth
Entra ID JWT-bearer authentication satellite for LevelUp.ServiceDefaults, wiring Microsoft.Identity.Web from the AzureAd config section. Explicit opt-in. |
GitHub repositories
This package is not used by any popular GitHub repositories.