refactor(telemetry.serilog): review fixes (thread-safe redactor, bootstrap logger, minlevel ordering, test coverage)

This commit is contained in:
Joseph Doherty
2026-06-01 07:48:57 -04:00
parent 37fb84f477
commit f1240c0bd4
7 changed files with 140 additions and 48 deletions
@@ -42,11 +42,16 @@ public sealed class TraceContextEnricherTests
Assert.NotNull(activity);
Assert.NotNull(Activity.Current);
// Capture IDs before the log call so assertions are not sensitive to activity
// lifecycle — Activity.Current may differ after the log call returns.
var expectedTraceId = activity.TraceId.ToString();
var expectedSpanId = activity.SpanId.ToString();
logger.Information("traced");
var logEvent = Assert.Single(sink.LogEvents);
Assert.Equal(Activity.Current!.TraceId.ToString(), ScalarOrNull(logEvent, "trace_id"));
Assert.Equal(Activity.Current!.SpanId.ToString(), ScalarOrNull(logEvent, "span_id"));
Assert.Equal(expectedTraceId, ScalarOrNull(logEvent, "trace_id"));
Assert.Equal(expectedSpanId, ScalarOrNull(logEvent, "span_id"));
}
[Fact]