@@ -20,6 +20,8 @@ public static class Extensions
2020
2121 public static TBuilder AddServiceDefaults < TBuilder > ( this TBuilder builder ) where TBuilder : IHostApplicationBuilder
2222 {
23+ ArgumentNullException . ThrowIfNull ( builder ) ;
24+
2325 builder . ConfigureOpenTelemetry ( ) ;
2426
2527 builder . AddDefaultHealthChecks ( ) ;
@@ -46,6 +48,8 @@ public static TBuilder AddServiceDefaults<TBuilder>(this TBuilder builder) where
4648
4749 public static TBuilder ConfigureOpenTelemetry < TBuilder > ( this TBuilder builder ) where TBuilder : IHostApplicationBuilder
4850 {
51+ ArgumentNullException . ThrowIfNull ( builder ) ;
52+
4953 builder . Logging . AddOpenTelemetry ( logging =>
5054 {
5155 logging . IncludeFormattedMessage = true ;
@@ -67,8 +71,8 @@ public static TBuilder ConfigureOpenTelemetry<TBuilder>(this TBuilder builder) w
6771 . AddAspNetCoreInstrumentation ( tracing =>
6872 // Exclude health check requests from tracing
6973 tracing . Filter = context =>
70- ! context . Request . Path . StartsWithSegments ( HealthEndpointPath )
71- && ! context . Request . Path . StartsWithSegments ( AlivenessEndpointPath )
74+ ! context . Request . Path . StartsWithSegments ( HealthEndpointPath , StringComparison . OrdinalIgnoreCase )
75+ && ! context . Request . Path . StartsWithSegments ( AlivenessEndpointPath , StringComparison . OrdinalIgnoreCase )
7276 )
7377 // Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package)
7478 //.AddGrpcClientInstrumentation()
@@ -102,6 +106,8 @@ private static TBuilder AddOpenTelemetryExporters<TBuilder>(this TBuilder builde
102106
103107 public static TBuilder AddDefaultHealthChecks < TBuilder > ( this TBuilder builder ) where TBuilder : IHostApplicationBuilder
104108 {
109+ ArgumentNullException . ThrowIfNull ( builder ) ;
110+
105111 builder . Services . AddHealthChecks ( )
106112 // Add a default liveness check to ensure app is responsive
107113 . AddCheck ( "self" , ( ) => HealthCheckResult . Healthy ( ) , [ "live" ] ) ;
@@ -111,6 +117,8 @@ public static TBuilder AddDefaultHealthChecks<TBuilder>(this TBuilder builder) w
111117
112118 public static WebApplication MapDefaultEndpoints ( this WebApplication app )
113119 {
120+ ArgumentNullException . ThrowIfNull ( app ) ;
121+
114122 // Adding health checks endpoints to applications in non-development environments has security implications.
115123 // See https://aka.ms/dotnet/aspire/healthchecks for details before enabling these endpoints in non-development environments.
116124 if ( app . Environment . IsDevelopment ( ) )
0 commit comments