From d215c528c07c7919c3ac30b35d92f4e51a60523b Mon Sep 17 00:00:00 2001 From: Jose Perez Rodriguez Date: Wed, 8 May 2024 13:22:57 -0700 Subject: [PATCH] Remove Prometheus commented out code that does not work (#4096) * Remove Prometheus commented out code that does not work * Update Extensions.cs * Update Extensions.cs * Update src/Aspire.ProjectTemplates/templates/aspire-empty/AspireApplication.1.ServiceDefaults/Extensions.cs * Update Extensions.cs * Update Extensions.cs * Update Extensions.cs * Apply suggestions from code review Co-authored-by: James Newton-King * Apply suggestions from code review --------- Co-authored-by: Sam Spencer <54915162+samsp-msft@users.noreply.github.com> Co-authored-by: James Newton-King --- .../AspireApplication.1.ServiceDefaults/Extensions.cs | 10 +++------- .../templates/aspire-servicedefaults/Extensions.cs | 10 +++------- .../Extensions.cs | 10 +++------- 3 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/Aspire.ProjectTemplates/templates/aspire-empty/AspireApplication.1.ServiceDefaults/Extensions.cs b/src/Aspire.ProjectTemplates/templates/aspire-empty/AspireApplication.1.ServiceDefaults/Extensions.cs index b6e80000de..ce94dc2c43 100644 --- a/src/Aspire.ProjectTemplates/templates/aspire-empty/AspireApplication.1.ServiceDefaults/Extensions.cs +++ b/src/Aspire.ProjectTemplates/templates/aspire-empty/AspireApplication.1.ServiceDefaults/Extensions.cs @@ -9,6 +9,9 @@ namespace Microsoft.Extensions.Hosting; +// Adds common .NET Aspire services: service discovery, resilience, health checks, and OpenTelemetry. +// This project should be referenced by each service project in your solution. +// 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) @@ -68,10 +71,6 @@ private static IHostApplicationBuilder AddOpenTelemetryExporters(this IHostAppli builder.Services.AddOpenTelemetry().UseOtlpExporter(); } - // 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"])) //{ @@ -105,9 +104,6 @@ public static WebApplication MapDefaultEndpoints(this WebApplication app) { Predicate = r => r.Tags.Contains("live") }); - - // Uncomment the following line to enable the Prometheus endpoint (requires the OpenTelemetry.Exporter.Prometheus.AspNetCore package) - // app.MapPrometheusScrapingEndpoint(); } return app; diff --git a/src/Aspire.ProjectTemplates/templates/aspire-servicedefaults/Extensions.cs b/src/Aspire.ProjectTemplates/templates/aspire-servicedefaults/Extensions.cs index 134217bfdc..2a3f4e074e 100644 --- a/src/Aspire.ProjectTemplates/templates/aspire-servicedefaults/Extensions.cs +++ b/src/Aspire.ProjectTemplates/templates/aspire-servicedefaults/Extensions.cs @@ -10,6 +10,9 @@ namespace Microsoft.Extensions.Hosting; +// Adds common .NET Aspire services: service discovery, resilience, health checks, and OpenTelemetry. +// This project should be referenced by each service project in your solution. +// 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) @@ -75,10 +78,6 @@ private static IHostApplicationBuilder AddOpenTelemetryExporters(this IHostAppli builder.Services.AddOpenTelemetry().UseOtlpExporter(); } - // 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"])) //{ @@ -100,9 +99,6 @@ public static IHostApplicationBuilder AddDefaultHealthChecks(this IHostApplicati 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(); - // 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. if (app.Environment.IsDevelopment()) diff --git a/src/Aspire.ProjectTemplates/templates/aspire-starter/AspireStarterApplication.1.ServiceDefaults/Extensions.cs b/src/Aspire.ProjectTemplates/templates/aspire-starter/AspireStarterApplication.1.ServiceDefaults/Extensions.cs index 877f870b74..ce94dc2c43 100644 --- a/src/Aspire.ProjectTemplates/templates/aspire-starter/AspireStarterApplication.1.ServiceDefaults/Extensions.cs +++ b/src/Aspire.ProjectTemplates/templates/aspire-starter/AspireStarterApplication.1.ServiceDefaults/Extensions.cs @@ -9,6 +9,9 @@ namespace Microsoft.Extensions.Hosting; +// Adds common .NET Aspire services: service discovery, resilience, health checks, and OpenTelemetry. +// This project should be referenced by each service project in your solution. +// 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) @@ -68,10 +71,6 @@ private static IHostApplicationBuilder AddOpenTelemetryExporters(this IHostAppli builder.Services.AddOpenTelemetry().UseOtlpExporter(); } - // 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"])) //{ @@ -93,9 +92,6 @@ public static IHostApplicationBuilder AddDefaultHealthChecks(this IHostApplicati 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(); - // 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. if (app.Environment.IsDevelopment())