<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="6.0.0-preview.6.21352.12" />

ActivityListener

public sealed class ActivityListener : IDisposable
Allows listening to the start and stop activity events and gives the opportunity to decide creating an activity for sampling scenarios.
public Action<Activity> ActivityStarted { get; set; }

Gets or sets the callback used to listen to the activity start event.

public Action<Activity> ActivityStopped { get; set; }

Gets or sets the callback used to listen to the activity stop event.

public SampleActivity<ActivityContext> Sample { get; set; }

Gets or sets the callback that is used to decide if creating Activity objects with a specific data state is allowed.

public SampleActivity<string> SampleUsingParentId { get; set; }

Gets or sets the callback that is used to decide if creating Activity objects with a specific data state is allowed.

public Func<ActivitySource, bool> ShouldListenTo { get; set; }

Gets or sets the callback that allows deciding if activity object events that were created using the activity source object should be listened or not.

Construct a new activity listener object to start listeneing to the activity events.

public void Dispose()

Unregisters this activity listener object from listening to activity events.