Skip to content

Commit

Permalink
Added Activity DisplayName + TraceStateString (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
snakefoot authored Jan 19, 2024
1 parent 6644501 commit 14e5a7f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
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,
}
}

0 comments on commit 14e5a7f

Please sign in to comment.