-
Notifications
You must be signed in to change notification settings - Fork 8
add client side correlation id, client request id. expose these and a… #70
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
base: main
Are you sure you want to change the base?
Conversation
…lso service request id correctly
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 adds correlation ID propagation across nested SDK calls to improve debugging and request tracing in the Dataverse client. It introduces context managers for scoped correlation IDs and expands error reporting to include separate client request IDs, correlation IDs, and service request IDs.
- Implemented
correlation_scope()context manager allowing users to specify custom correlation IDs for groups of operations - Added
_call_scope()internal context manager using Python'scontextvarsfor thread-safe correlation ID management - Updated all CRUD and metadata methods to use
_scoped_odata()wrapper ensuring correlation ID propagation
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/PowerPlatform/Dataverse/data/_odata.py | Added _call_scope() context manager, updated _request() to inject correlation and client request IDs into headers, modified error handling to separately track correlation, client request, and service request IDs |
| src/PowerPlatform/Dataverse/core/errors.py | Updated HttpError constructor to accept separate correlation_id, client_request_id, and service_request_id parameters with updated documentation |
| src/PowerPlatform/Dataverse/client.py | Added correlation_scope() public API and _scoped_odata() helper, updated all data and metadata methods to use scoped contexts |
| tests/unit/core/test_http_errors.py | Added test helpers RecordingHTTP and DummyCredential, added tests for correlation ID propagation behavior |
| README.md | Added documentation section explaining how to use correlation_scope() for request correlation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…com/microsoft/PowerPlatform-DataverseClient-Python into users/zhaodongwang/exposeIdsInError
…com/microsoft/PowerPlatform-DataverseClient-Python into users/zhaodongwang/exposeIdsInError
This pull request introduces support for propagating correlation IDs across nested SDK calls in the Dataverse client, enabling easier debugging and trace alignment for HTTP requests. The main changes include new context manager APIs for correlation scopes, consistent header propagation, and improved error reporting with expanded request ID details.
Correlation ID propagation and context management:
correlation_scopecontext manager to theDataverseClientclass, allowing users to specify a correlation ID that is automatically injected into all nested HTTP requests via thex-ms-correlation-request-idheader. This makes it easier to correlate logs and traces for a group of related operations._call_scopecontext manager in_ODataClientusing Python'scontextvarsto manage correlation IDs across nested calls, ensuring thread safety and isolation. [1] [2]DataverseClientto use the new_scoped_odatacontext manager, ensuring correlation IDs are consistently propagated. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]Request header and error reporting improvements:
x-ms-correlation-request-idand a uniquex-ms-client-request-idin their headers, and these values are logged for debugging.HttpErrorclass and its constructor have been updated to separately track and report correlation IDs, client request IDs, and service request IDs, providing more detailed error diagnostics. [1] [2] [3] [4] [5]Documentation and testing:
README.md.tests/unit/core/test_http_errors.pyto record and verify request headers, ensuring correct propagation of correlation and client request IDs. [1] [2]These changes provide a robust foundation for request tracing and debugging, making it easier to correlate SDK activity with Dataverse server logs and distributed traces.…lso service request id correctly