Skip to content

Commit 00b4d74

Browse files
authored
Added Activity IsAllDataRequested whether span should be sampled / recorded (#140)
1 parent 808fbf1 commit 00b4d74

5 files changed

Lines changed: 10 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Example of `NLog.config` file that outputs span-details together with LogEvent b
7373
- TraceStateString : W3C 'tracestate' header as a string
7474
- Status : Status code of the current activity (`Ok` or `Error`). For int-value combine with `format="d"`
7575
- StatusDescription : Status description of the current activity
76+
- IsAllDataRequested : Activity span has been marked to be sampled / recorded (`0` or `1`)
7677

7778
**Formatting**
7879
- Format: Format for rendering the property.

src/NLog.DiagnosticSource/LayoutRenderers/ActivityTraceLayoutRenderer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ private string GetValue(System.Diagnostics.Activity activity)
190190
case ActivityTraceProperty.TraceStateString: return activity.TraceStateString;
191191
case ActivityTraceProperty.Status: return ConvertToString(activity.Status, Format);
192192
case ActivityTraceProperty.StatusDescription: return activity.StatusDescription ?? string.Empty;
193+
case ActivityTraceProperty.IsAllDataRequested: return activity.IsAllDataRequested ? "1" : "0";
193194
default: return string.Empty;
194195
}
195196
}

src/NLog.DiagnosticSource/LayoutRenderers/ActivityTraceProperty.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,5 +89,9 @@ public enum ActivityTraceProperty
8989
/// Status description of the current activity
9090
/// </summary>
9191
StatusDescription,
92+
/// <summary>
93+
/// Whether the activity span is sampled / recorded, and should be populated with propagation info and other details.
94+
/// </summary>
95+
IsAllDataRequested,
9296
}
9397
}

src/NLog.DiagnosticSource/NLog.DiagnosticSource.csproj

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<TargetFrameworks>net8.0;net6.0;net462;netstandard2.0</TargetFrameworks>
55
<RootNamespace>NLog</RootNamespace>
6-
<VersionPrefix>5.2.2</VersionPrefix>
6+
<VersionPrefix>5.2.3</VersionPrefix>
77
<VersionSuffix></VersionSuffix>
88

99
<AssemblyVersion>5.0.0.0</AssemblyVersion>
@@ -25,9 +25,7 @@
2525
<PackageLicenseExpression>BSD-3-Clause</PackageLicenseExpression>
2626
<PackageReadmeFile>README.md</PackageReadmeFile>
2727
<PackageReleaseNotes>
28-
- Added support for property Status (Ok / Error) (@banko6)
29-
- Added support for property StatusDescription (@banko6)
30-
- Translate default TraceId / SpanId to empty string (@snakefoot)
28+
- Added support for property IsAllDataRequested (@snakefoot)
3129

3230
See https://github.com/NLog/NLog.DiagnosticSource for documentation of ${activity} and DiagnosticListenerTarget
3331
</PackageReleaseNotes>

test/NLog.DiagnosticSource.Tests/ActivityTraceLayoutRendererTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public void TestAllPropertiesWhenActivityNull()
5252
[InlineData(ActivityTraceProperty.ActivityKind, true)]
5353
[InlineData(ActivityTraceProperty.Status, true)]
5454
[InlineData(ActivityTraceProperty.StatusDescription, true)]
55+
[InlineData(ActivityTraceProperty.IsAllDataRequested, false)]
5556
public void TestAllPropertiesWhenActivityEmpty(ActivityTraceProperty property, bool empty)
5657
{
5758
bool orgThrowExceptions = LogManager.ThrowExceptions;
@@ -106,6 +107,7 @@ public void TestAllPropertiesWhenActivityEmpty(ActivityTraceProperty property, b
106107
[InlineData(ActivityTraceProperty.Status, "D", "0")]
107108
[InlineData(ActivityTraceProperty.Status, "X", "00000000")]
108109
[InlineData(ActivityTraceProperty.StatusDescription, null, "")]
110+
[InlineData(ActivityTraceProperty.IsAllDataRequested, null, "1")]
109111
public void TestAllPropertiesWhenActivityRunning(ActivityTraceProperty property, string format, string output)
110112
{
111113
bool orgThrowExceptions = LogManager.ThrowExceptions;

0 commit comments

Comments
 (0)