Altinn.AspNet.HealthChecks.OpenTelemetry
0.3.0
dotnet add package Altinn.AspNet.HealthChecks.OpenTelemetry --version 0.3.0
NuGet\Install-Package Altinn.AspNet.HealthChecks.OpenTelemetry -Version 0.3.0
<PackageReference Include="Altinn.AspNet.HealthChecks.OpenTelemetry" Version="0.3.0" />
<PackageVersion Include="Altinn.AspNet.HealthChecks.OpenTelemetry" Version="0.3.0" />
<PackageReference Include="Altinn.AspNet.HealthChecks.OpenTelemetry" />
paket add Altinn.AspNet.HealthChecks.OpenTelemetry --version 0.3.0
#r "nuget: Altinn.AspNet.HealthChecks.OpenTelemetry, 0.3.0"
#:package Altinn.AspNet.HealthChecks.OpenTelemetry@0.3.0
#addin nuget:?package=Altinn.AspNet.HealthChecks.OpenTelemetry&version=0.3.0
#tool nuget:?package=Altinn.AspNet.HealthChecks.OpenTelemetry&version=0.3.0
Altinn.AspNet.HealthChecks.OpenTelemetry
Experimental — pre-1.0.0. APIs may change without notice before the 1.0.0 release.
OpenTelemetry companion package to
Altinn.AspNet.HealthChecks:
a span processor that drops the noisy ASP.NET Core server spans produced by health check
probes, so /health* traffic does not flood your traces.
Usage
tracerProviderBuilder
.AddHealthCheckActivityFilter() // suppresses the five default /health* endpoints
.AddOtlpExporter(); // exporters must be registered after the filter
Without arguments, the filter suppresses the five endpoints mapped by
MapAltinnHealthChecks(): /alive, /health, /health/readiness,
/health/startup and /health/deep. Pass your own route suffixes to replace the defaults:
tracerProviderBuilder.AddHealthCheckActivityFilter("/internal/health");
If you customise the endpoint paths, share the options object
The defaults above are hardcoded, so moving a path leaves the filter matching the old one —
silently, with no error and no clue beyond a growing trace bill. Pass the same
HealthCheckEndpointOptions instance to both, and the two cannot disagree:
var healthEndpoints = new HealthCheckEndpointOptions();
healthEndpoints.Deep.Path = "/internal/health/deep";
healthEndpoints.Startup.Disable();
builder.Services.AddOpenTelemetry().WithTracing(t => t
.AddHealthCheckActivityFilter(healthEndpoints) // suppresses exactly what gets mapped
.AddOtlpExporter());
app.MapAltinnHealthChecks(healthEndpoints);
Disabled endpoints are not suppressed: nothing is mapped there, so a route ending that way belongs to your app and its spans are kept.
Matching is by case-insensitive route suffix, so the endpoints stay suppressed when the
app is mounted under a path base. The flip side: any route ending in a suffix is suppressed
too — if your API has a business route like /api/devices/{id}/health, its spans are dropped
under the defaults. Pass explicit, more specific suffixes in that case.
How it works
The filter is a span processor that clears the Recorded flag on ASP.NET Core server spans
whose http.route (or url.path) ends with one of the configured suffixes. Export processors
skip spans that are not recorded, so the span reaches no exporter — but only exporters added
after the filter, since processors run in registration order.
The decision is made when the server span ends, so child spans created while the probe ran (a database call inside a deep check, say) are still exported. To drop the whole trace, filter at the instrumentation level instead — that also avoids creating the span in the first place:
tracerProviderBuilder.AddAspNetCoreInstrumentation(o =>
o.Filter = ctx => !ctx.Request.Path.StartsWithSegments("/health"));
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
- Altinn.AspNet.HealthChecks (>= 0.3.0)
- OpenTelemetry (>= 1.17.0)
-
net8.0
- Altinn.AspNet.HealthChecks (>= 0.3.0)
- OpenTelemetry (>= 1.17.0)
-
net9.0
- Altinn.AspNet.HealthChecks (>= 0.3.0)
- OpenTelemetry (>= 1.17.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.