-
Notifications
You must be signed in to change notification settings - Fork 474
Suppress execution context flow when starting host #11498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
e580ab5 to
a8f413a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR aims to suppress execution context flow during host startup to prevent AsyncLocal state (particularly Activity.Current) from being captured and flowing into function trigger delegates, which would cause telemetry corruption and other issues.
Key Changes
- Adds
ExecutionContext.SuppressFlow()at the beginning ofUnsynchronizedStartHostAsyncto prevent context propagation during host initialization
2e00eb9 to
690670d
Compare
fabiocav
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good. As mentioned by @brettsam in sync, it would be good to have a test for this.
|
@fabiocav I updated a test. Good idea also, caught that I was missing a |
Issue describing the changes in this PR
resolves #9651
Pull request checklist
IMPORTANT: Currently, changes must be backported to the
in-procbranch to be included in Core Tools and non-Flex deployments.in-procbranch is not requiredrelease_notes.mdAdditional information
This PR suppresses execution context flow inside of
UnsynchronizedStartHostAsync. This is to ensure any context, like async state (and specificallyActivity.Current) do not get captured when starting the script host. When an activity is captured, it will flow all the way into listener start and potentially be captured in function trigger delegates. In which case, every invocation of these functions will have the sameActivity.Current, leading to corrupted telemetry among other more significant issues (like activity tag or log scope creep).