Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed IncludeActivityIdsWithBeginScope for NET8 #719

Merged
merged 1 commit into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/NLog.Extensions.Logging/Logging/ActivityExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NET6_0
#if NET5_0_OR_GREATER

using System.Diagnostics;

Expand Down
12 changes: 6 additions & 6 deletions src/NLog.Extensions.Logging/Logging/NLogBeginScopeParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,7 @@ public IDisposable ParseBeginScope<T>(T state)
}
}

#if !NET6_0
private static IReadOnlyList<KeyValuePair<string, object>> IncludeActivityIdsProperties(IReadOnlyList<KeyValuePair<string, object>> scopePropertyList)
{
return scopePropertyList; // Not supported
}
#else
#if NET5_0_OR_GREATER
private IReadOnlyList<KeyValuePair<string, object>> IncludeActivityIdsProperties(IReadOnlyList<KeyValuePair<string, object>> scopePropertyList)
{
if (_options.IncludeActivityIdsWithBeginScope && "RequestId".Equals(scopePropertyList[0].Key))
Expand Down Expand Up @@ -162,6 +157,11 @@ IEnumerator IEnumerable.GetEnumerator()
return ((IEnumerable)_originalPropertyList).GetEnumerator();
}
}
#else
private static IReadOnlyList<KeyValuePair<string, object>> IncludeActivityIdsProperties(IReadOnlyList<KeyValuePair<string, object>> scopePropertyList)
{
return scopePropertyList; // Not supported
}
#endif

public static IDisposable CaptureScopeProperties(IEnumerable scopePropertyCollection, ExtractorDictionary stateExtractor)
Expand Down
2 changes: 1 addition & 1 deletion src/NLog.Extensions.Logging/Logging/NLogProviderOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class NLogProviderOptions
/// </summary>
public bool AutoShutdown { get; set; }

#if NET6_0
#if NET5_0_OR_GREATER
/// <summary>
/// Automatically include <see cref="System.Diagnostics.Activity.SpanId"/>, <see cref="System.Diagnostics.Activity.TraceId"/> and <see cref="System.Diagnostics.Activity.ParentId"/>
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void AddNLog_LoggerFactory_LogInfoWithEventId_ShouldLogToNLogWithEventId(
AssertSingleMessage(memoryTarget, $"{expectedEventInLog} - test message with 1 arg");
}

#if NET6_0
#if NET5_0_OR_GREATER
[Fact]
public void AddNLog_LoggerFactory_IncludeActivityIdsWithBeginScope()
{
Expand Down