From fdab31fb4c3ed82f69d4e2fa8f3c7dc816ce6afa Mon Sep 17 00:00:00 2001 From: Collin Barrett <6483057+collinbarrett@users.noreply.github.com> Date: Mon, 26 May 2025 17:40:56 -0500 Subject: [PATCH] Revert "chore: update Aspire bits" This reverts commit 61f12927ff15447b95bf6e540649fab46970aa73. --- .../FilterLists.Directory.Api.csproj | 8 +-- .../FilterLists.AppHost.csproj | 9 +-- .../{AppHost.cs => Program.cs} | 0 .../Properties/launchSettings.json | 12 ++-- .../FilterLists.ServiceDefaults/Extensions.cs | 67 ++++++++----------- .../FilterLists.ServiceDefaults.csproj | 6 +- services/FilterLists.sln.DotSettings | 7 -- 7 files changed, 45 insertions(+), 64 deletions(-) rename services/FilterLists.AppHost/{AppHost.cs => Program.cs} (100%) delete mode 100644 services/FilterLists.sln.DotSettings diff --git a/services/Directory/FilterLists.Directory.Api/FilterLists.Directory.Api.csproj b/services/Directory/FilterLists.Directory.Api/FilterLists.Directory.Api.csproj index 52039f3e2..16645ea8c 100644 --- a/services/Directory/FilterLists.Directory.Api/FilterLists.Directory.Api.csproj +++ b/services/Directory/FilterLists.Directory.Api/FilterLists.Directory.Api.csproj @@ -4,7 +4,7 @@ net9.0 enable enable - All + Recommended @@ -23,12 +23,12 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/services/FilterLists.AppHost/FilterLists.AppHost.csproj b/services/FilterLists.AppHost/FilterLists.AppHost.csproj index b0b6f732e..f7c038c5c 100644 --- a/services/FilterLists.AppHost/FilterLists.AppHost.csproj +++ b/services/FilterLists.AppHost/FilterLists.AppHost.csproj @@ -1,14 +1,15 @@ - + Exe net9.0 enable enable + true c7967ef0-ced7-4e18-8282-7302b3c0002b - All + Recommended @@ -16,8 +17,8 @@ - - + + \ No newline at end of file diff --git a/services/FilterLists.AppHost/AppHost.cs b/services/FilterLists.AppHost/Program.cs similarity index 100% rename from services/FilterLists.AppHost/AppHost.cs rename to services/FilterLists.AppHost/Program.cs diff --git a/services/FilterLists.AppHost/Properties/launchSettings.json b/services/FilterLists.AppHost/Properties/launchSettings.json index ce19f7aa3..8db094ab5 100644 --- a/services/FilterLists.AppHost/Properties/launchSettings.json +++ b/services/FilterLists.AppHost/Properties/launchSettings.json @@ -5,24 +5,24 @@ "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, - "applicationUrl": "https://localhost:17145;http://localhost:15172", + "applicationUrl": "https://localhost:17246;http://localhost:15280", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development", "DOTNET_ENVIRONMENT": "Development", - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21129", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22052" + "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21069", + "DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22035" } }, "http": { "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, - "applicationUrl": "http://localhost:15172", + "applicationUrl": "http://localhost:15280", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development", "DOTNET_ENVIRONMENT": "Development", - "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19265", - "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20065" + "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19157", + "DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20152" } } } diff --git a/services/FilterLists.ServiceDefaults/Extensions.cs b/services/FilterLists.ServiceDefaults/Extensions.cs index 7c8919c33..735832d0a 100644 --- a/services/FilterLists.ServiceDefaults/Extensions.cs +++ b/services/FilterLists.ServiceDefaults/Extensions.cs @@ -8,7 +8,8 @@ using OpenTelemetry.Metrics; using OpenTelemetry.Trace; -// ReSharper disable once CheckNamespace +// ReSharper disable All + namespace Microsoft.Extensions.Hosting; // Adds common .NET Aspire services: service discovery, resilience, health checks, and OpenTelemetry. @@ -16,10 +17,7 @@ namespace Microsoft.Extensions.Hosting; // To learn more about using this project, see https://aka.ms/dotnet/aspire/service-defaults public static class Extensions { - private const string HealthEndpointPath = "/health"; - private const string AlivenessEndpointPath = "/alive"; - - public static TBuilder AddServiceDefaults(this TBuilder builder) where TBuilder : IHostApplicationBuilder + public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBuilder builder) { builder.ConfigureOpenTelemetry(); @@ -36,16 +34,10 @@ public static TBuilder AddServiceDefaults(this TBuilder builder) where http.AddServiceDiscovery(); }); - // Uncomment the following to restrict the allowed schemes for service discovery. - // builder.Services.Configure(options => - // { - // options.AllowedSchemes = ["https"]; - // }); - return builder; } - private static void ConfigureOpenTelemetry(this TBuilder builder) where TBuilder : IHostApplicationBuilder + public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicationBuilder builder) { builder.Logging.AddOpenTelemetry(logging => { @@ -62,60 +54,55 @@ private static void ConfigureOpenTelemetry(this TBuilder builder) wher }) .WithTracing(tracing => { - tracing.AddSource(builder.Environment.ApplicationName) - .AddAspNetCoreInstrumentation(tracingOptions => - // Exclude health check requests from tracing - tracingOptions.Filter = context => - !context.Request.Path.StartsWithSegments(HealthEndpointPath, - StringComparison.InvariantCultureIgnoreCase) - && !context.Request.Path.StartsWithSegments(AlivenessEndpointPath, - StringComparison.InvariantCultureIgnoreCase) - ) + tracing.AddAspNetCoreInstrumentation() // Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package) //.AddGrpcClientInstrumentation() .AddHttpClientInstrumentation(); }); builder.AddOpenTelemetryExporters(); + + return builder; } - private static void AddOpenTelemetryExporters(this TBuilder builder) - where TBuilder : IHostApplicationBuilder + private static IHostApplicationBuilder AddOpenTelemetryExporters(this IHostApplicationBuilder builder) { var useOtlpExporter = !string.IsNullOrWhiteSpace(builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"]); - if (useOtlpExporter) builder.Services.AddOpenTelemetry().UseOtlpExporter(); + if (useOtlpExporter) + { + builder.Services.AddOpenTelemetry().UseOtlpExporter(); + } // Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.AspNetCore package) if (!string.IsNullOrEmpty(builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"])) + { builder.Services.AddOpenTelemetry() .UseAzureMonitor(); + } + + return builder; } - private static void AddDefaultHealthChecks(this TBuilder builder) where TBuilder : IHostApplicationBuilder + public static IHostApplicationBuilder AddDefaultHealthChecks(this IHostApplicationBuilder builder) { builder.Services.AddHealthChecks() - // Add a default liveness check to ensure the app is responsive + // Add a default liveness check to ensure app is responsive .AddCheck("self", () => HealthCheckResult.Healthy(), ["live"]); + + return builder; } public static WebApplication MapDefaultEndpoints(this WebApplication app) { - // Adding health checks endpoints to applications in non-development environments has security implications. - // See https://aka.ms/dotnet/aspire/healthchecks for details before enabling these endpoints in non-development environments. -#pragma warning disable CA1062 - if (app.Environment.IsDevelopment()) -#pragma warning restore CA1062 - { - // All health checks must pass for the app to be considered ready to accept traffic after starting - app.MapHealthChecks(HealthEndpointPath); + // All health checks must pass for app to be considered ready to accept traffic after starting + app.MapHealthChecks("/health"); - // Only health checks tagged with the "live" tag must pass for the app to be considered alive - app.MapHealthChecks(AlivenessEndpointPath, new HealthCheckOptions - { - Predicate = r => r.Tags.Contains("live") - }); - } + // Only health checks tagged with the "live" tag must pass for app to be considered alive + app.MapHealthChecks("/alive", new HealthCheckOptions + { + Predicate = r => r.Tags.Contains("live") + }); return app; } diff --git a/services/FilterLists.ServiceDefaults/FilterLists.ServiceDefaults.csproj b/services/FilterLists.ServiceDefaults/FilterLists.ServiceDefaults.csproj index 345a81c74..6caa33700 100644 --- a/services/FilterLists.ServiceDefaults/FilterLists.ServiceDefaults.csproj +++ b/services/FilterLists.ServiceDefaults/FilterLists.ServiceDefaults.csproj @@ -5,15 +5,15 @@ enable enable true - All + Recommended - - + + diff --git a/services/FilterLists.sln.DotSettings b/services/FilterLists.sln.DotSettings deleted file mode 100644 index 306f32a26..000000000 --- a/services/FilterLists.sln.DotSettings +++ /dev/null @@ -1,7 +0,0 @@ - - True - True - True - True - True - True \ No newline at end of file