feat(obs): OpenTelemetry distributed tracing across the five .NET services (refs #123)
Each host adds AddOpenTelemetry().WithTracing with ASP.NET Core + HttpClient auto-instrumentation and an OTLP exporter to Tempo; service name + endpoint from OTEL_* env set per app service in compose. Since every cross-service call goes through a typed HttpClient, traceparent propagates for free, so a request is one connected trace (bff → domain/projection → acl → openzaak). /health is filtered out. The exporter no-ops harmlessly when Tempo is unreachable (verified: domain boots healthy with no collector). refs #123
This commit is contained in:
@@ -1,9 +1,22 @@
|
||||
using System.Text.Json;
|
||||
using EventSubscriber.Application;
|
||||
using OpenTelemetry.Resources;
|
||||
using OpenTelemetry.Trace;
|
||||
using Projection.ReadModel;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// OpenTelemetry tracing (S-16b, ADR-0023): auto-instrument the incoming NRC notification callback and
|
||||
// the outgoing ACL enrichment call, exported over OTLP to Tempo. Service name + OTLP endpoint come
|
||||
// from OTEL_* env (compose); the exporter no-ops when Tempo is unreachable.
|
||||
builder.Services.AddOpenTelemetry()
|
||||
.ConfigureResource(r => r.AddService(
|
||||
builder.Configuration["OTEL_SERVICE_NAME"] ?? builder.Environment.ApplicationName))
|
||||
.WithTracing(tracing => tracing
|
||||
.AddAspNetCoreInstrumentation(o => o.Filter = ctx => ctx.Request.Path != "/health")
|
||||
.AddHttpClientInstrumentation()
|
||||
.AddOtlpExporter());
|
||||
|
||||
var connectionString = builder.Configuration.GetConnectionString("Projection")
|
||||
?? throw new InvalidOperationException("Missing connection string 'ConnectionStrings:Projection'");
|
||||
// The exact Authorization header value Open Notificaties sends on each abonnement callback.
|
||||
|
||||
Reference in New Issue
Block a user