Mute all healthcheck related trace spans in AspireShop#796
Mute all healthcheck related trace spans in AspireShop#796yuriyostapenko wants to merge 2 commits intomicrosoft:mainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR mutes healthcheck-related trace spans in AspireShop by filtering out unnecessary instrumentation for HTTP, gRPC, and Redis PING operations.
- Updated service extensions to include additional endpoint filtering for gRPC healthchecks.
- Added a new package reference for OpenTelemetry Redis instrumentation.
- Configured Redis tracing in AppHost to mute PING commands.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| samples/AspireShop/AspireShop.ServiceDefaults/Extensions.cs | Updated tracing filters to exclude healthcheck endpoints for HTTP and gRPC. |
| samples/AspireShop/AspireShop.BasketService/AspireShop.BasketService.csproj | Added package reference for OpenTelemetry Redis instrumentation. |
| samples/AspireShop/AspireShop.BasketService/AppHost.cs | Introduced Redis instrumentation to mute PING command spans. |
| // Don't trace requests to the health endpoint to avoid filling the dashboard with noise | ||
| grpcOptions.EnrichWithHttpRequestMessage = (activity, request) => | ||
| { | ||
| if (request.RequestUri?.AbsolutePath == GrpcHealthEndpointPath) |
There was a problem hiding this comment.
[nitpick] Consider aligning the comparison logic for the gRPC health endpoint with the HTTP instrumentation filter (which uses StartsWith) to maintain consistency in handling potential URL variations.
| if (request.RequestUri?.AbsolutePath == GrpcHealthEndpointPath) | |
| if (request.RequestUri?.AbsolutePath.StartsWith(GrpcHealthEndpointPath)) |
|
@dotnet-policy-service agree |
|
@yuriyostapenko would you mind rebasing this on latest changes? |
Server-side HTTP healthcheck endpoints were already filtered out, but http client spans were not, as well as gRPC and Redis PING commands. Now idle application does not spam spans.
46b560b to
d19eece
Compare
|
@DamianEdwards, rebased and updated to suppress |
|
@microsoft-github-policy-service agree |
| builder.AddNpgsqlDbContext<CatalogDbContext>("catalogdb", null, | ||
| optionsBuilder => optionsBuilder.UseNpgsql(npgsqlBuilder => | ||
| npgsqlBuilder.MigrationsAssembly(typeof(Program).Assembly.GetName().Name))); | ||
| { | ||
| npgsqlBuilder.MigrationsAssembly(typeof(Program).Assembly.GetName().Name); | ||
| npgsqlBuilder.ConfigureDataSource(dataSourceBuilder => | ||
| { | ||
| dataSourceBuilder.ConfigureTracing(options => | ||
| { | ||
| options.ConfigureCommandFilter(cmd => | ||
| { | ||
| // Don't trace commands related to the health check to avoid filling the dashboard with noise | ||
| if (cmd.CommandText.Contains("SELECT 1")) | ||
| { | ||
| return false; | ||
| } | ||
| return true; | ||
| }); | ||
| }); | ||
| }); | ||
| })); |
There was a problem hiding this comment.
This level of lambda nesting is truly unfortunate 😬
There was a problem hiding this comment.
Would it be useful to add a helper method to our integration to suppress?
There was a problem hiding this comment.
Could be yeah. What are you thinking? Something that hangs off the npgsqlBuilder in the above, hoisting it out 2 levels basically?
Server-side HTTP healthcheck endpoints were already filtered out, but http client spans were not, as well as gRPC, Redis
PINGcommands and PostgresSELECT 1's.Now idle application does not spam spans.