-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-System.Diagnostics.Activity
Milestone
Description
Background and Motivation
Forcing creation of an Activity will allow existing codebases (e.g., aspnetcore) to migrate to using ActivitySource to create Activitys while still preserving compat with existing DiagnosticListeners.
Proposed API
namespace System.Diagnostics.DiagnosticSource
{
public sealed class ActivitySource
{
+ public System.Diagnostics.Activity? StartActivity (string name,
+ System.Diagnostics.ActivityKind kind,
+ string parentId,
+ bool forceCreation,
+ System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string,object?>>? tags = default,
+ System.Collections.Generic.IEnumerable<System.Diagnostics.ActivityLink>? links = default,
+ DateTimeOffset startTime = default);
}
}Usage Examples
Alternative Designs
The alternative design to achieve compat with DiagnosticListener was to create a dummy ActivityListener. However, the decision to sample/or not sample can change frequently (on a per request-basis), making it expensive to mutate the Sample/SampleUsingParentId delegate in a thread-safe.
Risks
When used incorrectly, forcing creation of an Activity could be a potentially expensive/high-allocation operation.
joshfree
Metadata
Metadata
Assignees
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-System.Diagnostics.Activity