Skip to content
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

Header propagation POC #135

Closed
wants to merge 4 commits into from
Closed

Conversation

tracyboehrer
Copy link
Member

@tracyboehrer tracyboehrer commented Mar 17, 2025

The Problem

  • Need to support getting headers, and additional User-Agent info, to outgoing requests.
  • Microsoft.AspNetCore.HeaderPropagation will not work since the DotNet CloudAdapter uses a queue on another thread, and the AspNet functionality is in the context of a current request only.
  • We also need to carry x-ms-correlation-id over (all the time)
  • I didn't want to pass headers all over.

This POC

  • IHeaderPropagationFilter
    • User DI'd impl that defines the list of headers and User-Agent addition
  • IHeaderPropation
    • Impl in Host.AspNet to filter the incoming headers for the incoming Microsoft.AspNetCore.Http.HttpRequest
  • RequestContext
    • Uses AsyncLocal to allow anything in the async call to access the filtered headers and add to HttpClient.
    • See Microsoft.Agents.Connector.RestClients.RestClientBase.GetHttpClientAsync for usage

Flow

  1. Request arrives at CloudAdapter
  2. Get IHeaderPropagationFilter (passed in via DI in this case)
  3. Create a host specific IHeaderPropagation using that
  4. If async, IHeaderPropagation pass it to the queue
  5. On the queue thread, create a new RequestContext
  6. Anything within the async call will be able to access RequestContext and values.

@github-actions github-actions bot added the ML: Core Tags changes to core libraries label Mar 17, 2025
@github-actions github-actions bot added the ML: Tests Tags changes to tests label Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ML: Core Tags changes to core libraries ML: Tests Tags changes to tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant