From e686eb482b9b02b63a85d167ff90fecab4fac2dd Mon Sep 17 00:00:00 2001 From: Henrik Lau Eriksson Date: Sat, 23 Mar 2024 22:35:19 +0100 Subject: [PATCH] :arrow_up: --- .../Markupolation.Sample.Api.csproj | 2 +- samples/Markupolation.Sample.Api/Program.cs | 2 ++ .../Properties/launchSettings.json | 2 +- .../Markupolation.Sample.ApiGateway.csproj | 4 ++-- ...Markupolation.Sample.Aspire.AppHost.csproj | 2 +- .../Properties/launchSettings.json | 2 +- .../Extensions.cs | 21 +++++++++---------- ...ation.Sample.Aspire.ServiceDefaults.csproj | 14 ++++++------- .../Markupolation.Sample.Htmx.csproj | 4 ++-- .../Properties/launchSettings.json | 2 +- 10 files changed, 28 insertions(+), 27 deletions(-) diff --git a/samples/Markupolation.Sample.Api/Markupolation.Sample.Api.csproj b/samples/Markupolation.Sample.Api/Markupolation.Sample.Api.csproj index f6fc152..08c1117 100644 --- a/samples/Markupolation.Sample.Api/Markupolation.Sample.Api.csproj +++ b/samples/Markupolation.Sample.Api/Markupolation.Sample.Api.csproj @@ -2,8 +2,8 @@ net8.0 - enable enable + enable false diff --git a/samples/Markupolation.Sample.Api/Program.cs b/samples/Markupolation.Sample.Api/Program.cs index 871dd98..243be32 100644 --- a/samples/Markupolation.Sample.Api/Program.cs +++ b/samples/Markupolation.Sample.Api/Program.cs @@ -2,10 +2,12 @@ var builder = WebApplication.CreateBuilder(args); builder.Services.AddCors(options => options.AddDefaultPolicy(policy => policy.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader())); +builder.Services.AddProblemDetails(); builder.AddServiceDefaults(); var app = builder.Build(); app.UseCors(); +app.UseExceptionHandler(); app.UseHttpsRedirection(); app.MapDefaultEndpoints(); diff --git a/samples/Markupolation.Sample.Api/Properties/launchSettings.json b/samples/Markupolation.Sample.Api/Properties/launchSettings.json index 98bb96d..ff4f6d7 100644 --- a/samples/Markupolation.Sample.Api/Properties/launchSettings.json +++ b/samples/Markupolation.Sample.Api/Properties/launchSettings.json @@ -1,5 +1,5 @@ { - "$schema": "http://json.schemastore.org/launchsettings.json", + "$schema": "https://json.schemastore.org/launchsettings.json", "profiles": { "Markupolation.Sample.Api": { "commandName": "Project", diff --git a/samples/Markupolation.Sample.ApiGateway/Markupolation.Sample.ApiGateway.csproj b/samples/Markupolation.Sample.ApiGateway/Markupolation.Sample.ApiGateway.csproj index 6b80848..f0a5e33 100644 --- a/samples/Markupolation.Sample.ApiGateway/Markupolation.Sample.ApiGateway.csproj +++ b/samples/Markupolation.Sample.ApiGateway/Markupolation.Sample.ApiGateway.csproj @@ -2,12 +2,12 @@ net8.0 - enable enable + enable - + diff --git a/samples/Markupolation.Sample.Aspire.AppHost/Markupolation.Sample.Aspire.AppHost.csproj b/samples/Markupolation.Sample.Aspire.AppHost/Markupolation.Sample.Aspire.AppHost.csproj index 05986c5..04c78b7 100644 --- a/samples/Markupolation.Sample.Aspire.AppHost/Markupolation.Sample.Aspire.AppHost.csproj +++ b/samples/Markupolation.Sample.Aspire.AppHost/Markupolation.Sample.Aspire.AppHost.csproj @@ -9,7 +9,7 @@ - + diff --git a/samples/Markupolation.Sample.Aspire.AppHost/Properties/launchSettings.json b/samples/Markupolation.Sample.Aspire.AppHost/Properties/launchSettings.json index c43ba50..73025d9 100644 --- a/samples/Markupolation.Sample.Aspire.AppHost/Properties/launchSettings.json +++ b/samples/Markupolation.Sample.Aspire.AppHost/Properties/launchSettings.json @@ -1,5 +1,5 @@ { - "$schema": "http://json.schemastore.org/launchsettings.json", + "$schema": "https://json.schemastore.org/launchsettings.json", "profiles": { "http": { "commandName": "Project", diff --git a/samples/Markupolation.Sample.Aspire.ServiceDefaults/Extensions.cs b/samples/Markupolation.Sample.Aspire.ServiceDefaults/Extensions.cs index c59308d..f444496 100644 --- a/samples/Markupolation.Sample.Aspire.ServiceDefaults/Extensions.cs +++ b/samples/Markupolation.Sample.Aspire.ServiceDefaults/Extensions.cs @@ -42,8 +42,10 @@ public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicati builder.Services.AddOpenTelemetry() .WithMetrics(metrics => { - metrics.AddRuntimeInstrumentation() - .AddBuiltInMeters(); + metrics.AddAspNetCoreInstrumentation() + .AddHttpClientInstrumentation() + .AddProcessInstrumentation() + .AddRuntimeInstrumentation(); }) .WithTracing(tracing => { @@ -78,9 +80,12 @@ private static IHostApplicationBuilder AddOpenTelemetryExporters(this IHostAppli // builder.Services.AddOpenTelemetry() // .WithMetrics(metrics => metrics.AddPrometheusExporter()); - // Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.Exporter package) - // builder.Services.AddOpenTelemetry() - // .UseAzureMonitor(); + // 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; } @@ -110,10 +115,4 @@ public static WebApplication MapDefaultEndpoints(this WebApplication app) return app; } - - private static MeterProviderBuilder AddBuiltInMeters(this MeterProviderBuilder meterProviderBuilder) => - meterProviderBuilder.AddMeter( - "Microsoft.AspNetCore.Hosting", - "Microsoft.AspNetCore.Server.Kestrel", - "System.Net.Http"); } diff --git a/samples/Markupolation.Sample.Aspire.ServiceDefaults/Markupolation.Sample.Aspire.ServiceDefaults.csproj b/samples/Markupolation.Sample.Aspire.ServiceDefaults/Markupolation.Sample.Aspire.ServiceDefaults.csproj index fc4f398..80f9ee9 100644 --- a/samples/Markupolation.Sample.Aspire.ServiceDefaults/Markupolation.Sample.Aspire.ServiceDefaults.csproj +++ b/samples/Markupolation.Sample.Aspire.ServiceDefaults/Markupolation.Sample.Aspire.ServiceDefaults.csproj @@ -1,7 +1,6 @@ - Library net8.0 enable enable @@ -11,14 +10,15 @@ - - + + - - - - + + + + + diff --git a/samples/Markupolation.Sample.Htmx/Markupolation.Sample.Htmx.csproj b/samples/Markupolation.Sample.Htmx/Markupolation.Sample.Htmx.csproj index 6b80848..f0a5e33 100644 --- a/samples/Markupolation.Sample.Htmx/Markupolation.Sample.Htmx.csproj +++ b/samples/Markupolation.Sample.Htmx/Markupolation.Sample.Htmx.csproj @@ -2,12 +2,12 @@ net8.0 - enable enable + enable - + diff --git a/samples/Markupolation.Sample.Htmx/Properties/launchSettings.json b/samples/Markupolation.Sample.Htmx/Properties/launchSettings.json index 572c17f..84fb060 100644 --- a/samples/Markupolation.Sample.Htmx/Properties/launchSettings.json +++ b/samples/Markupolation.Sample.Htmx/Properties/launchSettings.json @@ -1,5 +1,5 @@ { - "$schema": "http://json.schemastore.org/launchsettings.json", + "$schema": "https://json.schemastore.org/launchsettings.json", "profiles": { "Markupolation.Sample.Htmx": { "commandName": "Project",