<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="7.0.0-preview.7.22375.6" />

Activity

public class Activity : IDisposable
Represents an operation with context to be used for logging.
public struct Enumerator<T>

Enumerates the data stored on an Activity object.

public static Activity Current { get; set; }

Gets or sets the current operation ( Activity) for the current thread. This flows across async calls.

public static ActivityIdFormat DefaultIdFormat { get; set; }

Gets or sets the default ID format for the Activity.

public static bool ForceDefaultIdFormat { get; set; }

Gets or sets a value that detrmines if the DefaultIdFormat is always used to define the default ID format.

public static Func<ActivityTraceId> TraceIdGenerator { get; set; }

When starting an Activity which does not have a parent context, the Trace Id will automatically be generated using random numbers. TraceIdGenerator can be used to override the runtime's default Trace Id generation algorithm.

Gets or sets the flags (defined by the W3C ID specification) associated with the activity.

public IEnumerable<KeyValuePair<string, string>> Baggage { get; }

Gets a collection of key/value pairs that represents information that is passed to children of this Activity.

public ActivityContext Context { get; }

Gets the context of the activity. Context becomes valid only if the activity has been started.

public string DisplayName { get; set; }

Gets or sets the display name of the activity.

public TimeSpan Duration { get; }

Gets the duration of the operation.

public IEnumerable<ActivityEvent> Events { get; }

Gets the list of all the activity events attached to this activity.

public bool HasRemoteParent { get; }

Gets a value that indicates whether the parent context was created from remote propagation.

public string Id { get; }

Gets an identifier that is specific to a particular request.

public ActivityIdFormat IdFormat { get; }

Gets the format for the Id.

public bool IsAllDataRequested { get; set; }

Gets or sets a value that indicates whether this activity should be populated with all the propagation information, as well as all the other properties, such as links, tags, and events.

public bool IsStopped { get; }

Gets a value that indicates whether this Activity object is stopped or not.

public ActivityKind Kind { get; }

Gets the relationship between the activity, its parents, and its children in a trace.

public IEnumerable<ActivityLink> Links { get; }

Gets the list of all the activity links attached to this activity.

public string OperationName { get; }

Gets the operation name.

public Activity Parent { get; }

Gets the parent Activity that created this activity.

public string ParentId { get; }

Gets the ID of this activity's parent.

public ActivitySpanId ParentSpanId { get; }

Gets the parent's SpanId.

public bool Recorded { get; }

Gets a value that indicates whether the W3CIdFlags.Recorded flag is set.

public string RootId { get; }

Gets the root ID of this Activity.

public ActivitySource Source { get; }

Gets the activity source associated with this activity.

public ActivitySpanId SpanId { get; }

Gets the SPAN part of the Id.

public DateTime StartTimeUtc { get; }

Gets the time when the operation started.

public ActivityStatusCode Status { get; }

Gets status code of the current activity object.

public string StatusDescription { get; }

Gets the status description of the current activity object.

public IEnumerable<KeyValuePair<string, object>> TagObjects { get; }

Gets the list of tags that represent information to log along with the activity. This information is not passed on to the children of this activity.

public IEnumerable<KeyValuePair<string, string>> Tags { get; }

Gets a collection of key/value pairs that represent information that will be logged along with the Activity to the logging system.

public ActivityTraceId TraceId { get; }

Gets the TraceId part of the Id.

public string TraceStateString { get; set; }

Gets or sets the W3C tracestate header.

Occurs when the Current value changes.

public Activity(string operationName)

Initializes a new instance of the Activity class.

public Activity AddBaggage(string key, string value)

Updates the Activity to have a new baggage item with the specified key and value.

Adds the specified activity event to the events list.

public Activity AddTag(string key, string value)

Updates the Activity to have a new tag with the provided key and value.

public Activity AddTag(string key, object value)

Updates the activity to have a tag with an additional key and value.

public void Dispose()

Stops the activity if it is already started and notifies any event listeners. Nothing will happen otherwise.

protected virtual void Dispose(bool disposing)

When overriden by a derived type, this method releases any allocated resources.

Enumerates the ActivityEvent objects attached to this Activity object.

Enumerates the ActivityLink objects attached to this Activity object.

public Enumerator<KeyValuePair<string, object>> EnumerateTagObjects()

Enumerates the tags attached to this Activity object.

public string GetBaggageItem(string key)

Returns the value of a key-value pair added to the activity with AddBaggage.

public object GetCustomProperty(string propertyName)

Returns the object mapped to the specified property name.

public object GetTagItem(string key)

Returns the value of the Activity tag mapped to the input key/>. Returns null if that key does not exist.

public Activity SetBaggage(string key, string value)

Add or update the Activity baggage with the input key and value. If the input value is null - if the collection has any baggage with the same key, then this baggage will get removed from the collection. - otherwise, nothing will happen and the collection will not change. If the input value is not null - if the collection has any baggage with the same key, then the value mapped to this key will get updated with the new input value. - otherwise, the key and value will get added as a new baggage to the collection. Baggage item will be updated/removed only if it was originaly added to the current activity. Items inherited from the parents will not be changed/removed, new item would be added to current activity baggage instead.

public void SetCustomProperty(string propertyName, object propertyValue)

Attaches any custom object to this activity. If the specified propertyName was previously associated with another object, the property will be updated to be associated with the new propertyValue instead. It is recommended to use a unique property name to avoid conflicts with anyone using the same value.

public Activity SetEndTime(DateTime endTimeUtc)

Updates the Activity to set its Duration as the difference between StartTimeUtc and the specified stop time.

Sets the ID format on this Activity before it is started.

public Activity SetParentId(string parentId)

Updates this Activity to indicate that the Activity with an ID of parentId caused this Activity.

public Activity SetParentId(ActivityTraceId traceId, ActivitySpanId spanId, ActivityTraceFlags activityTraceFlags = 0)

Sets the parent ID using the W3C convention of a TraceId and a SpanId.

public Activity SetStartTime(DateTime startTimeUtc)

Sets the start time of this Activity.

public Activity SetStatus(ActivityStatusCode code, string description = null)

Sets the status code and description on the current activity object.

public Activity SetTag(string key, object value)

Adds or update the activity tag with the input key and value.

public Activity Start()

Starts the activity.

public void Stop()

Stops the activity.