Skip to content

[Internal] Thin Client Integration: Adds Thin Client Enablement Through Account Config and Reduce Request Headers for Proxy#5303

Merged
kushagraThapar merged 17 commits intomasterfrom
users/aavasthy/5282_thinclientenablement
Jul 25, 2025
Merged

[Internal] Thin Client Integration: Adds Thin Client Enablement Through Account Config and Reduce Request Headers for Proxy#5303
kushagraThapar merged 17 commits intomasterfrom
users/aavasthy/5282_thinclientenablement

Conversation

@aavasthy
Copy link
Copy Markdown
Contributor

@aavasthy aavasthy commented Jul 18, 2025

Pull Request Template

Description

This PR addresses the following:

  • While creating the proxy request, the SDK will now pass the below headers only:

    • x-ms-user-Agent : Used to identify the SDK user agent.
    • x-ms-activity-id : Activity ID to track requests in the proxy layer.
  • Update thin client enablement criteria:

    Currently the TC enablement is the combination of the below two operations:

    Enable TC = Set Environment Variable + Select Gateway Mode

    If either of the above condition is not meeting, default is Gateway mode. This PR is changing the enablement with the combination of 3 criteria. The flow will look like the below:

    First Phase Rollout: Enable TC = Set Environment Variable + Select Gateway Mode + GW Account Level Response indicating TC is enabled (containing TC endpoints)

    If either of the above condition is not meeting, default is Gateway mode.

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 #5285
To automatically close an issue: closes #5282

Comment thread Microsoft.Azure.Cosmos/src/DocumentClient.cs Outdated
Comment thread Microsoft.Azure.Cosmos/src/ThinClientStoreClient.cs Outdated
@kundadebdatta kundadebdatta requested a review from Copilot July 18, 2025 20:22
Copy link
Copy Markdown
Contributor

Copilot AI left a 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 implements thin client integration by adding proper header management for proxy requests and updating the enablement criteria. The changes ensure that only specific headers (user-agent and activity-id) are passed to proxy requests, while also updating the thin client enablement logic to require environment variable, gateway mode selection, and gateway account level response.

Key changes include:

  • Modified proxy request header handling to only include user-agent and activity-id headers
  • Updated thin client enablement criteria to check environment variable, gateway mode, and account-level response
  • Added UserAgentContainer parameter throughout the thin client components

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
ThinClientStoreClient.cs Updated proxy request preparation to clear headers and only add user-agent and activity-id
ThinClientStoreModel.cs Added UserAgentContainer parameter to constructor
DocumentClient.cs Updated thin client enablement logic and moved initialization timing
RetryPolicy.cs Added isThinClientEnabled parameter and threading
ClientRetryPolicy.cs Added thin client enabled flag and updated endpoint resolution logic
ThinClientConstants.cs Added UserAgent constant definition
Test files Updated test constructors to include UserAgentContainer parameter
Comments suppressed due to low confidence (2)

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CosmosItemThinClientTests.cs:26

  • The type name 'MultiRegionSetupHelpers.CosmosSystemTextJsonSerializer' appears to be inconsistent with the previous type 'CosmosSystemTextJsonSerializer'. This change suggests a namespace or type refactoring that should be verified for correctness.
        private MultiRegionSetupHelpers.CosmosSystemTextJsonSerializer cosmosSystemTextJsonSerializer;

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CosmosItemThinClientTests.cs:27

  • The ItemCount has been reduced from 1000 to 100. This reduction in test coverage may not adequately test performance and scalability scenarios that the original higher count was designed to verify.
        private const int ItemCount = 100;

Comment thread Microsoft.Azure.Cosmos/src/ThinClientStoreClient.cs
Comment thread Microsoft.Azure.Cosmos/src/DocumentClient.cs Outdated
Copy link
Copy Markdown
Member

@kundadebdatta kundadebdatta left a comment

Choose a reason for hiding this comment

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

As discussed - please pass the isThinClientEnabled flag to GlobalPartitionEndpointManagerCore ctor, so that we don't make unnecessary I/O calls (i.e.: ConfigurationManager.IsThinClientEnabled()) to determine thin client is enabled.

@kundadebdatta kundadebdatta added the auto-merge Enables automation to merge PRs label Jul 21, 2025
@kundadebdatta kundadebdatta changed the title [Internal] Thin Client Integration: Adds thinclient enablement and correct headers for proxy request. [Internal] Thin Client Integration: Adds Thin Client Enablement Through Account Config and Reduce Request Headers for Proxy Jul 22, 2025
kundadebdatta
kundadebdatta previously approved these changes Jul 22, 2025
Copy link
Copy Markdown
Member

@kundadebdatta kundadebdatta left a comment

Choose a reason for hiding this comment

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

LGTM Now.

Comment thread Microsoft.Azure.Cosmos/src/DocumentClient.cs Outdated
Comment thread Microsoft.Azure.Cosmos/src/DocumentClient.cs
Comment thread Microsoft.Azure.Cosmos/src/ThinClientStoreModel.cs
kundadebdatta
kundadebdatta previously approved these changes Jul 23, 2025
Copy link
Copy Markdown
Member

@kundadebdatta kundadebdatta left a comment

Choose a reason for hiding this comment

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

LGTM.

Copy link
Copy Markdown
Member

@kundadebdatta kundadebdatta left a comment

Choose a reason for hiding this comment

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

LGTM.

@aavasthy aavasthy moved this to Approved in Azure Cosmos SDKs Jul 25, 2025
@kushagraThapar kushagraThapar merged commit cdd1b1d into master Jul 25, 2025
27 checks passed
@kushagraThapar kushagraThapar deleted the users/aavasthy/5282_thinclientenablement branch July 25, 2025 14:06
@github-project-automation github-project-automation Bot moved this from Approved to Done in Azure Cosmos SDKs Jul 25, 2025
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 thin-client-integration

Projects

Status: Done

5 participants