Skip to content

Conversation

@jviau
Copy link
Contributor

@jviau jviau commented Dec 3, 2025

Issue describing the changes in this PR

resolves #9651

Pull request checklist

IMPORTANT: Currently, changes must be backported to the in-proc branch to be included in Core Tools and non-Flex deployments.

  • Backporting to the in-proc branch is not required
    • Otherwise: Link to backporting PR
  • My changes do not require documentation changes
    • Otherwise: Documentation issue linked to PR
  • My changes should not be added to the release notes for the next release
    • Otherwise: I've added my notes to release_notes.md
  • My changes do not need to be backported to a previous version
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • My changes do not require diagnostic events changes
    • Otherwise: I have added/updated all related diagnostic events and their documentation (Documentation issue linked to PR)
  • I have added all required tests (Unit tests, E2E tests)

Additional information

This PR suppresses execution context flow inside of UnsynchronizedStartHostAsync. This is to ensure any context, like async state (and specifically Activity.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 same Activity.Current, leading to corrupted telemetry among other more significant issues (like activity tag or log scope creep).

Copilot AI review requested due to automatic review settings December 3, 2025 16:43
@jviau jviau requested a review from a team as a code owner December 3, 2025 16:43
Copilot finished reviewing on behalf of jviau December 3, 2025 16:45
@jviau jviau force-pushed the u/jviau/suppress-flow branch from e580ab5 to a8f413a Compare December 3, 2025 16:47
Copy link
Contributor

Copilot AI left a 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 of UnsynchronizedStartHostAsync to prevent context propagation during host initialization

@jviau jviau force-pushed the u/jviau/suppress-flow branch from 2e00eb9 to 690670d Compare December 3, 2025 17:22
Copy link
Member

@fabiocav fabiocav left a 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.

@jviau
Copy link
Contributor Author

jviau commented Dec 3, 2025

@fabiocav I updated a test. Good idea also, caught that I was missing a Task.Yield()

@jviau jviau requested a review from fabiocav December 3, 2025 19:17
@jviau jviau merged commit f1e7275 into dev Dec 4, 2025
9 checks passed
@jviau jviau deleted the u/jviau/suppress-flow branch December 4, 2025 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GRPC TraceContext Tags overwrite warnings

5 participants