Skip to content

Commit

Permalink
Merge pull request #24 from osstotalsoft/feature/correlation-fix
Browse files Browse the repository at this point in the history
Replaced existing CorrelationId in Serilog enricher
  • Loading branch information
fraliv13 committed Sep 9, 2019
2 parents f2f8861 + 79a8096 commit 586bdb2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static IApplicationBuilder UseCorrelation(this IApplicationBuilder app)
}
var correlationId =
ExtractGuid(context.Request.Headers["x-correlation-id"]) ??
ExtractGuid(context.Request.Headers[HttpRequestHeaders.CorrelationId]) ??
ExtractGuid(context.Request.Query["correlationId"]);
using (CorrelationManager.NewCorrelationId(correlationId))
Expand Down
7 changes: 7 additions & 0 deletions src/Correlation/NBB.Correlation.AspNet/HttpRequestHeaders.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace NBB.Correlation.AspNet
{
public static class HttpRequestHeaders
{
public const string CorrelationId = "x-correlation-id";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class CorrelationLogEventEnricher : ILogEventEnricher

public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
{
logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty("CorrelationId", CorrelationManager.GetCorrelationId()));
logEvent.AddOrUpdateProperty(propertyFactory.CreateProperty("CorrelationId", CorrelationManager.GetCorrelationId()));
}
}
}

0 comments on commit 586bdb2

Please sign in to comment.