Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
class System.​Diagnostics.​ActivitySource
Assembly: System.Diagnostics.DiagnosticSource
Inheritance: object → ActivitySource
Implemented Interfaces
Provides APIs to create and start <see cref="T:System.Diagnostics.Activity" /> objects and to register <see cref="T:System.Diagnostics.ActivityListener" /> objects to listen to the <see cref="T:System.Diagnostics.Activity" /> events.
Properties
public
string
Name
Returns the activity source name.
public
string
Version
Returns the activity source version.
public
string
TelemetrySchemaUrl
Gets the telemetry schema URL associated with the ActivitySource.
public
Collections.​Generic.​IEnumerable<​Collections.​Generic.​KeyValuePair<​string, object>>
Tags
Gets the tags associated with the ActivitySource.
Methods
public
bool
HasListeners​()
Checks if there are any listeners for this activity source.
Returns <see langword="true" /> if there is a listener registered for this activity source; otherwise, <see langword="false" /> .
public
Activity
CreateActivity​(string name,
ActivityKind kind)
Creates a new <see cref="T:System.Diagnostics.Activity" /> object if there is any listener to the Activity, returns <see langword="null" /> otherwise.
Returns The created <see cref="T:System.Diagnostics.Activity" /> object or <see langword="null" /> if there are no listeners.
name
The operation name of the Activity
kind
The <see cref="T:System.Diagnostics.ActivityKind" />
public
Activity
CreateActivity​(string name,
ActivityKind kind,
ActivityContext parentContext,
Collections.​Generic.​IEnumerable?<​Collections.​Generic.​KeyValuePair<​string, object>> tags = null,
Collections.​Generic.​IEnumerable<​ActivityLink> links = null,
ActivityIdFormat idFormat = 0)
Creates a new <see cref="T:System.Diagnostics.Activity" /> object if there is any listener to the Activity, returns <see langword="null" /> otherwise.
If the Activity object is created, it will not automatically start. Callers will need to call <see cref="M:System.Diagnostics.Activity.Start" /> to start it.
Returns The created <see cref="T:System.Diagnostics.Activity" /> object or <see langword="null" /> if there are no listeners.
name
The operation name of the Activity.
kind
The <see cref="T:System.Diagnostics.ActivityKind" />
parentContext
The parent <see cref="T:System.Diagnostics.ActivityContext" /> object to initialize the created Activity object with.
tags
The optional tags list to initialize the created Activity object with.
links
The optional <see cref="T:System.Diagnostics.ActivityLink" /> list to initialize the created Activity object with.
idFormat
The default Id format to use.
public
Activity
CreateActivity​(string name,
ActivityKind kind,
string parentId,
Collections.​Generic.​IEnumerable?<​Collections.​Generic.​KeyValuePair<​string, object>> tags = null,
Collections.​Generic.​IEnumerable<​ActivityLink> links = null,
ActivityIdFormat idFormat = 0)
Creates a new <see cref="T:System.Diagnostics.Activity" /> object if there is any listener to the Activity, returns <see langword="null" /> otherwise.
Returns The created <see cref="T:System.Diagnostics.Activity" /> object or <see langword="null" /> if there are no listeners.
name
The operation name of the Activity.
kind
The <see cref="T:System.Diagnostics.ActivityKind" />
parentId
The parent Id to initialize the created Activity object with.
tags
The optional tags list to initialize the created Activity object with.
links
The optional <see cref="T:System.Diagnostics.ActivityLink" /> list to initialize the created Activity object with.
idFormat
The default Id format to use.
public
Activity
StartActivity​(string name = "",
ActivityKind kind = 0)
Creates and starts a new activity if there are active listeners for it, using the specified name and activity kind.
Returns The created activity object, if it had active listeners, or <see langword="null" /> if it has no event listeners.
name
The operation name of the activity.
kind
The activity kind.
public
Activity
StartActivity​(string name,
ActivityKind kind,
ActivityContext parentContext,
Collections.​Generic.​IEnumerable?<​Collections.​Generic.​KeyValuePair<​string, object>> tags = null,
Collections.​Generic.​IEnumerable<​ActivityLink> links = null,
DateTimeOffset startTime = null)
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.
Returns The created activity object, if it had active listeners, or <see langword="null" /> if it has no event listeners.
name
The operation name of the activity.
kind
The activity kind.
parentContext
The parent <see cref="T:System.Diagnostics.ActivityContext" /> object to initialize the created activity object with.
tags
The optional tags list to initialize the created activity object with.
links
The optional <see cref="T:System.Diagnostics.ActivityLink" /> list to initialize the created activity object with.
startTime
The optional start timestamp to set on the created activity object.
public
Activity
StartActivity​(string name,
ActivityKind kind,
string parentId,
Collections.​Generic.​IEnumerable?<​Collections.​Generic.​KeyValuePair<​string, object>> tags = null,
Collections.​Generic.​IEnumerable<​ActivityLink> links = null,
DateTimeOffset startTime = null)
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.
Returns The created activity object, if it had active listeners, or <see langword="null" /> if it has no event listeners.
name
The operation name of the activity.
kind
The activity kind.
parentId
The parent Id to initialize the created activity object with.
tags
The optional tags list to initialize the created activity object with.
links
The optional <see cref="T:System.Diagnostics.ActivityLink" /> list to initialize the created activity object with.
startTime
The optional start timestamp to set on the created activity object.
public
Activity
StartActivity​(ActivityKind kind,
ActivityContext parentContext = null,
Collections.​Generic.​IEnumerable?<​Collections.​Generic.​KeyValuePair<​string, object>> tags = null,
Collections.​Generic.​IEnumerable<​ActivityLink> links = null,
DateTimeOffset startTime = null,
string name = "")
Creates and starts a new <see cref="T:System.Diagnostics.Activity" /> object if there is any listener to the Activity events, returns <see langword="null" /> otherwise.
Returns The created <see cref="T:System.Diagnostics.Activity" /> object or <see langword="null" /> if there are no listeners.
kind
The <see cref="T:System.Diagnostics.ActivityKind" />
parentContext
The parent <see cref="T:System.Diagnostics.ActivityContext" /> object to initialize the created Activity object with.
tags
The optional tags list to initialize the created Activity object with.
links
The optional <see cref="T:System.Diagnostics.ActivityLink" /> list to initialize the created Activity object with.
startTime
The optional start timestamp to set on the created Activity object.
name
The operation name of the Activity.
public static
void
AddActivityListener​(ActivityListener listener)
Adds a listener to the activity starting and stopping events.
listener
The activity listener object to use for listening to the activity events.
public
void
Dispose​()
Disposes the activity source object, removes the current instance from the global list, and empties the listeners list.
public
bool
Equals​(object obj)
Inherited from object
protected
void
Finalize​()
Inherited from object
public
int
GetHashCode​()
Inherited from object
protected
object
MemberwiseClone​()
Inherited from object
public
string
ToString​()
Inherited from object