Stratara.ServiceDefaults
4.6.0
Prefix Reserved
dotnet add package Stratara.ServiceDefaults --version 4.6.0
NuGet\Install-Package Stratara.ServiceDefaults -Version 4.6.0
<PackageReference Include="Stratara.ServiceDefaults" Version="4.6.0" />
<PackageVersion Include="Stratara.ServiceDefaults" Version="4.6.0" />
<PackageReference Include="Stratara.ServiceDefaults" />
paket add Stratara.ServiceDefaults --version 4.6.0
#r "nuget: Stratara.ServiceDefaults, 4.6.0"
#:package Stratara.ServiceDefaults@4.6.0
#addin nuget:?package=Stratara.ServiceDefaults&version=4.6.0
#tool nuget:?package=Stratara.ServiceDefaults&version=4.6.0
Stratara.ServiceDefaults
Derived. The behaviour described here is specified under
openspec/specs/. Those specifications are the source; this page explains and illustrates them.
License: MIT.
Cross-host observability defaults for the Stratara stack. Reference from every host (API, worker) to get OpenTelemetry + Serilog wired up with sensible defaults.
What's in the box
| Extension | Purpose |
|---|---|
ConfigureOpenTelemetry |
Logging + metrics + tracing with HTTP, EF Core, RabbitMQ, runtime instrumentation; OTLP exporter wired up automatically when OTEL_EXPORTER_OTLP_ENDPOINT is set. Accepts optional MeterProviderBuilder / TracerProviderBuilder callbacks for host-specific extras. |
ConfigureSerilog |
Structured logging with destructuring attributes, async console sink, OTLP sink (gRPC or HTTP/Protobuf based on OTEL_EXPORTER_OTLP_PROTOCOL), dev-mode log cleanup at {Path.GetTempPath()}/stratara-logs/{service-name}.log — the OS temp directory, so not literally /tmp on Windows or macOS. |
ConfigureSerilogBootstrapLogger |
Sets up Log.Logger as a bootstrap logger before the host is built, so early-startup errors surface to the console. |
Quick start
builder.ConfigureOpenTelemetry();
builder.ConfigureSerilog();
It deletes your development log file on start-up
In the Development environment only, configuring Serilog deletes the current log file before
opening it: %TEMP%/stratara-logs/{OTEL_SERVICE_NAME}.log, where the service name falls back to
Unknown when OTEL_SERVICE_NAME is unset. The intent is a clean file per debugging session rather
than one that grows across dozens of restarts.
Two consequences worth knowing before they cost you an hour:
- A crash you wanted to read is gone the moment you restart to reproduce it. Copy the file before restarting, or point the sink elsewhere for that session.
- Two development services with no
OTEL_SERVICE_NAMEshareUnknown.logand delete each other's. Set the variable per service.
Outside Development nothing is deleted.
Sibling packages
Stratara.EventSourcing.WorkerDefaults— one-stopAddBackendServices/AddXxxWorkerServicescomposites that wire the framework's mediator + outbox + projections + sagas stack.Stratara.ServiceDefaults.AspNetCore— ASP.NET-specific extras:AddDefaultHealthChecks+MapDefaultEndpoints(/health,/alive) and ASP.NET request OTel instrumentation.
Dependencies
Stratara.Shared— diagnostics base (ApplicationDiagnostics.Activity.SourceName).- OpenTelemetry runtime + exporter packages.
- Serilog sinks (Console, File, Async, OpenTelemetry).
Destructurama.Attributedfor destructuring conventions.Microsoft.Extensions.Http.Resilience+Microsoft.Extensions.ServiceDiscovery.
Prerelease dependencies. This package transitively pulls in two prerelease OpenTelemetry instrumentation packages that have no stable release yet:
OpenTelemetry.Instrumentation.EntityFrameworkCore(beta) andRabbitMQ.Client.OpenTelemetry(RC). Both ride the stable OpenTelemetry 1.15.x core. NU5104 is suppressed in this csproj with that justification — consumers inherit the prerelease deps transitively. We will swap to GA as soon as the vendors ship stable.
| 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
- Destructurama.Attributed (>= 5.3.0)
- Microsoft.Extensions.Http.Resilience (>= 10.11.0)
- Microsoft.Extensions.ServiceDiscovery (>= 10.11.0)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.20.1)
- OpenTelemetry.Extensions.Hosting (>= 1.20.1)
- OpenTelemetry.Instrumentation.EntityFrameworkCore (>= 1.20.1-beta.1)
- OpenTelemetry.Instrumentation.Http (>= 1.20.1)
- OpenTelemetry.Instrumentation.Runtime (>= 1.20.1)
- RabbitMQ.Client.OpenTelemetry (>= 1.0.0-rc.2)
- Serilog.Extensions.Hosting (>= 10.0.0)
- Serilog.Formatting.Compact (>= 3.0.0)
- Serilog.Settings.Configuration (>= 10.0.1)
- Serilog.Sinks.Async (>= 2.1.0)
- Serilog.Sinks.Console (>= 6.1.1)
- Serilog.Sinks.File (>= 7.0.0)
- Serilog.Sinks.OpenTelemetry (>= 4.2.0)
- Stratara.Shared (>= 4.6.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Stratara.ServiceDefaults:
| Package | Downloads |
|---|---|
|
Stratara.ServiceDefaults.AspNetCore
ASP.NET Core extensions on top of Stratara.ServiceDefaults — default health checks, /health and /alive endpoints, and ASP.NET request OpenTelemetry instrumentation. Reference from every API host. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.6.0 | 0 | 10/28/2026 |
| 4.5.0 | 0 | 10/28/2026 |
| 4.4.10 | 142 | 10/26/2026 |
| 4.4.9 | 67 | 10/26/2026 |
| 4.4.8 | 215 | 10/24/2026 |
| 4.4.7 | 82 | 10/23/2026 |
| 4.4.6 | 176 | 10/22/2026 |
| 4.4.5 | 245 | 10/14/2026 |
| 4.4.4 | 260 | 10/10/2026 |
| 4.4.3 | 91 | 10/10/2026 |
| 4.4.2 | 361 | 10/2/2026 |
| 4.4.1 | 343 | 9/29/2026 |
| 4.4.0 | 113 | 9/27/2026 |
| 4.3.1 | 109 | 9/25/2026 |
| 4.3.0 | 276 | 9/23/2026 |
| 4.2.0 | 129 | 9/18/2026 |
| 4.1.1 | 89 | 9/16/2026 |
| 4.1.0 | 83 | 9/16/2026 |
| 4.0.4 | 812 | 9/14/2026 |
| 4.0.3 | 96 | 9/3/2026 |
An erasure shreds every key that names the subject, and nothing stopped the next encryption for that subject
from creating a new one: a key store asked for a scope it does not hold creates a first version. A job, a request
in flight or a second process that encrypted for an erased subject afterwards got a fresh key, and what it wrote
stayed readable for good. The key store now records an erased subject and refuses to create a key for it again.
### Added
- **`IKeyStore.MarkSubjectErasedAsync(KeySubject)`** records that a tenant or user has been erased. It has a
default implementation that throws `NotSupportedException`, so an existing key store still compiles.
- **`KeySubject`** names the tenant or user, and `KeySubject.Covers(KeyScope)` states which keys belong to its
erasure: for a tenant, a key of any level that names it; for a user, a user-level key that names it.
- **`KeyScopeErasedException`** (an `InvalidOperationException`) is what a key store throws for such a scope. It
carries the refused `Scope`.
### Changed
- **An encryption for an erased subject fails.** After a subject's erasure, `GetOrCreateCurrentKeyAsync` and
`RotateAsync` throw `KeyScopeErasedException` for every scope the subject covers, whether or not it ever held a
key, and create nothing. The blob encryptor, the encrypting settings store and the field-encrypting serializer
pass it through. Code that erased a subject and then wrote encrypted data for it again now sees the exception;
the mark is permanent and cannot be lifted. Revoking every version of a scope is not an erasure and marks nothing.
- **`ISubjectEraser` marks the subject before it sweeps any plane**, so an encryption racing the erasure
either creates its key first, and that key is shredded with the rest, or is refused. A key store that cannot mark
a subject leaves the erasure as before and logs `SubjectNotMarkable` (112009).
- **The file-backed key store writes format version 2**, which holds the marks, and refuses to open a file in a
newer format than it knows. `InMemoryKeyStore` refuses an erased subject as the file store does; `DummyKeyStore`
refuses to mark one, as it refuses every erasure operation.
**Upgrading:**
- **Upgrade every process that shares a key store file in one step.** A process on an earlier release reads a
version-2 file, ignores the marks, creates keys for an erased subject and drops the marks the next time it writes
the file. A version-1 file needs no migration. Rolling back is possible but loses the marks on the first write.
- **Map `KeyScopeErasedException` to your answer for data that is gone**, if a request can reach an encryption for
a subject after its erasure.
- **A key store of your own implements `MarkSubjectErasedAsync`**, refusing in `GetOrCreateCurrentKeyAsync` and
`RotateAsync` every scope a marked subject `Covers`. Without it the erasure warns and the gap stays open.