fix(telemetry): redact after ConfigureLogger enrichers, keep colliding dictionary keys, require http(s) OTLP endpoint and validate the options overload; bump 0.2.1 (scadaproj#48)

Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV
This commit is contained in:
Joseph Doherty
2026-11-09 14:57:48 -05:00
parent 5bf2f2caf1
commit 1786bab0a0
12 changed files with 182 additions and 25 deletions
@@ -72,7 +72,7 @@ internal static class ZbSerilogConfig
if (serviceProvider is not null)
{
enrich.With(new RedactionEnricher(serviceProvider));
ApplyRedaction(loggerConfiguration, serviceProvider);
}
ApplyOpenTelemetryExport(loggerConfiguration, options);
@@ -80,6 +80,16 @@ internal static class ZbSerilogConfig
return loggerConfiguration;
}
/// <summary>
/// Registers the <see cref="RedactionEnricher"/>. Must be the LAST enricher registered so that
/// every other enricher (including ones a host adds through <c>ZbSerilogOptions.ConfigureLogger</c>)
/// has stamped its properties before redaction runs.
/// </summary>
/// <param name="loggerConfiguration">The Serilog configuration.</param>
/// <param name="serviceProvider">Provider used to lazily resolve <c>ILogRedactor</c>.</param>
internal static void ApplyRedaction(LoggerConfiguration loggerConfiguration, IServiceProvider serviceProvider) =>
loggerConfiguration.Enrich.With(new RedactionEnricher(serviceProvider));
/// <summary>
/// Adds a <c>WriteTo.OpenTelemetry</c> log sink when an OTLP exporter is explicitly
/// selected (<see cref="ZbTelemetryOptions.Exporter"/> = <see cref="ZbExporter.Otlp"/>).