-
Notifications
You must be signed in to change notification settings - Fork 563
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d0b860a
commit a5871df
Showing
10 changed files
with
38 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,8 @@ | ||
/* | ||
* https://github.com/serilog/serilog-aspnetcore/issues/207 | ||
* | ||
*/ | ||
using System.Diagnostics; | ||
|
||
using Serilog.Core; | ||
using Serilog.Events; | ||
using System.Diagnostics; | ||
namespace ClassifiedAds.CrossCuttingConcerns.Logging; | ||
|
||
namespace ClassifiedAds.Infrastructure.Logging; | ||
|
||
public class ActivityEnricher : ILogEventEnricher | ||
{ | ||
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) | ||
{ | ||
var activity = Activity.Current; | ||
|
||
if (activity == null) | ||
{ | ||
return; | ||
} | ||
|
||
logEvent.AddPropertyIfAbsent(new LogEventProperty("SpanId", new ScalarValue(activity.GetSpanId()))); | ||
logEvent.AddPropertyIfAbsent(new LogEventProperty("TraceId", new ScalarValue(activity.GetTraceId()))); | ||
logEvent.AddPropertyIfAbsent(new LogEventProperty("ParentId", new ScalarValue(activity.GetParentId()))); | ||
} | ||
} | ||
|
||
internal static class ActivityExtensions | ||
public static class ActivityExtensions | ||
{ | ||
public static string GetSpanId(this Activity activity) | ||
{ | ||
|
@@ -57,4 +33,17 @@ public static string GetParentId(this Activity activity) | |
_ => null, | ||
} ?? string.Empty; | ||
Check warning on line 34 in src/Microservices/Common/ClassifiedAds.CrossCuttingConcerns/Logging/ActivityExtensions.cs GitHub Actions / build
|
||
} | ||
|
||
public static Activity StartNew(string name, string parentId = null) | ||
{ | ||
var activity = new Activity(name); | ||
|
||
if (!string.IsNullOrEmpty(parentId)) | ||
{ | ||
activity.SetParentId(parentId); | ||
} | ||
|
||
activity.Start(); | ||
return activity; | ||
} | ||
} |
5 changes: 0 additions & 5 deletions
5
src/Microservices/Common/ClassifiedAds.CrossCuttingConcerns/Logging/ILogger.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...vices/Common/ClassifiedAds.Infrastructure/Web/ExceptionHandlers/GlobalExceptionHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...es/Common/ClassifiedAds.Infrastructure/Web/Middleware/GlobalExceptionHandlerMiddleware.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,8 @@ | ||
/* | ||
* https://github.com/serilog/serilog-aspnetcore/issues/207 | ||
* | ||
*/ | ||
using System.Diagnostics; | ||
|
||
using Serilog.Core; | ||
using Serilog.Events; | ||
using System.Diagnostics; | ||
namespace ClassifiedAds.CrossCuttingConcerns.Logging; | ||
|
||
namespace ClassifiedAds.Infrastructure.Logging; | ||
|
||
public class ActivityEnricher : ILogEventEnricher | ||
{ | ||
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) | ||
{ | ||
var activity = Activity.Current; | ||
|
||
if (activity == null) | ||
{ | ||
return; | ||
} | ||
|
||
logEvent.AddPropertyIfAbsent(new LogEventProperty("SpanId", new ScalarValue(activity.GetSpanId()))); | ||
logEvent.AddPropertyIfAbsent(new LogEventProperty("TraceId", new ScalarValue(activity.GetTraceId()))); | ||
logEvent.AddPropertyIfAbsent(new LogEventProperty("ParentId", new ScalarValue(activity.GetParentId()))); | ||
} | ||
} | ||
|
||
internal static class ActivityExtensions | ||
public static class ActivityExtensions | ||
{ | ||
public static string GetSpanId(this Activity activity) | ||
{ | ||
|
@@ -57,4 +33,17 @@ public static string GetParentId(this Activity activity) | |
_ => null, | ||
} ?? string.Empty; | ||
Check warning on line 34 in src/ModularMonolith/ClassifiedAds.CrossCuttingConcerns/Logging/ActivityExtensions.cs GitHub Actions / build
|
||
} | ||
|
||
public static Activity StartNew(string name, string parentId = null) | ||
{ | ||
var activity = new Activity(name); | ||
|
||
if (!string.IsNullOrEmpty(parentId)) | ||
{ | ||
activity.SetParentId(parentId); | ||
} | ||
|
||
activity.Start(); | ||
return activity; | ||
} | ||
} |
5 changes: 0 additions & 5 deletions
5
src/ModularMonolith/ClassifiedAds.CrossCuttingConcerns/Logging/ILogger.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ularMonolith/ClassifiedAds.Infrastructure/Web/ExceptionHandlers/GlobalExceptionHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...rMonolith/ClassifiedAds.Infrastructure/Web/Middleware/GlobalExceptionHandlerMiddleware.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters