Fix OTel wiring to match working Auth implementation
Three corrections vs Auth project: - Replace AddOtlpExporter() (traces only) with UseOtlpExporter() so both traces and logs are exported via OTLP - Remove redundant .WithLogging() call; builder.Logging.AddOpenTelemetry() is sufficient on its own - Pass OTEL_EXPORTER_OTLP_ENDPOINT/PROTOCOL through from host env vars instead of hardcoding the collector URL Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,7 @@ using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using OpenTelemetry;
|
||||
using OpenTelemetry.Resources;
|
||||
using OpenTelemetry.Trace;
|
||||
|
||||
@@ -24,12 +25,11 @@ builder.Logging.AddOpenTelemetry(logging =>
|
||||
builder.Services.AddOpenTelemetry()
|
||||
.ConfigureResource(resource => resource
|
||||
.AddService(serviceName: "budget", serviceVersion: "1.0.0"))
|
||||
.WithLogging()
|
||||
.WithTracing(tracing => tracing
|
||||
.AddAspNetCoreInstrumentation()
|
||||
.AddHttpClientInstrumentation()
|
||||
.AddEntityFrameworkCoreInstrumentation()
|
||||
.AddOtlpExporter());
|
||||
.AddEntityFrameworkCoreInstrumentation())
|
||||
.UseOtlpExporter();
|
||||
|
||||
var connStr = builder.Configuration.GetConnectionString("DefaultConnection")
|
||||
?? $"Host={builder.Configuration["POSTGRES_HOST"] ?? "localhost"};" +
|
||||
|
||||
Reference in New Issue
Block a user