ActivitySource.StartActivity Method

Definition

Overloads

StartActivity(String, ActivityKind)

Creates a new activity if there are active listeners for it, using the specified name and activity kind.

StartActivity(ActivityKind, ActivityContext, IEnumerable<KeyValuePair<String,Object>>, IEnumerable<ActivityLink>, DateTimeOffset, String)

Creates and starts a new Activity object if there is any listener to the Activity events, returns null otherwise.

StartActivity(String, ActivityKind, ActivityContext, IEnumerable<KeyValuePair<String,Object>>, IEnumerable<ActivityLink>, DateTimeOffset)

Creates a new activity if there are active listeners for it, using the specified name, activity kind, parent activity context, tags, optional activity link and optional start time.

StartActivity(String, ActivityKind, String, IEnumerable<KeyValuePair<String,Object>>, IEnumerable<ActivityLink>, DateTimeOffset)

Creates a new activity if there are active listeners for it, using the specified name, activity kind, parent Id, tags, optional activity links and optional start time.

StartActivity(String, ActivityKind)

Creates a new activity if there are active listeners for it, using the specified name and activity kind.

public System.Diagnostics.Activity? StartActivity (string name, System.Diagnostics.ActivityKind kind = System.Diagnostics.ActivityKind.Internal);
public System.Diagnostics.Activity? StartActivity (string name = "", System.Diagnostics.ActivityKind kind = System.Diagnostics.ActivityKind.Internal);
member this.StartActivity : string * System.Diagnostics.ActivityKind -> System.Diagnostics.Activity
Public Function StartActivity (name As String, Optional kind As ActivityKind = System.Diagnostics.ActivityKind.Internal) As Activity
Public Function StartActivity (Optional name As String = "", Optional kind As ActivityKind = System.Diagnostics.ActivityKind.Internal) As Activity

Parameters

name
String

The operation name of the activity.

kind
ActivityKind

The activity kind.

Returns

Activity

The created activity object, if it had active listeners, or null if it has no event listeners.

Applies to

Creates and starts a new Activity object if there is any listener to the Activity events, returns null otherwise.

public System.Diagnostics.Activity? StartActivity (System.Diagnostics.ActivityKind kind, System.Diagnostics.ActivityContext parentContext = default, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string,object?>>? tags = default, System.Collections.Generic.IEnumerable<System.Diagnostics.ActivityLink>? links = default, DateTimeOffset startTime = default, string name = "");
member this.StartActivity : System.Diagnostics.ActivityKind * System.Diagnostics.ActivityContext * seq<System.Collections.Generic.KeyValuePair<string, obj>> * seq<System.Diagnostics.ActivityLink> * DateTimeOffset * string -> System.Diagnostics.Activity
Public Function StartActivity (kind As ActivityKind, Optional parentContext As ActivityContext = Nothing, Optional tags As IEnumerable(Of KeyValuePair(Of String, Object)) = Nothing, Optional links As IEnumerable(Of ActivityLink) = Nothing, Optional startTime As DateTimeOffset = Nothing, Optional name As String = "") As Activity

Parameters

parentContext
ActivityContext

The parent ActivityContext object to initialize the created Activity object with.

tags
IEnumerable<KeyValuePair<String,Object>>

The optional tags list to initialize the created Activity object with.

links
IEnumerable<ActivityLink>

The optional ActivityLink list to initialize the created Activity object with.

startTime
DateTimeOffset

The optional start timestamp to set on the created Activity object.

name
String

The operation name of the Activity.

Returns

Activity

The created Activity object or null if there is no any listener.

Applies to

Creates a new activity if there are active listeners for it, using the specified name, activity kind, parent activity context, tags, optional activity link and optional start time.

public System.Diagnostics.Activity? StartActivity (string name, System.Diagnostics.ActivityKind kind, System.Diagnostics.ActivityContext parentContext, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string,object?>>? tags = default, System.Collections.Generic.IEnumerable<System.Diagnostics.ActivityLink>? links = default, DateTimeOffset startTime = default);
member this.StartActivity : string * System.Diagnostics.ActivityKind * System.Diagnostics.ActivityContext * seq<System.Collections.Generic.KeyValuePair<string, obj>> * seq<System.Diagnostics.ActivityLink> * DateTimeOffset -> System.Diagnostics.Activity
Public Function StartActivity (name As String, kind As ActivityKind, parentContext As ActivityContext, Optional tags As IEnumerable(Of KeyValuePair(Of String, Object)) = Nothing, Optional links As IEnumerable(Of ActivityLink) = Nothing, Optional startTime As DateTimeOffset = Nothing) As Activity

Parameters

name
String

The operation name of the activity.

kind
ActivityKind

The activity kind.

parentContext
ActivityContext

The parent ActivityContext object to initialize the created activity object with.

tags
IEnumerable<KeyValuePair<String,Object>>

The optional tags list to initialize the created activity object with.

links
IEnumerable<ActivityLink>

The optional ActivityLink list to initialize the created activity object with.

startTime
DateTimeOffset

The optional start timestamp to set on the created activity object.

Returns

Activity

The created activity object, if it had active listeners, or null if it has no event listeners.

Applies to

Creates a new activity if there are active listeners for it, using the specified name, activity kind, parent Id, tags, optional activity links and optional start time.

public System.Diagnostics.Activity? StartActivity (string name, System.Diagnostics.ActivityKind kind, string parentId, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string,object?>>? tags = default, System.Collections.Generic.IEnumerable<System.Diagnostics.ActivityLink>? links = default, DateTimeOffset startTime = default);
member this.StartActivity : string * System.Diagnostics.ActivityKind * string * seq<System.Collections.Generic.KeyValuePair<string, obj>> * seq<System.Diagnostics.ActivityLink> * DateTimeOffset -> System.Diagnostics.Activity
Public Function StartActivity (name As String, kind As ActivityKind, parentId As String, Optional tags As IEnumerable(Of KeyValuePair(Of String, Object)) = Nothing, Optional links As IEnumerable(Of ActivityLink) = Nothing, Optional startTime As DateTimeOffset = Nothing) As Activity

Parameters

name
String

The operation name of the activity.

kind
ActivityKind

The activity kind.

parentId
String

The parent Id to initialize the created activity object with.

tags
IEnumerable<KeyValuePair<String,Object>>

The optional tags list to initialize the created activity object with.

links
IEnumerable<ActivityLink>

The optional ActivityLink list to initialize the created activity object with.

startTime
DateTimeOffset

The optional start timestamp to set on the created activity object.

Returns

Activity

The created activity object, if it had active listeners, or null if it has no event listeners.

Applies to