Skip to content

Conversation

@NaluTripician
Copy link
Contributor

Pull Request Template

Description

This pull request adds enhanced trace logging to improve observability and debugging of metadata request routing and partition key range cache operations in the Cosmos DB SDK. The most important changes are the addition of detailed trace information for exception handling, request routing, and partition key range cache responses.

Enhanced Exception and Request Logging:

  • Added trace logs to ShouldRetryAsync in MetadataRequestThrottleRetryPolicy to record StatusCode and SubStatusCode for both CosmosException and DocumentClientException when evaluating retry logic. [1] [2]
  • Updated trace logging in OnBeforeSendRequest to include collectionName and collectionRid when routing metadata requests, providing more context for diagnostics.

Partition Key Range Cache Diagnostics:

  • Added trace logging in GetRoutingMapForCollectionAsync to output collectionRid, StatusCode, SubstatusCode, and the ETag value (ChangeFeedNextIfNoneMatch) for each response, aiding in troubleshooting partition key range cache issues.

Type of change

Please delete options that are not relevant.

  • [] New feature (non-breaking change which adds functionality)

Closing issues

To automatically close an issue: closes #IssueNumber

@NaluTripician NaluTripician self-assigned this Nov 24, 2025
@NaluTripician NaluTripician added the auto-merge Enables automation to merge PRs label Nov 24, 2025
Copy link
Member

@kirankumarkolli kirankumarkolli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check comments

xinlian12
xinlian12 previously approved these changes Nov 24, 2025
Copy link
Member

@xinlian12 xinlian12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks,

Copy link
Member

@xinlian12 xinlian12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks :)

@microsoft-github-policy-service microsoft-github-policy-service bot merged commit 2c73160 into master Nov 25, 2025
32 checks passed
@microsoft-github-policy-service microsoft-github-policy-service bot deleted the users/nalutripician/pkRangeTracingImprovements branch November 25, 2025 21:10
NaluTripician added a commit that referenced this pull request Jan 14, 2026
# Pull Request Template

## Description


This pull request adds enhanced trace logging to improve observability
and debugging of metadata request routing and partition key range cache
operations in the Cosmos DB SDK. The most important changes are the
addition of detailed trace information for exception handling, request
routing, and partition key range cache responses.

**Enhanced Exception and Request Logging:**

* Added trace logs to `ShouldRetryAsync` in
`MetadataRequestThrottleRetryPolicy` to record `StatusCode` and
`SubStatusCode` for both `CosmosException` and `DocumentClientException`
when evaluating retry logic.
[[1]](diffhunk://#diff-a5ed5985909c3dcb6e4ce186cdd662d590dac5297ea14e68560c7d1eca307be4R96)
[[2]](diffhunk://#diff-a5ed5985909c3dcb6e4ce186cdd662d590dac5297ea14e68560c7d1eca307be4R106)
* Updated trace logging in `OnBeforeSendRequest` to include
`collectionName` and `collectionRid` when routing metadata requests,
providing more context for diagnostics.

**Partition Key Range Cache Diagnostics:**

* Added trace logging in `GetRoutingMapForCollectionAsync` to output
`collectionRid`, `StatusCode`, `SubstatusCode`, and the ETag value
(`ChangeFeedNextIfNoneMatch`) for each response, aiding in
troubleshooting partition key range cache issues.

## Type of change

Please delete options that are not relevant.

- [] New feature (non-breaking change which adds functionality)

## Closing issues

To automatically close an issue: closes #IssueNumber
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-merge Enables automation to merge PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants