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

Added Activity DisplayName + TraceStateString #123

Merged
merged 1 commit into from
Jan 19, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Example of `NLog.config` file that outputs span-details together with LogEvent b
- ParentId : Identifier for the parent activity
- TraceId : Identifier for the root activity (Request Trace Identifier)
- OperationName : Operation name of the current activity
- DisplayName : Explicit assigned Activity DisplayName (with fallback to OperationName)
- StartTimeUtc : Time when the operation started
- Duration : Duration of the operation (formatted as TimeSpan)
- DurationMs : Duration of the operation (formatted as TimeSpan.TotalMilliseconds)
Expand All @@ -69,6 +70,7 @@ Example of `NLog.config` file that outputs span-details together with LogEvent b
- SourceName : Name of the activity source associated with this activity
- SourceVersion : Version of the activity source associated with this activity
- ActivityKind : Relationship kind between the activity, its parents, and its children. Can be combined with `format="d"`
- TraceStateString : W3C 'tracestate' header as a string

**Formatting**
- Format: Format for rendering the property.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ private string GetValue(System.Diagnostics.Activity activity)
case ActivityTraceProperty.SpanId: return activity.GetSpanId();
case ActivityTraceProperty.TraceId: return activity.GetTraceId();
case ActivityTraceProperty.OperationName: return activity.OperationName;
case ActivityTraceProperty.DisplayName: return activity.DisplayName;
case ActivityTraceProperty.StartTimeUtc: return activity.StartTimeUtc > DateTime.MinValue ? activity.StartTimeUtc.ToString(Format, Culture) : string.Empty;
case ActivityTraceProperty.Duration: return GetDuration(activity);
case ActivityTraceProperty.ParentId: return activity.GetParentId();
Expand All @@ -186,6 +187,7 @@ private string GetValue(System.Diagnostics.Activity activity)
case ActivityTraceProperty.SourceName: return activity.Source?.Name;
case ActivityTraceProperty.SourceVersion: return activity.Source?.Version;
case ActivityTraceProperty.ActivityKind: return ConvertToString(activity.Kind, Format);
case ActivityTraceProperty.TraceStateString: return activity.TraceStateString;
default: return string.Empty;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,13 @@ public enum ActivityTraceProperty
/// Duration of the operation (formatted as TimeSpan.TotalMilliseconds)
/// </summary>
DurationMs,
/// <summary>
/// Explicit assigned Activity DisplayName (with fallback to OperationName)
/// </summary>
DisplayName,
/// <summary>
/// Holds the W3C 'tracestate' header as a string. See also <see cref="System.Diagnostics.Activity.TraceStateString"/>
/// </summary>
TraceStateString,
}
}