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

.Net: New Feature: add correlation Id header to Kernel http calls #9717

Open
MaxiPigna opened this issue Nov 15, 2024 · 1 comment
Open

.Net: New Feature: add correlation Id header to Kernel http calls #9717

MaxiPigna opened this issue Nov 15, 2024 · 1 comment
Assignees
Labels
.NET Issue or Pull requests regarding .NET code telemetry

Comments

@MaxiPigna
Copy link


name: Feature request
about: Suggest an idea for this project


Sure, here's a rewritten version of your GitHub issue:


Implementation Details:

  • A Kernel is created from scratch for each incoming client request.
  • Several OpenAPI plugins are orchestrated by the Kernel.
  • The Kernel and OpenAPI plugins use different HttpClient instances due to varying endpoints, authentication methods, etc.
  • The backend is behind Azure API Management, which acts as a proxy and logs all outgoing requests to OpenAI and OpenAPI plugins.

Requirement:
I need to correlate all consecutive requests made by the Kernel by adding a header to the HTTP request containing a GUID. For example, if generating an answer requires two calls to OpenAI, both calls must include a header with the same value. Additionally, requests to the plugin must also include this header, as the plugin might need to propagate it for its own OpenAI calls, ensuring all related calls can be correlated.

Workaround:
The current workaround involves:

  1. Adding the header during Kernel creation for OpenAI calls.
  2. Storing the header value in Kernel Data.
  3. Implementing a DelegatingHandler that reads the header value from Kernel Data and adds it to the request (following this approach).

Proposed Solution:
A potential solution could involve making the Kernel context available in the DelegatingHandler for both OpenAPI and OpenAI requests. In this way I can implement this logic in one place and make it available to all components. However, I am open to suggestions for a more elegant solution.

@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code triage labels Nov 15, 2024
@github-actions github-actions bot changed the title New Feature: add correlation Id header to Kernel http calls .Net: New Feature: add correlation Id header to Kernel http calls Nov 15, 2024
@markwallace-microsoft
Copy link
Member

@dmytrostruk Let's start by creating a sample showing how to do this and we can then review to se does it make sense to add this as core functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
.NET Issue or Pull requests regarding .NET code telemetry
Projects
Status: No status
Development

No branches or pull requests

3 participants