-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added NLogProviderOptions.IncludeActivtyIdsWithBeginScope
- Loading branch information
Showing
5 changed files
with
146 additions
and
6 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
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#if NET5_0 | ||
|
||
using System.Diagnostics; | ||
|
||
namespace NLog.Extensions.Logging | ||
{ | ||
/// <summary> | ||
/// Helpers for getting the right values from Activity no matter the format (w3c or hierarchical) | ||
/// </summary> | ||
internal static class ActivityExtensions | ||
{ | ||
public static string GetSpanId(this Activity activity) | ||
{ | ||
return activity.IdFormat switch | ||
{ | ||
ActivityIdFormat.Hierarchical => activity.Id, | ||
ActivityIdFormat.W3C => activity.SpanId.ToHexString(), | ||
_ => null, | ||
} ?? string.Empty; | ||
} | ||
|
||
public static string GetTraceId(this Activity activity) | ||
{ | ||
return activity.IdFormat switch | ||
{ | ||
ActivityIdFormat.Hierarchical => activity.RootId, | ||
ActivityIdFormat.W3C => activity.TraceId.ToHexString(), | ||
_ => null, | ||
} ?? string.Empty; | ||
} | ||
|
||
public static string GetParentId(this Activity activity) | ||
{ | ||
return activity.IdFormat switch | ||
{ | ||
ActivityIdFormat.Hierarchical => activity.ParentId, | ||
ActivityIdFormat.W3C => activity.ParentSpanId.ToHexString(), | ||
_ => null, | ||
} ?? string.Empty; | ||
} | ||
} | ||
} | ||
|
||
#endif |
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
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