Skip to content

Commit

Permalink
Fixed spelling for IncludeActivityIdsWithBeginScope (#534)
Browse files Browse the repository at this point in the history
  • Loading branch information
snakefoot authored Sep 23, 2021
1 parent 3db30df commit 039f13a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private IDisposable CaptureScopeProperties(IReadOnlyList<KeyValuePair<string, ob
{
scopePropertyList = ExcludeOriginalFormatProperty(scopePropertyList);
}
else if (_options.IncludeActivtyIdsWithBeginScope && "RequestId".Equals(scopePropertyList[0].Key))
else if (_options.IncludeActivityIdsWithBeginScope && "RequestId".Equals(scopePropertyList[0].Key))
{
scopePropertyList = IncludeActivityIdsProperties(scopePropertyList);
}
Expand Down
24 changes: 20 additions & 4 deletions src/NLog.Extensions.Logging/Logging/NLogProviderOptions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace NLog.Extensions.Logging
using System;

namespace NLog.Extensions.Logging
{
/// <summary>
/// Options for logging to NLog with
Expand Down Expand Up @@ -47,14 +49,28 @@ public class NLogProviderOptions
/// <summary>
/// Automatically include <see cref="System.Diagnostics.Activity.SpanId"/>, <see cref="System.Diagnostics.Activity.TraceId"/> and <see cref="System.Diagnostics.Activity.ParentId"/>
/// </summary>
/// <remarks>For Net5.0 where these properties are no longer included by default for performance reasons</remarks>
/// <remarks>
/// Intended for Net5.0 where these properties are no longer included by default for performance reasons
///
/// Consider using <a href="https://www.nuget.org/packages/NLog.DiagnosticSource/">${activity}</a> as alternative
/// </remarks>
#else
/// <summary>
/// Automatically include Activity.SpanId, Activity.TraceId and Activity.ParentId.
/// </summary>
/// <remarks>For Net5.0 where these properties are no longer included by default for performance reasons</remarks>
/// <remarks>
/// Intended for Net5.0 where these properties are no longer included by default for performance reasons
///
/// Consider using <a href="https://www.nuget.org/packages/NLog.DiagnosticSource/">${activity}</a> as alternative
/// </remarks>
#endif
public bool IncludeActivtyIdsWithBeginScope { get; set; }
public bool IncludeActivityIdsWithBeginScope { get; set; }

/// <summary>
/// See <see cref="IncludeActivityIdsWithBeginScope"/> for documentation
/// </summary>
[Obsolete("Fixed spelling, so use IncludeActivityIdsWithBeginScope instead. Marked obsolete with NLog 5.0")]
public bool IncludeActivtyIdsWithBeginScope { get => IncludeActivityIdsWithBeginScope; set => IncludeActivityIdsWithBeginScope = value; }

/// <summary>
/// Resets the default Microsoft LoggerFactory Filter for the <see cref="NLogLoggerProvider"/>, and instead only uses NLog LoggingRules.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ public void AddNLog_LoggerFactory_LogInfoWithEventId_ShouldLogToNLogWithEventId(

#if NET5_0
[Fact]
public void AddNLog_LoggerFactory_IncludeActivtyIdsWithBeginScope()
public void AddNLog_LoggerFactory_IncludeActivityIdsWithBeginScope()
{
// Arrange
var loggerFactory = LoggerFactory.Create(builder => builder.AddNLog(new NLogProviderOptions { IncludeActivtyIdsWithBeginScope = true }));
var loggerFactory = LoggerFactory.Create(builder => builder.AddNLog(new NLogProviderOptions { IncludeActivityIdsWithBeginScope = true }));
var config = CreateConfigWithMemoryTarget(out var memoryTarget, $"${{scopeproperty:ParentId}} - ${{message}}");

// Act
LogManager.Configuration = config;
var logger = loggerFactory.CreateLogger(nameof(AddNLog_LoggerFactory_IncludeActivtyIdsWithBeginScope));
var logger = loggerFactory.CreateLogger(nameof(AddNLog_LoggerFactory_IncludeActivityIdsWithBeginScope));
var activity = new System.Diagnostics.Activity("TestActivity").SetParentId("42").Start();
var scopeProperties = new Dictionary<string, object> { { "RequestId", "123" }, { "RequestPath", "Unknown" } };
using (logger.BeginScope(scopeProperties.ToList()))
Expand Down

0 comments on commit 039f13a

Please sign in to comment.