Skip to content

Support Activity.Current Changed Event - #67938

Merged
tarekgh merged 1 commit into
dotnet:mainfrom
tarekgh:SupportActivtyCurrentChangedEvent
Apr 13, 2022
Merged

tarekgh merged 1 commit into
dotnet:mainfrom
tarekgh:SupportActivtyCurrentChangedEvent

Conversation

@tarekgh

@tarekgh tarekgh commented Apr 13, 2022

Copy link
Copy Markdown
Member

Fixes #67276

@ghost

ghost commented Apr 13, 2022

Copy link
Copy Markdown

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@ghost ghost assigned tarekgh Apr 13, 2022
@ghost

ghost commented Apr 13, 2022

Copy link
Copy Markdown

Tagging subscribers to this area: @dotnet/area-system-diagnostics-activity
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #67276

Author: tarekgh
Assignees: -
Labels:

new-api-needs-documentation, area-System.Diagnostics.Activity

Milestone: -

@tarekgh tarekgh added this to the 7.0.0 milestone Apr 13, 2022
@tarekgh
tarekgh requested a review from noahfalk April 13, 2022 00:22
@tarekgh

tarekgh commented Apr 13, 2022

Copy link
Copy Markdown
Member Author

CC @noahfalk @pjanotti

@noahfalk noahfalk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM : )

{
Activity? previous = s_current.Value;
s_current.Value = activity;
CurrentChanged?.Invoke(null, new ActivityChangedEventArgs(previous, activity));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means that arbitrary user code is now going to run anywhere Activity.Current is set. Is that always going to be ok? e.g. might that ever be set while holding a lock?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is possible there will be a lock held so it isn't foolproof, but its roughly the same type of problem that people already deal with successfully in ActivityListener. The small set of telemetry libraries that hook up to these mechanisms need to be careful to keep their dependencies limited both to avoid creating functional or performance problems.

@tarekgh
tarekgh merged commit 3b6a539 into dotnet:main Apr 13, 2022
@tarekgh
tarekgh deleted the SupportActivtyCurrentChangedEvent branch April 13, 2022 18:33
@pjanotti

Copy link
Copy Markdown
Contributor

Thanks @tarekgh!

@ghost ghost locked as resolved and limited conversation to collaborators May 14, 2022
@EgorBo

EgorBo commented Jul 21, 2022

Copy link
Copy Markdown
Member

Regression dotnet/perf-autofiling-issues#5202 @tarekgh is it expected?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[API Proposal]: Api handle Activity.Current value changes

5 participants