ResQ.BuildingBlocks.ServiceDefaults 0.2.0

dotnet add package ResQ.BuildingBlocks.ServiceDefaults --version 0.2.0
                    
NuGet\Install-Package ResQ.BuildingBlocks.ServiceDefaults -Version 0.2.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="ResQ.BuildingBlocks.ServiceDefaults" Version="0.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ResQ.BuildingBlocks.ServiceDefaults" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="ResQ.BuildingBlocks.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 ResQ.BuildingBlocks.ServiceDefaults --version 0.2.0
                    
#r "nuget: ResQ.BuildingBlocks.ServiceDefaults, 0.2.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 ResQ.BuildingBlocks.ServiceDefaults@0.2.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=ResQ.BuildingBlocks.ServiceDefaults&version=0.2.0
                    
Install as a Cake Addin
#tool nuget:?package=ResQ.BuildingBlocks.ServiceDefaults&version=0.2.0
                    
Install as a Cake Tool

ResQ.BuildingBlocks.ServiceDefaults

Aspire-style cross-cutting defaults — one call from a host's composition root wires observability, health, resilience, and a testable clock. Depends only on ResQ.BuildingBlocks.Application + ResQ.BuildingBlocks.Domain.

What AddServiceDefaults wires

  • OpenTelemetry (ConfigureOpenTelemetry): logs (IncludeScopes + IncludeFormattedMessage), metrics (ASP.NET Core + HTTP-client + runtime instrumentation + the ResqDiagnostics.MeterName meter), and traces (ASP.NET Core + HTTP-client sources + the ResqDiagnostics.ActivitySourceName source). The OTLP exporter turns on only when OTEL_EXPORTER_OTLP_ENDPOINT is set.
  • Health checks (AddDefaultHealthChecks): a self liveness check tagged live.
  • Service discovery + standard HTTP resilience: applied to every HttpClient via ConfigureHttpClientDefaults.
  • IClock → singleton SystemClock (backed by TimeProvider.System).

It does not register the observability pipeline behaviors — that is an explicit, ordered call (below).

var builder = WebApplication.CreateBuilder(args);
builder.AddServiceDefaults();               // OTel / health / resilience / IClock — NO behaviors

builder.Services
    .AddResqApplication(typeof(CreateWidget).Assembly)
    .AddValidatorsFrom(typeof(CreateWidget).Assembly)
    .AddLoggingPipeline()                    // outermost
    .AddValidationPipeline();
builder.Services.AddResqObservabilityBehaviors();   // Tracing then Metrics — AFTER validation

var app = builder.Build();
app.MapDefaultEndpoints();                   // /health + /alive (non-Production)
app.Run();

Resulting behavior order: Logging → Validation → Tracing → Metrics → Transaction → handler (first-registered = outermost).

Pieces

  • ServiceDefaultsExtensions — AddServiceDefaults, ConfigureOpenTelemetry, AddDefaultHealthChecks (IHostApplicationBuilder), and MapDefaultEndpoints (WebApplication).
  • ResqDiagnostics — the shared ActivitySource + the ActivitySourceName/MeterName constants. No hand-newed static Meter; metrics come from IMeterFactory so the emitting and allow-listed names always match.
  • TracingBehavior<,> / MetricsBehavior<,> — CQRS pipeline behaviors. Tracing starts an activity named for the request and sets ok/error status (tags no business data); metrics record a duration histogram + failure counter, tagged by request name. AddResqObservabilityBehaviors registers both.
  • AddResqOptions<T>(sectionName) — bind a config section, ValidateDataAnnotations, and ValidateOnStart (fail fast at boot).
  • AddResqResiliencePipeline(key, configure?) — a Polly retry + circuit-breaker + timeout pipeline whose retry ShouldHandle treats a failed Result with ErrorType.Failure (or any exception) as retryable.

Known coupling (accepted)

FrameworkReference Microsoft.AspNetCore.App and AddAspNetCoreInstrumentation are unconditional, so a pure worker host that calls AddServiceDefaults still pulls the ASP.NET shared framework. This mirrors Aspire's own ServiceDefaults; a ServiceDefaults.Worker split is possible future work.

Apache-2.0 · part of resq-software/dotnet.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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
0.2.0 442 8/16/2026