refactor(logging): correlation scope + redaction on shared ILogRedactor seam
Move the per-request correlation context and secret redaction off the MEL mechanism onto the Serilog primitives the shared bootstrap consumes. - GatewayRequestLoggingMiddlewareExtensions now pushes the correlation properties (SessionId / WorkerProcessId / CorrelationId / CommandMethod / ClientIdentity) via Serilog LogContext.PushProperty for the request lifetime and pops them on completion, replacing MEL ILogger.BeginScope. Header parsing and property names are unchanged; GatewayLogScope remains the data holder. - Add GatewayLogRedactorAdapter : ILogRedactor delegating to the existing GatewayLogRedactor policy (mxgw_ bearer tokens / credential-bearing command values), registered as a singleton so the shared RedactionEnricher masks secrets on every event. Remove the now-dead GatewayLoggerExtensions MEL helper. - Tests: add GatewayLogRedactorAdapterTests; serialize the four host-building test classes into one non-parallel collection (HostBuildingCollection) so the process-wide Serilog bootstrap logger is not frozen by two concurrent host builds racing in parallel collections. The net48/x86 worker is untouched.
This commit is contained in:
@@ -84,6 +84,8 @@ public static class GatewayApplication
|
||||
/// <c>ZB.MOM.WW.Telemetry.Serilog</c> bootstrap (<see cref="ZbSerilogExtensions.AddZbSerilog"/>).
|
||||
/// Sinks and minimum level come from the <c>Serilog</c> configuration section; identity
|
||||
/// (<c>SiteId</c>/<c>NodeRole</c>) is read from <c>MxGateway:Telemetry</c> when present.
|
||||
/// Also registers the project's <see cref="ILogRedactor"/> adapter so the shared redaction
|
||||
/// enricher masks gateway secrets on every event.
|
||||
/// </summary>
|
||||
/// <param name="builder">The web application builder being configured.</param>
|
||||
private static void ConfigureSerilog(WebApplicationBuilder builder)
|
||||
@@ -91,6 +93,8 @@ public static class GatewayApplication
|
||||
string? siteId = builder.Configuration["MxGateway:Telemetry:SiteId"];
|
||||
string? nodeRole = builder.Configuration["MxGateway:Telemetry:NodeRole"];
|
||||
|
||||
builder.Services.AddSingleton<ILogRedactor, GatewayLogRedactorAdapter>();
|
||||
|
||||
builder.AddZbSerilog(options =>
|
||||
{
|
||||
options.ServiceName = "mxgateway";
|
||||
|
||||
Reference in New Issue
Block a user