diff --git a/examples/AspNetCore/Examples.AspNetCore.csproj b/examples/AspNetCore/Examples.AspNetCore.csproj index a6ce0375535..d92150ac7f8 100644 --- a/examples/AspNetCore/Examples.AspNetCore.csproj +++ b/examples/AspNetCore/Examples.AspNetCore.csproj @@ -8,6 +8,7 @@ + diff --git a/examples/AspNetCore/Program.cs b/examples/AspNetCore/Program.cs index 0ee7a24c22a..a0bf9e0f3f7 100644 --- a/examples/AspNetCore/Program.cs +++ b/examples/AspNetCore/Program.cs @@ -113,13 +113,16 @@ }); // Metrics + +var metricsExporter = builder.Configuration.GetValue("UseMetricsExporter").ToLowerInvariant(); + builder.Services.AddOpenTelemetryMetrics(options => { options.ConfigureResource(configureResource) + .AddRuntimeMetrics() .AddHttpClientInstrumentation() .AddAspNetCoreInstrumentation(); - var metricsExporter = builder.Configuration.GetValue("UseMetricsExporter").ToLowerInvariant(); switch (metricsExporter) { case "prometheus": @@ -160,9 +163,7 @@ app.MapControllers(); -var metricsExporter = builder.Configuration.GetValue("UseMetricsExporter").ToLowerInvariant(); - -if (metricsExporter == "prometheus") +if (metricsExporter.Equals("prometheus", StringComparison.OrdinalIgnoreCase)) { app.UseOpenTelemetryPrometheusScrapingEndpoint(); }