aspire-service-defaults

Create a shared ServiceDefaults project for Aspire applications. Centralizes OpenTelemetry, health checks, resilience, and service discovery configuration across all services.

By aaronontheweb · 428 installs

npx skills add aaronontheweb/dotnet-skills --skill aspire-service-defaults

Source repository · Upstream listing

Aspire Service Defaults When to Use This Skill Use this skill when: Building Aspire based distributed applications Need consistent observability (logging, tracing, metrics) across services Want shared health check configuration Configuring HttpClient resilience and service discovery What is ServiceDefaults? ServiceDefaults is a shared project that provides common configuration for all services in an Aspire application: OpenTelemetry Logging, tracing, and metrics Health Checks Readiness and liveness endpoints Service Discovery Automatic service resolution HTTP Resilience Retry and circuit breaker policies Every service references this project and calls AddServiceDefaults() . Project Structure ServiceDefaults Project Project File Extensions.cs Usage in Services API Service Worker Service Adding Custom Health Checks Adding Custom Trace Sources For Akka.NET or custom ActivitySources: Production Health Checks For production, protect health endpoints or use different paths: Integration with AppHost The AppHost automatically configures OTLP endpoints: Services receive OTEL EXPORTER OTLP ENDPOINT automatically, sending telemetry to the Aspire Dashboard. Best Practices Practice Reason One ServiceDefaults project Consistent config across all services Filter health checks from traces Reduces noise in observability data Tag health checks Separate liveness from readiness Use StandardResilienceHandler Built in retry, circuit breaker, timeout Add custom trace sources Capture domain specific spans Resources Aspire Service Defaults : https://learn.microsoft.com/en us/dotnet/aspire/fundamentals/service defaults OpenTelemetry .NET : https://opentelemetry.io/docs/languages/net/ Health Checks : https://learn.microsoft.com/en us/aspnet/core/host and deploy/health checks