From 90b5a037b5753cc7052651e2aad17b2a924f8bdf Mon Sep 17 00:00:00 2001 From: nd Date: Sat, 24 Aug 2024 11:20:11 +0700 Subject: [PATCH] Remove Aspire projects --- src/wan24-AutoDiscover.AppHost/Program.cs | 7 -- .../appsettings.Development.json | 8 -- .../appsettings.json | 9 -- .../wan24-AutoDiscover.AppHost.csproj | 20 --- .../Extensions.cs | 118 ------------------ .../wan24-AutoDiscover.ServiceDefaults.csproj | 25 ---- 6 files changed, 187 deletions(-) delete mode 100644 src/wan24-AutoDiscover.AppHost/Program.cs delete mode 100644 src/wan24-AutoDiscover.AppHost/appsettings.Development.json delete mode 100644 src/wan24-AutoDiscover.AppHost/appsettings.json delete mode 100644 src/wan24-AutoDiscover.AppHost/wan24-AutoDiscover.AppHost.csproj delete mode 100644 src/wan24-AutoDiscover.ServiceDefaults/Extensions.cs delete mode 100644 src/wan24-AutoDiscover.ServiceDefaults/wan24-AutoDiscover.ServiceDefaults.csproj diff --git a/src/wan24-AutoDiscover.AppHost/Program.cs b/src/wan24-AutoDiscover.AppHost/Program.cs deleted file mode 100644 index b91aa6e..0000000 --- a/src/wan24-AutoDiscover.AppHost/Program.cs +++ /dev/null @@ -1,7 +0,0 @@ -using Aspire.Hosting; - -var builder = DistributedApplication.CreateBuilder(args); - -builder.AddProject("wan24-autodiscover"); - -builder.Build().Run(); diff --git a/src/wan24-AutoDiscover.AppHost/appsettings.Development.json b/src/wan24-AutoDiscover.AppHost/appsettings.Development.json deleted file mode 100644 index 0c208ae..0000000 --- a/src/wan24-AutoDiscover.AppHost/appsettings.Development.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - } -} diff --git a/src/wan24-AutoDiscover.AppHost/appsettings.json b/src/wan24-AutoDiscover.AppHost/appsettings.json deleted file mode 100644 index 31c092a..0000000 --- a/src/wan24-AutoDiscover.AppHost/appsettings.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning", - "Aspire.Hosting.Dcp": "Warning" - } - } -} diff --git a/src/wan24-AutoDiscover.AppHost/wan24-AutoDiscover.AppHost.csproj b/src/wan24-AutoDiscover.AppHost/wan24-AutoDiscover.AppHost.csproj deleted file mode 100644 index 2002466..0000000 --- a/src/wan24-AutoDiscover.AppHost/wan24-AutoDiscover.AppHost.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - Exe - net8.0 - enable - enable - true - Debug;Release;Trunk - - - - - - - - - - - diff --git a/src/wan24-AutoDiscover.ServiceDefaults/Extensions.cs b/src/wan24-AutoDiscover.ServiceDefaults/Extensions.cs deleted file mode 100644 index f444496..0000000 --- a/src/wan24-AutoDiscover.ServiceDefaults/Extensions.cs +++ /dev/null @@ -1,118 +0,0 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Diagnostics.HealthChecks; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Diagnostics.HealthChecks; -using Microsoft.Extensions.Logging; -using OpenTelemetry.Logs; -using OpenTelemetry.Metrics; -using OpenTelemetry.Trace; - -namespace Microsoft.Extensions.Hosting; - -public static class Extensions -{ - public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBuilder builder) - { - builder.ConfigureOpenTelemetry(); - - builder.AddDefaultHealthChecks(); - - builder.Services.AddServiceDiscovery(); - - builder.Services.ConfigureHttpClientDefaults(http => - { - // Turn on resilience by default - http.AddStandardResilienceHandler(); - - // Turn on service discovery by default - http.UseServiceDiscovery(); - }); - - return builder; - } - - public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicationBuilder builder) - { - builder.Logging.AddOpenTelemetry(logging => - { - logging.IncludeFormattedMessage = true; - logging.IncludeScopes = true; - }); - - builder.Services.AddOpenTelemetry() - .WithMetrics(metrics => - { - metrics.AddAspNetCoreInstrumentation() - .AddHttpClientInstrumentation() - .AddProcessInstrumentation() - .AddRuntimeInstrumentation(); - }) - .WithTracing(tracing => - { - if (builder.Environment.IsDevelopment()) - { - // We want to view all traces in development - tracing.SetSampler(new AlwaysOnSampler()); - } - - tracing.AddAspNetCoreInstrumentation() - .AddGrpcClientInstrumentation() - .AddHttpClientInstrumentation(); - }); - - builder.AddOpenTelemetryExporters(); - - return builder; - } - - private static IHostApplicationBuilder AddOpenTelemetryExporters(this IHostApplicationBuilder builder) - { - var useOtlpExporter = !string.IsNullOrWhiteSpace(builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"]); - - if (useOtlpExporter) - { - builder.Services.Configure(logging => logging.AddOtlpExporter()); - builder.Services.ConfigureOpenTelemetryMeterProvider(metrics => metrics.AddOtlpExporter()); - builder.Services.ConfigureOpenTelemetryTracerProvider(tracing => tracing.AddOtlpExporter()); - } - - // Uncomment the following lines to enable the Prometheus exporter (requires the OpenTelemetry.Exporter.Prometheus.AspNetCore package) - // builder.Services.AddOpenTelemetry() - // .WithMetrics(metrics => metrics.AddPrometheusExporter()); - - // 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) - { - builder.Services.AddHealthChecks() - // Add a default liveness check to ensure app is responsive - .AddCheck("self", () => HealthCheckResult.Healthy(), ["live"]); - - return builder; - } - - public static WebApplication MapDefaultEndpoints(this WebApplication app) - { - // Uncomment the following line to enable the Prometheus endpoint (requires the OpenTelemetry.Exporter.Prometheus.AspNetCore package) - // app.MapPrometheusScrapingEndpoint(); - - // 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 - { - Predicate = r => r.Tags.Contains("live") - }); - - return app; - } -} diff --git a/src/wan24-AutoDiscover.ServiceDefaults/wan24-AutoDiscover.ServiceDefaults.csproj b/src/wan24-AutoDiscover.ServiceDefaults/wan24-AutoDiscover.ServiceDefaults.csproj deleted file mode 100644 index 2567583..0000000 --- a/src/wan24-AutoDiscover.ServiceDefaults/wan24-AutoDiscover.ServiceDefaults.csproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - net8.0 - enable - enable - true - Debug;Release;Trunk - - - - - - - - - - - - - - - - -