diff --git a/src/Budget.Api/Budget.Api.csproj b/src/Budget.Api/Budget.Api.csproj index 48be54e..cb46c05 100644 --- a/src/Budget.Api/Budget.Api.csproj +++ b/src/Budget.Api/Budget.Api.csproj @@ -13,6 +13,11 @@ all + + + + + diff --git a/src/Budget.Api/Program.cs b/src/Budget.Api/Program.cs index 299c82e..43c9f50 100644 --- a/src/Budget.Api/Program.cs +++ b/src/Budget.Api/Program.cs @@ -10,9 +10,27 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Diagnostics.HealthChecks; using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Tokens; +using OpenTelemetry.Resources; +using OpenTelemetry.Trace; var builder = WebApplication.CreateBuilder(args); +builder.Logging.AddOpenTelemetry(logging => +{ + logging.IncludeFormattedMessage = true; + logging.IncludeScopes = true; +}); + +builder.Services.AddOpenTelemetry() + .ConfigureResource(resource => resource + .AddService(serviceName: "budget", serviceVersion: "1.0.0")) + .WithLogging() + .WithTracing(tracing => tracing + .AddAspNetCoreInstrumentation() + .AddHttpClientInstrumentation() + .AddEntityFrameworkCoreInstrumentation() + .AddOtlpExporter()); + var connStr = builder.Configuration.GetConnectionString("DefaultConnection") ?? $"Host={builder.Configuration["POSTGRES_HOST"] ?? "localhost"};" + $"Port={builder.Configuration["POSTGRES_PORT"] ?? "5432"};" +