Nabs.Launchpad.Core.ServiceDefaults
10.0.181-rc3
Prefix Reserved
See the version list below for details.
dotnet add package Nabs.Launchpad.Core.ServiceDefaults --version 10.0.181-rc3
NuGet\Install-Package Nabs.Launchpad.Core.ServiceDefaults -Version 10.0.181-rc3
<PackageReference Include="Nabs.Launchpad.Core.ServiceDefaults" Version="10.0.181-rc3" />
<PackageVersion Include="Nabs.Launchpad.Core.ServiceDefaults" Version="10.0.181-rc3" />
<PackageReference Include="Nabs.Launchpad.Core.ServiceDefaults" />
paket add Nabs.Launchpad.Core.ServiceDefaults --version 10.0.181-rc3
#r "nuget: Nabs.Launchpad.Core.ServiceDefaults, 10.0.181-rc3"
#:package Nabs.Launchpad.Core.ServiceDefaults@10.0.181-rc3
#addin nuget:?package=Nabs.Launchpad.Core.ServiceDefaults&version=10.0.181-rc3&prerelease
#tool nuget:?package=Nabs.Launchpad.Core.ServiceDefaults&version=10.0.181-rc3&prerelease
Nabs Launchpad Core Service Defaults Library
The Nabs Launchpad Core Service Defaults library provides standardized observability, health checks, service discovery, and HTTP resilience configuration for all Launchpad applications. This library implements best practices for distributed applications based on .NET Aspire patterns.
Key Features
- OpenTelemetry Integration: Comprehensive logging, metrics, and distributed tracing
- Health Checks: Built-in health and liveness endpoints for container orchestration
- Service Discovery: Automatic service resolution and load balancing
- HTTP Resilience: Standard retry, timeout, and circuit breaker patterns
- Metrics Collection: ASP.NET Core, HTTP client, and runtime metrics
- Distributed Tracing: Request correlation across services
- OTLP Export: OpenTelemetry Protocol support for observability platforms
Core Components
ProjectExtensions
Provides extension methods for configuring service defaults on IHostApplicationBuilder and WebApplication.
Usage Examples
Basic Service Setup
using Nabs.Launchpad.Core.ServiceDefaults;
var builder = WebApplication.CreateBuilder(args);
// Add all service defaults (telemetry, health checks, service discovery, resilience)
builder.AddServiceDefaults();
// Your service configuration
builder.Services.AddControllers();
var app = builder.Build();
// Map health check endpoints
app.MapDefaultEndpoints();
app.MapControllers();
await app.RunAsync();
Custom OpenTelemetry Configuration
var builder = WebApplication.CreateBuilder(args);
// Configure only OpenTelemetry (without other defaults)
builder.ConfigureOpenTelemetry();
// Add custom metrics
builder.Services.AddOpenTelemetry()
.WithMetrics(metrics =>
{
metrics.AddMeter("MyApp.CustomMetrics");
});
var app = builder.Build();
Health Checks Only
var builder = WebApplication.CreateBuilder(args);
// Add only health checks
builder.AddDefaultHealthChecks();
// Add custom health checks
builder.Services.AddHealthChecks()
.AddCheck<DatabaseHealthCheck>("database")
.AddCheck<CacheHealthCheck>("cache", tags: new[] { "ready" });
var app = builder.Build();
app.MapDefaultEndpoints();
Aspire AppHost Integration
// In your AppHost project
var builder = DistributedApplication.CreateBuilder(args);
// Service defaults are automatically applied to all projects
var apiService = builder.AddProject<Projects.MyApi>("api-service");
var webApp = builder.AddProject<Projects.MyWebApp>("web-app")
.WithReference(apiService);
builder.Build().Run();
API Reference
AddServiceDefaults<TBuilder>
public static TBuilder AddServiceDefaults<TBuilder>(this TBuilder builder)
where TBuilder : IHostApplicationBuilder
Adds all service defaults including:
- OpenTelemetry configuration
- Health checks
- Service discovery
- HTTP client resilience
Returns: The builder for method chaining
Usage:
builder.AddServiceDefaults();
ConfigureOpenTelemetry<TBuilder>
public static TBuilder ConfigureOpenTelemetry<TBuilder>(this TBuilder builder)
where TBuilder : IHostApplicationBuilder
Configures OpenTelemetry for logging, metrics, and tracing.
Includes:
- Formatted message logging with scopes
- ASP.NET Core metrics and instrumentation
- HTTP client metrics and instrumentation
- Runtime metrics (GC, thread pool, exceptions)
- Distributed tracing with activity correlation
- OTLP exporter (when
OTEL_EXPORTER_OTLP_ENDPOINTis configured)
Returns: The builder for method chaining
AddDefaultHealthChecks<TBuilder>
public static TBuilder AddDefaultHealthChecks<TBuilder>(this TBuilder builder)
where TBuilder : IHostApplicationBuilder
Adds default health checks including a self-check tagged as "live".
Returns: The builder for method chaining
Usage:
builder.AddDefaultHealthChecks();
// Add custom health checks
builder.Services.AddHealthChecks()
.AddCheck<MyCustomHealthCheck>("my-check");
MapDefaultEndpoints
public static WebApplication MapDefaultEndpoints(this WebApplication app)
Maps health check endpoints (development environment only for security).
Endpoints:
/health- All health checks must pass (readiness)/alive- Only "live" tagged checks must pass (liveness)
Returns: The WebApplication for method chaining
Usage:
var app = builder.Build();
app.MapDefaultEndpoints();
OpenTelemetry Configuration
Metrics
Automatically collected metrics include:
ASP.NET Core Metrics:
- Request duration
- Request rate
- Active requests
- Failed requests
HTTP Client Metrics:
- Request duration by endpoint
- Success/failure rates
- Active connections
Runtime Metrics:
- GC collections
- Heap size
- Thread pool statistics
- Exception counts
Tracing
Automatically instrumented traces:
ASP.NET Core Tracing:
- HTTP request spans
- Automatic span hierarchy
- Exception tracking
- Excludes health check endpoints
HTTP Client Tracing:
- Outbound HTTP request spans
- Service dependency mapping
- Request/response details
Logging
Enhanced logging features:
- Formatted Messages: Full message formatting included
- Scopes: Log scopes preserved for context
- Structured Logging: JSON-structured logs
- OpenTelemetry Integration: Logs correlated with traces
Health Checks
Default Health Checks
The library provides a "self" health check tagged as "live":
.AddCheck("self", () => HealthCheckResult.Healthy(), ["live"])
Health Check Endpoints
/health (Readiness)
- All registered health checks must pass
- Used by orchestrators to determine if pod should receive traffic
- Returns 200 OK when healthy, 503 Service Unavailable otherwise
/alive (Liveness)
- Only health checks tagged with "live" must pass
- Used by orchestrators to determine if pod should be restarted
- Returns 200 OK when alive, 503 Service Unavailable otherwise
Custom Health Checks
// Register custom health check
builder.Services.AddHealthChecks()
.AddCheck<DatabaseHealthCheck>("database", tags: new[] { "ready" })
.AddCheck<CacheHealthCheck>("cache", tags: new[] { "ready" })
.AddCheck("api-dependency", () =>
{
// Check external API
return HealthCheckResult.Healthy();
}, tags: new[] { "ready" });
// Health check implementation
public class DatabaseHealthCheck : IHealthCheck
{
private readonly IDbConnection _connection;
public DatabaseHealthCheck(IDbConnection connection)
{
_connection = connection;
}
public async Task<HealthCheckResult> CheckHealthAsync(
HealthCheckContext context,
CancellationToken cancellationToken = default)
{
try
{
await _connection.OpenAsync(cancellationToken);
return HealthCheckResult.Healthy("Database is accessible");
}
catch (Exception ex)
{
return HealthCheckResult.Unhealthy("Database is not accessible", ex);
}
}
}
Service Discovery
Automatic Service Resolution
HTTP clients automatically resolve service names:
// Service registration (no hardcoded URLs)
builder.Services.AddHttpClient<IOrdersService, OrdersService>(client =>
{
client.BaseAddress = new Uri("http://orders-service"); // Service name, not URL
});
// Usage
public class OrdersService : IOrdersService
{
private readonly HttpClient _httpClient;
public OrdersService(HttpClient httpClient)
{
_httpClient = httpClient; // Automatically configured with service discovery
}
public async Task<Order> GetOrderAsync(int id)
{
// Service name resolves to actual endpoint
return await _httpClient.GetFromJsonAsync<Order>($"/api/orders/{id}");
}
}
Service Discovery Configuration
// Optional: Restrict allowed schemes
builder.Services.Configure<ServiceDiscoveryOptions>(options =>
{
options.AllowedSchemes = ["https"]; // Only allow HTTPS endpoints
});
HTTP Resilience
Standard Resilience Handler
Automatically applied to all HTTP clients:
Includes:
- Retry Policy: Exponential backoff with jitter
- Timeout Policy: Request and overall timeout
- Circuit Breaker: Prevents cascading failures
- Rate Limiter: Controls request rate
Configuration
// HTTP client with standard resilience
builder.Services.AddHttpClient<IMyService, MyService>(client =>
{
client.BaseAddress = new Uri("http://my-service");
})
.AddStandardResilienceHandler(); // Already added by service defaults
// Custom resilience configuration
builder.Services.AddHttpClient<IMyService, MyService>()
.AddStandardResilienceHandler(options =>
{
options.Retry.MaxRetryAttempts = 5;
options.CircuitBreaker.SamplingDuration = TimeSpan.FromSeconds(30);
});
OTLP Export Configuration
Environment Variables
Configure OTLP exporter using standard environment variables:
# OTLP endpoint (enables exporter when set)
OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317
# Optional: Configure protocol (grpc or http/protobuf)
OTEL_EXPORTER_OTLP_PROTOCOL=grpc
# Optional: Configure headers (for authentication)
OTEL_EXPORTER_OTLP_HEADERS=api-key=your-api-key
appsettings.json Configuration
{
"OTEL_EXPORTER_OTLP_ENDPOINT": "http://localhost:4317",
"OTEL_EXPORTER_OTLP_PROTOCOL": "grpc"
}
Supported Backends
Works with any OpenTelemetry-compatible backend:
- Jaeger: Distributed tracing
- Prometheus: Metrics collection
- Grafana: Visualization
- Azure Monitor: Azure Application Insights
- AWS X-Ray: AWS observability
- Google Cloud Trace: GCP observability
Container Orchestration
Kubernetes Integration
apiVersion: v1
kind: Pod
metadata:
name: my-service
spec:
containers:
- name: my-service
image: my-service:latest
livenessProbe:
httpGet:
path: /alive
port: 8080
initialDelaySeconds: 10
periodSeconds: 30
readinessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
Docker Compose
version: '3.8'
services:
my-service:
image: my-service:latest
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/alive"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
Best Practices
Service Defaults
- Always Use: Call
AddServiceDefaults()in every service - Order Matters: Call before other service registrations
- Map Endpoints: Always call
MapDefaultEndpoints()for health checks
Health Checks
- Tag Appropriately: Use "live" for liveness, "ready" for readiness
- Fast Checks: Keep health checks lightweight (< 1 second)
- Avoid Cascading: Don't check downstream services in liveness checks
- Include Dependencies: Check critical dependencies in readiness checks
Observability
- Environment-Specific: Use OTLP in production, console in development
- Sampling: Configure appropriate trace sampling in production
- Sensitive Data: Avoid logging sensitive information
- Custom Metrics: Add application-specific metrics when needed
HTTP Clients
- Named Clients: Use typed or named HTTP clients
- Service Names: Use service names instead of URLs for discovery
- Resilience: Trust the standard resilience handler
- Timeouts: Configure appropriate timeouts for your scenarios
Security Considerations
Health Check Endpoints
- Only exposed in development by default
- Consider authentication for production environments
- Avoid exposing sensitive information in health check responses
Observability Data
- Sanitize sensitive data before logging
- Use appropriate retention policies
- Secure OTLP endpoints with authentication
- Consider data privacy regulations (GDPR, HIPAA, etc.)
Dependencies
- Microsoft.Extensions.Http.Resilience: HTTP resilience patterns
- Microsoft.Extensions.ServiceDiscovery: Service discovery client
- OpenTelemetry.Exporter.OpenTelemetryProtocol: OTLP exporter
- OpenTelemetry.Extensions.Hosting: OpenTelemetry hosting integration
- OpenTelemetry.Instrumentation.AspNetCore: ASP.NET Core instrumentation
- OpenTelemetry.Instrumentation.Http: HTTP client instrumentation
- OpenTelemetry.Instrumentation.Runtime: .NET runtime instrumentation
Related Libraries
- Nabs.Launchpad.Core.Gateway: Gateway service using service defaults
- Nabs.Launchpad.Core.Silo: Orleans silo with service defaults
- Nabs.Launchpad.Core.Portal: Blazor portal with service defaults
Target Framework
- .NET 10
| 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
- Microsoft.Extensions.Http.Resilience (>= 10.0.0)
- Microsoft.Extensions.ServiceDiscovery (>= 10.0.0)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.14.0-rc.1)
- OpenTelemetry.Extensions.Hosting (>= 1.14.0-rc.1)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.14.0-rc.1)
- OpenTelemetry.Instrumentation.Http (>= 1.14.0-rc.1)
- OpenTelemetry.Instrumentation.Runtime (>= 1.13.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Nabs.Launchpad.Core.ServiceDefaults:
| Package | Downloads |
|---|---|
|
Nabs.Launchpad.Core.Silo
Package Description |
|
|
Nabs.Launchpad.Core.Gateway
Package Description |
|
|
Nabs.Launchpad.Core.Portal
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 10.0.196 | 30 | 12/3/2025 | |
| 10.0.195 | 30 | 12/3/2025 | |
| 10.0.194 | 32 | 12/3/2025 | |
| 10.0.193 | 75 | 12/2/2025 | |
| 10.0.192 | 160 | 11/28/2025 | |
| 10.0.190 | 166 | 11/27/2025 | |
| 10.0.189 | 161 | 11/23/2025 | |
| 10.0.187 | 166 | 11/23/2025 | |
| 10.0.186 | 144 | 11/23/2025 | |
| 10.0.184 | 404 | 11/20/2025 | |
| 10.0.181-rc3 | 251 | 11/11/2025 | |
| 10.0.179-rc2 | 241 | 11/11/2025 | |
| 10.0.178-rc2 | 196 | 11/10/2025 | |
| 10.0.177-rc2 | 187 | 11/10/2025 | |
| 10.0.176-rc2 | 149 | 11/6/2025 | |
| 10.0.175-rc2 | 145 | 11/6/2025 | |
| 10.0.174-rc2 | 154 | 11/5/2025 | |
| 10.0.173-rc2 | 168 | 11/3/2025 | |
| 10.0.172-rc2 | 179 | 11/2/2025 | |
| 10.0.170-rc2 | 165 | 11/1/2025 | |
| 10.0.169-rc2 | 167 | 11/1/2025 | |
| 10.0.168-rc2 | 168 | 10/31/2025 | |
| 10.0.166-rc2 | 172 | 10/31/2025 | |
| 10.0.164-rc2 | 231 | 10/28/2025 | |
| 10.0.162-rc2 | 229 | 10/24/2025 | |
| 9.0.151 | 223 | 10/17/2025 | |
| 9.0.150 | 288 | 9/10/2025 | |
| 9.0.146 | 241 | 8/15/2025 | |
| 9.0.145 | 289 | 8/11/2025 | |
| 9.0.144 | 300 | 8/8/2025 | |
| 9.0.137 | 238 | 7/29/2025 | |
| 9.0.136 | 244 | 7/29/2025 | |
| 9.0.135 | 258 | 7/28/2025 | |
| 9.0.134 | 292 | 7/9/2025 | |
| 9.0.133 | 306 | 7/9/2025 | |
| 9.0.132 | 301 | 7/9/2025 | |
| 9.0.131 | 308 | 7/9/2025 | |
| 9.0.130 | 288 | 7/7/2025 |