ActivitySource.StartActivity Method

Definition

Overloads

StartActivity(String, ActivityKind)

Creates and starts 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 and starts 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 and starts 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)

Source:
ActivitySource.cs
Source:
ActivitySource.cs
Source:
ActivitySource.cs
Source:
ActivitySource.cs
Source:
ActivitySource.cs

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

C#
public System.Diagnostics.Activity? StartActivity(string name = "", System.Diagnostics.ActivityKind kind = System.Diagnostics.ActivityKind.Internal);
C#
public System.Diagnostics.Activity? StartActivity(string name, System.Diagnostics.ActivityKind kind = System.Diagnostics.ActivityKind.Internal);

Parameters

name
String

The operation name of the activity.

kind
ActivityKind

The activity kind.

Returns

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

Applies to

.NET 10 och andra versioner
Produkt Versioner
.NET 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

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

Source:
ActivitySource.cs
Source:
ActivitySource.cs
Source:
ActivitySource.cs
Source:
ActivitySource.cs
Source:
ActivitySource.cs

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

C#
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 = "");

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

The created Activity object or null if there are no listeners.

Applies to

.NET 10 och andra versioner
Produkt Versioner
.NET 6, 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

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

Source:
ActivitySource.cs
Source:
ActivitySource.cs
Source:
ActivitySource.cs
Source:
ActivitySource.cs
Source:
ActivitySource.cs

Creates and starts 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.

C#
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);

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

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

Applies to

.NET 10 och andra versioner
Produkt Versioner
.NET 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

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

Source:
ActivitySource.cs
Source:
ActivitySource.cs
Source:
ActivitySource.cs
Source:
ActivitySource.cs
Source:
ActivitySource.cs

Creates and starts 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.

C#
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);
C#
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);

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

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

Applies to

.NET 10 och andra versioner
Produkt Versioner
.NET 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)