Stratara.ServiceDefaults
4.0.3
Prefix Reserved
dotnet add package Stratara.ServiceDefaults --version 4.0.3
NuGet\Install-Package Stratara.ServiceDefaults -Version 4.0.3
<PackageReference Include="Stratara.ServiceDefaults" Version="4.0.3" />
<PackageVersion Include="Stratara.ServiceDefaults" Version="4.0.3" />
<PackageReference Include="Stratara.ServiceDefaults" />
paket add Stratara.ServiceDefaults --version 4.0.3
#r "nuget: Stratara.ServiceDefaults, 4.0.3"
#:package Stratara.ServiceDefaults@4.0.3
#addin nuget:?package=Stratara.ServiceDefaults&version=4.0.3
#tool nuget:?package=Stratara.ServiceDefaults&version=4.0.3
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.9.0)
- Microsoft.Extensions.ServiceDiscovery (>= 10.9.0)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.18.0)
- OpenTelemetry.Extensions.Hosting (>= 1.18.0)
- OpenTelemetry.Instrumentation.EntityFrameworkCore (>= 1.18.0-beta.1)
- OpenTelemetry.Instrumentation.Http (>= 1.18.0)
- OpenTelemetry.Instrumentation.Runtime (>= 1.18.0)
- 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.0.3)
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.0.3 | 30 | 9/3/2026 |
| 4.0.2 | 57 | 9/3/2026 |
| 4.0.1 | 60 | 9/2/2026 |
| 4.0.0 | 124 | 8/31/2026 |
| 4.0.0-preview.1 | 48 | 8/31/2026 |
| 3.4.0 | 97 | 8/28/2026 |
| 3.3.0 | 70 | 8/25/2026 |
| 3.2.3 | 76 | 8/22/2026 |
| 3.2.2 | 78 | 8/14/2026 |
| 3.2.1 | 430 | 8/2/2026 |
| 3.2.0 | 73 | 7/18/2026 |
| 3.1.7 | 87 | 7/1/2026 |
| 3.1.6 | 507 | 6/22/2026 |
| 3.1.5 | 85 | 6/22/2026 |
| 3.1.4 | 95 | 6/15/2026 |
| 3.1.3 | 95 | 6/10/2026 |
| 3.1.2 | 99 | 6/5/2026 |
| 3.1.1 | 175 | 6/1/2026 |
| 3.1.0 | 86 | 5/30/2026 |
| 3.0.23 | 88 | 5/28/2026 |
Three fixes to the same complaint: a host composed exactly as the documentation describes did not
start. Each one was a registration the composites assumed somebody else had made — a tracer, a unit
of work, a Redis connection — and each is now made by the registration that needs it. Nothing that
already worked changes: every fix defers to a registration the host makes itself, in either order,
so the lines a working host added to get past these gaps can simply be deleted. Additive on every
published surface.
### Fixed
- **A host without Redis starts and dispatches.** Every composite that carries a dispatcher
registered the projection-replay state, and its only implementation took a Redis connection that
no composite registers, so a host composed as documented failed at its first dispatch unless it
also ran Redis and called `AddCaching()`. `AddProjectionReplayState()` now chooses at first
resolution: with a registered `IConnectionMultiplexer` the Redis-backed state as before, without
one an in-process state with the same lease semantics — and a warning, once at start-up
(`104_012`), that replay coordination is confined to that process, so a replay requested there
suppresses publication there only. A deployment whose replay must reach several hosts registers
the shared connection, in either order. Redis-backed hosts observe no change.
- **Registering a store context now registers its unit of work.**
`AddNpgsqlWriteDbContextFactory<T>()` registered the context factory, the context and the default
connection resolver but not the `IWriteUnitOfWork` that the event source, the outbox dispatcher and
the command worker take from the container — and nothing else in the published packages did, so a
host composed exactly as documented failed at its first command with a dependency-injection error.
The write registration now try-adds a scoped `IWriteUnitOfWork` over its context, and
`AddNpgsqlReadDbContextFactory<T>()` try-adds `IProjectionsUnitOfWork` and `IReadUnitOfWork`
likewise. A unit of work the host registers itself, before or after, is still the one used; a
hand-written registration can simply be deleted.
- **`AddMediator()` no longer requires the host to register an OpenTelemetry `Tracer`.** The
mediator traces every dispatch and obtained its tracer from the host, but nothing registered one,
so a host that called `AddMediator()` and nothing else failed at the first resolve of `IMediator`.
`AddMediator()` now registers a fallback that emits the dispatch spans from the framework's
`Stratara.Application` activity source — a host that subscribes to framework telemetry sees them,
a host that subscribes to nothing pays for nothing. A `Tracer` the host registers, before or after
`AddMediator()`, is still the one used, so no existing host changes behaviour; the registration
line can simply be deleted. The samples, the README and the package README no longer carry it.