diff --git a/services/Directory/FilterLists.Directory.Api/FilterLists.Directory.Api.csproj b/services/Directory/FilterLists.Directory.Api/FilterLists.Directory.Api.csproj
index 16645ea8c..52039f3e2 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
- Recommended
+ All
@@ -23,12 +23,12 @@
-
-
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
diff --git a/services/FilterLists.AppHost/Program.cs b/services/FilterLists.AppHost/AppHost.cs
similarity index 100%
rename from services/FilterLists.AppHost/Program.cs
rename to services/FilterLists.AppHost/AppHost.cs
diff --git a/services/FilterLists.AppHost/FilterLists.AppHost.csproj b/services/FilterLists.AppHost/FilterLists.AppHost.csproj
index f7c038c5c..b0b6f732e 100644
--- a/services/FilterLists.AppHost/FilterLists.AppHost.csproj
+++ b/services/FilterLists.AppHost/FilterLists.AppHost.csproj
@@ -1,15 +1,14 @@
-
+
Exe
net9.0
enable
enable
- true
c7967ef0-ced7-4e18-8282-7302b3c0002b
- Recommended
+ All
@@ -17,8 +16,8 @@
-
-
+
+
\ No newline at end of file
diff --git a/services/FilterLists.AppHost/Properties/launchSettings.json b/services/FilterLists.AppHost/Properties/launchSettings.json
index 8db094ab5..ce19f7aa3 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:17246;http://localhost:15280",
+ "applicationUrl": "https://localhost:17145;http://localhost:15172",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
- "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21069",
- "DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22035"
+ "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21129",
+ "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22052"
}
},
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
- "applicationUrl": "http://localhost:15280",
+ "applicationUrl": "http://localhost:15172",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
- "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19157",
- "DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20152"
+ "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19265",
+ "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20065"
}
}
}
diff --git a/services/FilterLists.ServiceDefaults/Extensions.cs b/services/FilterLists.ServiceDefaults/Extensions.cs
index 735832d0a..7c8919c33 100644
--- a/services/FilterLists.ServiceDefaults/Extensions.cs
+++ b/services/FilterLists.ServiceDefaults/Extensions.cs
@@ -8,8 +8,7 @@
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;
-// ReSharper disable All
-
+// ReSharper disable once CheckNamespace
namespace Microsoft.Extensions.Hosting;
// Adds common .NET Aspire services: service discovery, resilience, health checks, and OpenTelemetry.
@@ -17,7 +16,10 @@ namespace Microsoft.Extensions.Hosting;
// To learn more about using this project, see https://aka.ms/dotnet/aspire/service-defaults
public static class Extensions
{
- public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBuilder builder)
+ private const string HealthEndpointPath = "/health";
+ private const string AlivenessEndpointPath = "/alive";
+
+ public static TBuilder AddServiceDefaults(this TBuilder builder) where TBuilder : IHostApplicationBuilder
{
builder.ConfigureOpenTelemetry();
@@ -34,10 +36,16 @@ public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBu
http.AddServiceDiscovery();
});
+ // Uncomment the following to restrict the allowed schemes for service discovery.
+ // builder.Services.Configure(options =>
+ // {
+ // options.AllowedSchemes = ["https"];
+ // });
+
return builder;
}
- public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicationBuilder builder)
+ private static void ConfigureOpenTelemetry(this TBuilder builder) where TBuilder : IHostApplicationBuilder
{
builder.Logging.AddOpenTelemetry(logging =>
{
@@ -54,55 +62,60 @@ public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicati
})
.WithTracing(tracing =>
{
- tracing.AddAspNetCoreInstrumentation()
+ 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)
+ )
// Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package)
//.AddGrpcClientInstrumentation()
.AddHttpClientInstrumentation();
});
builder.AddOpenTelemetryExporters();
-
- return builder;
}
- private static IHostApplicationBuilder AddOpenTelemetryExporters(this IHostApplicationBuilder builder)
+ private static void AddOpenTelemetryExporters(this TBuilder builder)
+ where TBuilder : IHostApplicationBuilder
{
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;
}
- public static IHostApplicationBuilder AddDefaultHealthChecks(this IHostApplicationBuilder builder)
+ private static void AddDefaultHealthChecks(this TBuilder builder) where TBuilder : IHostApplicationBuilder
{
builder.Services.AddHealthChecks()
- // Add a default liveness check to ensure app is responsive
+ // Add a default liveness check to ensure the app is responsive
.AddCheck("self", () => HealthCheckResult.Healthy(), ["live"]);
-
- return builder;
}
public static WebApplication MapDefaultEndpoints(this WebApplication app)
{
- // 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 app to be considered alive
- app.MapHealthChecks("/alive", new HealthCheckOptions
+ // 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
{
- Predicate = r => r.Tags.Contains("live")
- });
+ // All health checks must pass for the app to be considered ready to accept traffic after starting
+ app.MapHealthChecks(HealthEndpointPath);
+
+ // 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")
+ });
+ }
return app;
}
diff --git a/services/FilterLists.ServiceDefaults/FilterLists.ServiceDefaults.csproj b/services/FilterLists.ServiceDefaults/FilterLists.ServiceDefaults.csproj
index 6caa33700..345a81c74 100644
--- a/services/FilterLists.ServiceDefaults/FilterLists.ServiceDefaults.csproj
+++ b/services/FilterLists.ServiceDefaults/FilterLists.ServiceDefaults.csproj
@@ -5,15 +5,15 @@
enable
enable
true
- Recommended
+ All
-
-
+
+
diff --git a/services/FilterLists.sln.DotSettings b/services/FilterLists.sln.DotSettings
new file mode 100644
index 000000000..306f32a26
--- /dev/null
+++ b/services/FilterLists.sln.DotSettings
@@ -0,0 +1,7 @@
+
+ True
+ True
+ True
+ True
+ True
+ True
\ No newline at end of file