Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@
<PackageReference Include="AspNetCore.HealthChecks.Uris" />
</ItemGroup>

<ItemGroup>
<Compile Include="$(SharedDir)\LoggingUtils.cs" Link="LoggingUtils.cs" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Aspire.Hosting.ApplicationModel;
using CommunityToolkit.Hosting.Utils;
using Microsoft.Extensions.DependencyInjection;

namespace Aspire.Hosting;
Expand Down Expand Up @@ -138,6 +139,7 @@ public static IResourceBuilder<McpInspectorResource> AddMcpInspector(this IDistr
setup.AddCustomHeader("X-MCP-Proxy-Auth", $"Bearer {token}");
});
}, healthCheckKey);
builder.Services.SuppressHealthCheckHttpClientLogging(healthCheckKey);

return resource.WithHealthCheck(healthCheckKey);
}
Expand Down
17 changes: 17 additions & 0 deletions src/Shared/LoggingUtils.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

namespace CommunityToolkit.Hosting.Utils;

internal static class LoggingUtils
{
Comment on lines +5 to +7
Copy link

Copilot AI Oct 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The LoggingUtils class and SuppressHealthCheckHttpClientLogging method are missing XML documentation comments. All public members should have XML doc comments according to project guidelines.

Suggested change
internal static class LoggingUtils
{
/// <summary>
/// Provides utility methods for configuring logging in the application.
/// </summary>
internal static class LoggingUtils
{
/// <summary>
/// Suppresses logging for HTTP client requests made by a specific health check.
/// </summary>
/// <param name="services">The service collection to configure logging for.</param>
/// <param name="healthCheckName">The name of the health check whose HTTP client logging should be suppressed.</param>

Copilot uses AI. Check for mistakes.
public static void SuppressHealthCheckHttpClientLogging(this IServiceCollection services, string healthCheckName)
{
services.AddLogging(configure =>
{
// The AddUrlGroup health check makes use of http client factory.
configure.AddFilter($"System.Net.Http.HttpClient.{healthCheckName}.LogicalHandler", LogLevel.None);
configure.AddFilter($"System.Net.Http.HttpClient.{healthCheckName}.ClientHandler", LogLevel.None);
});
}
}
Loading