Repository navigation
[Azure Functions v2] Propagate invocation IDs in client gRPC metadata - #328
Open
andystaples wants to merge 2 commits into
Open
andystaples wants to merge 2 commits into
andystaples wants to merge 2 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The wrapper mistakes binding data named context for runtime context, causing client RPCs to fail with AttributeError; it must preserve the binding, omit unavailable correlation, and add regression coverage.
1 open issue
What changed in this PR
This PR adds invocation-ID correlation to Azure Functions v2 client RPCs, allowing host logs to identify the calling function invocation without changing generic Durable Task or DTS clients.
Changes:
- Capture invocation-local context while preserving synchronous and asynchronous dispatch.
- Resolve invocation IDs per RPC so cached clients use the current invocation’s ID.
- Add transport and host-backed regression coverage and document the Functions-specific fix.
| File | Description |
|---|---|
tests/azure-functions-durable/test_invocation_metadata.py |
Tests transport metadata, concurrency, client reuse, and context cleanup. |
tests/azure-functions-durable/e2e/test_dtask_client_e2e.py |
Adds host-log correlation assertions for concurrent starters. |
tests/azure-functions-durable/e2e/apps/dtask_style/client_routes.py |
Adds async and sync correlation endpoints. |
azure-functions-durable/CHANGELOG.md |
Documents the invocation-correlation fix. |
azure-functions-durable/azure/durable_functions/internal/invocation.py |
Adds invocation-ID lookup and sync-compatible context wrapping. |
azure-functions-durable/azure/durable_functions/internal/azurefunctions_grpc_interceptor.py |
Adds invocation metadata at RPC call time. |
azure-functions-durable/azure/durable_functions/decorators/durable_app.py |
Wraps client-bound functions with invocation-context capture. |
Review effort: Balanced
| client_bound = sync_client_bound | ||
|
|
||
| set_client_metadata(client_bound) | ||
| client_bound = wrap_invocation(client_bound) |
Keep invocation correlation fix under Unreleased and preserve the rc4 release notes. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Functions-bound async and synchronous clients now send the originating
func.Context.invocation_idasx-azure-functions-invocationid, allowing the host'sClientOperationReceivedlogs to correlate client operations with the calling function invocation.The binding wrapper captures and resets invocation-local context while preserving synchronous/asynchronous dispatch and existing function annotations. Both Functions interceptors resolve the ID on each RPC rather than retaining it on a client or channel, matching the .NET Functions SDK's call-time correlation model. Cached synchronous clients, concurrent invocations, and thread-offloaded synchronous calls therefore use the current invocation's ID. Existing routing, user-agent, and caller metadata are preserved; calls without Functions invocation context do not gain a fabricated ID. Generic Durable Task and DTS clients are unchanged.
Regression coverage
Release coordination
This change applies only to
azure-functions-durableand is recorded under its unreleased changelog.2.0.0rc3remains unfixed; a fixed published version is not yet available and should be recorded when the next Functions SDK release is published. No package versions or dependency minimums are changed here.The extension E2E matrix must explicitly select that fixed Python v2 release with Python 3.13+ before making its corresponding SDK-line assertions mandatory. That dependency/version handoff remains tracked in Azure/azure-functions-durable-extension#3327; this does not change the separate stable Python v1 purge tracker.
Fixes #314.