TailoredApps.Shared.WebApi
1.4.10
dotnet add package TailoredApps.Shared.WebApi --version 1.4.10
NuGet\Install-Package TailoredApps.Shared.WebApi -Version 1.4.10
<PackageReference Include="TailoredApps.Shared.WebApi" Version="1.4.10" />
<PackageVersion Include="TailoredApps.Shared.WebApi" Version="1.4.10" />
<PackageReference Include="TailoredApps.Shared.WebApi" />
paket add TailoredApps.Shared.WebApi --version 1.4.10
#r "nuget: TailoredApps.Shared.WebApi, 1.4.10"
#:package TailoredApps.Shared.WebApi@1.4.10
#addin nuget:?package=TailoredApps.Shared.WebApi&version=1.4.10
#tool nuget:?package=TailoredApps.Shared.WebApi&version=1.4.10
TailoredApps.Shared.WebApi
Production-ready defaults for ASP.NET Core Web APIs, wired through a single call. Add this package to
every service and get consistent observability, health probing and outbound-call resilience without
copy-pasting boilerplate into each Program.cs.
What you get
| Concern | What is configured |
|---|---|
| Metrics | OpenTelemetry metrics for ASP.NET Core, HttpClient and the .NET runtime (GC, thread pool, exceptions). |
| Tracing | OpenTelemetry distributed tracing for ASP.NET Core and HttpClient; health-probe requests are filtered out. |
| Logging | OpenTelemetry logging with formatted messages and scopes. |
| Export | OTLP exporter for all three signals, enabled when an endpoint is configured. |
| Health checks | Readiness (/health, all checks) and liveness (/alive, live-tagged checks) endpoints with a JSON writer. |
| HTTP clients | Standard resilience handler (retry, circuit breaker, timeouts) and service discovery on every client. |
Usage
var builder = WebApplication.CreateBuilder(args);
builder.AddTailoredWebApiDefaults();
var app = builder.Build();
app.MapTailoredWebApiDefaults(); // maps /health and /alive
app.Run();
Configuration
Everything can be driven from the WebApiDefaults configuration section:
{
"WebApiDefaults": {
"ServiceName": "catalog-api",
"ServiceVersion": "1.4.0",
"HealthChecks": {
"ReadinessPath": "/health",
"LivenessPath": "/alive",
"AllowDetailedResponse": false
},
"Observability": {
"EnableTracing": true,
"EnableMetrics": true,
"EnableLogging": true,
"OtlpExporterEndpoint": "http://otel-collector:4317"
},
"HttpClient": {
"EnableStandardResilience": true,
"EnableServiceDiscovery": true
}
}
}
The OTLP endpoint also honours the standard OTEL_EXPORTER_OTLP_ENDPOINT environment variable. When no
endpoint is resolved, telemetry is still collected in-process but not exported.
Overriding in code
Code overrides are applied after configuration binding:
builder.AddTailoredWebApiDefaults(options =>
{
options.ServiceName = "catalog-api";
options.HealthChecks.AllowDetailedResponse = builder.Environment.IsDevelopment();
});
Adding a Prometheus /metrics endpoint
The default export path is OTLP (push to an OpenTelemetry Collector, which can expose Prometheus). If you
want an in-process Prometheus scrape endpoint instead, add the
OpenTelemetry.Exporter.Prometheus.AspNetCore package and use the metrics hook:
builder.AddTailoredWebApiDefaults(options =>
{
options.Observability.ConfigureMetrics = metrics => metrics.AddPrometheusExporter();
});
var app = builder.Build();
app.MapTailoredWebApiDefaults();
app.MapPrometheusScrapingEndpoint(); // /metrics
Target frameworks
net8.0, net9.0, net10.0.
| Product | Versions 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 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.7.0)
- Microsoft.Extensions.ServiceDiscovery (>= 10.7.0)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.16.0)
- OpenTelemetry.Extensions.Hosting (>= 1.16.0)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.16.0)
- OpenTelemetry.Instrumentation.Http (>= 1.16.0)
- OpenTelemetry.Instrumentation.Runtime (>= 1.15.1)
-
net8.0
- Microsoft.Extensions.Http.Resilience (>= 8.10.0)
- Microsoft.Extensions.ServiceDiscovery (>= 8.2.2)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.16.0)
- OpenTelemetry.Extensions.Hosting (>= 1.16.0)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.16.0)
- OpenTelemetry.Instrumentation.Http (>= 1.16.0)
- OpenTelemetry.Instrumentation.Runtime (>= 1.15.1)
-
net9.0
- Microsoft.Extensions.Http.Resilience (>= 9.10.0)
- Microsoft.Extensions.ServiceDiscovery (>= 9.5.2)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.16.0)
- OpenTelemetry.Extensions.Hosting (>= 1.16.0)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.16.0)
- OpenTelemetry.Instrumentation.Http (>= 1.16.0)
- OpenTelemetry.Instrumentation.Runtime (>= 1.15.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.