From 4519fcddf8150f294771d9f97ed9e4f1a530527e Mon Sep 17 00:00:00 2001 From: 0GiS0 Date: Thu, 8 Feb 2024 15:29:59 +0100 Subject: [PATCH] Update OpenTelemetry configuration and SQL Server connection string --- Program.cs | 6 ++++-- appsettings.Development.json | 11 ++--------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Program.cs b/Program.cs index 1e1b624..0708001 100644 --- a/Program.cs +++ b/Program.cs @@ -24,13 +24,15 @@ *********** https://grafana.com/grafana/dashboards/17706-asp-net-otel-metrics/ ****************** ************************************************************************************************/ +string serviceName = builder.Configuration["OTEL_SERVICE_NAME"] ?? "tour_of_heroes_api"; + builder.Logging.AddOpenTelemetry(options => { options.IncludeScopes = true; options.IncludeFormattedMessage = true; var resourceBuilder = ResourceBuilder.CreateDefault(); - resourceBuilder.AddService(builder.Configuration["OTEL_SERVICE_NAME"]); + resourceBuilder.AddService(serviceName); options.SetResourceBuilder(resourceBuilder); // options.AddConsoleExporter(); @@ -42,7 +44,7 @@ builder.Services.AddOpenTelemetry() // .UseAzureMonitor() //https://learn.microsoft.com/es-es/azure/azure-monitor/app/opentelemetry-configuration?tabs=aspnetcore -.ConfigureResource(resource => resource.AddService(builder.Configuration["OTEL_SERVICE_NAME"])) +.ConfigureResource(resource => resource.AddService(serviceName)) .WithTracing(tracing => { tracing.AddAspNetCoreInstrumentation(); diff --git a/appsettings.Development.json b/appsettings.Development.json index 2355bdf..a336f98 100644 --- a/appsettings.Development.json +++ b/appsettings.Development.json @@ -1,6 +1,6 @@ { "ConnectionStrings": { - "DefaultConnection": "" + "DefaultConnection": "Server=localhost,1433;Initial Catalog=heroes;Persist Security Info=False;User ID=sa;Password=Password1!;Encrypt=False" }, "Logging": { "LogLevel": { @@ -13,12 +13,5 @@ "Microsoft.EntityFrameworkCore": "Warning" } }, - "AllowedHosts": "*", - "Kestrel": { - "Endpoints": { - "Http": { - "Url": "http://*:5010" - } - } - } + "AllowedHosts": "*" }