Repository navigation
[Cosmos] Add Gateway service endpoint metric tags - #50888
Merged
Abhijeet Mohanty (jeet1995) merged 13 commits intoOct 26, 2026
Merged
Abhijeet Mohanty (jeet1995) merged 13 commits into
Abhijeet Mohanty (jeet1995) merged 13 commits into
Conversation
Emit opt-in hostname and port dimensions for Gateway request metrics, with account-free coverage and a live integration test. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 2 pipeline(s). 33 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Carry immutable per-attempt URI references through response diagnostics instead of reparsing endpoint strings during metric emission. Preserve URI snapshots across errors and status remapping without changing diagnostic JSON. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Cache immutable endpoint Tags by request authority in the client endpoint manager and reuse them directly during metric emission. Avoid repeated formatting, escaping and Tag allocation on cache hits; clear cached tags when the endpoint manager closes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Own cached endpoint Tags in RxGatewayStoreModel and capture them per request attempt for success, failure and cancellation diagnostics. Keep metric emission independent of the document client and endpoint manager, preserve opt-in gating, and clear Gateway/thin-client caches during client shutdown. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove the added BridgeInternal overload, use existing diagnostics accessors for failure and cancellation recording, shorten metric documentation, and clean up imports and formatting. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Build fresh Gateway clients for Compute Gateway and HTTP/2 GatewayV2 coverage, assert actual transport and endpoint tags across CRUD and 404 responses, and wait for probe readiness. Use run-scoped database setup and unconditional cleanup without modifying the Direct metrics fixture. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rename managementClient to resourceSetupClient to avoid confusion with Azure management SDKs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
Author
|
/azp run java - cosmos - tests |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Extract telemetry eligibility checks, combine destination validation, and retain the explicit cache-hit path. Let the metrics producer own the NONE fallback and verify missing tags do not populate the cache. Document Gateway endpoint examples in the metric table. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Inject one throttled read on Compute Gateway and GatewayV2 and verify endpoint/status counter deltas match diagnostic attempts while the logical operation count increases once. Share probe-readiness setup with existing E2E cases. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Abhijeet Mohanty (jeet1995)
marked this pull request as ready for review
October 23, 2026 20:57
Abhijeet Mohanty (jeet1995)
requested review from
a team and
Kiran Kumar Kolli (kirankumarkolli)
as code owners
October 23, 2026 20:57
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Query-plan metrics have inconsistent tag keys, and Compute Gateway test assertions reject valid emulator ports.
2 open issues
What changed in this PR
Adds the opt-in ServiceEndpoint tag to Azure Cosmos DB Gateway request metrics, capturing each attempt’s destination while preserving existing defaults and Direct behavior.
Changes:
- Cache destination tags and carry them through response and failure diagnostics.
- Reuse captured tags during metric emission and clear caches on client shutdown.
- Add unit and end-to-end coverage, metric documentation, and release notes.
| File | Description |
|---|---|
sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosMetricTagName.java |
Documents Gateway endpoint values. |
sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/ThinClientStoreModel.java |
Passes telemetry configuration to the Gateway model. |
sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RxGatewayStoreModel.java |
Caches endpoint tags and captures them per attempt. |
sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RxDocumentClientImpl.java |
Wires configuration and cache cleanup. |
sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/StoreResponseDiagnostics.java |
Snapshots destination URI and tag without changing JSON output. |
sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/StoreResponse.java |
Preserves destination metadata during status remapping. |
sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/clienttelemetry/ClientTelemetryMetrics.java |
Emits captured endpoint tags with a NONE fallback. |
sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/ClientSideRequestStatistics.java |
Carries destination metadata into Gateway statistics. |
sdk/cosmos/azure-cosmos/docs/Metrics.md |
Adds Gateway endpoint examples. |
sdk/cosmos/azure-cosmos/CHANGELOG.md |
Announces the opt-in metric dimension. |
sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/RxGatewayStoreModelTest.java |
Tests capture on successful and failed responses. |
sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/GatewayEndpointMetricsTest.java |
Tests formatting, caching, suppression, and diagnostics. |
sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/GatewayEndpointMetricsE2ETest.java |
Exercises Gateway metrics for item operations and retries. |
Review effort: Balanced
Member
Author
|
@sdkReviewAgent |
Remove synthetic query-plan measurements and use actual endpoint-tagged request attempts, including retries and RU charges. Add schema and live fault-injection regressions, verify cached plans do not create network measurements, and accept captured Compute Gateway emulator ports. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Reuse DocumentCollection/QueryPlan for actual Gateway query-plan attempts while retaining endpoint attribution and retry accounting. Update compatibility assertions and release notes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
Author
|
/azp run java - cosmos - tests |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Fabian Meiswinkel (FabianMeiswinkel)
approved these changes
Oct 26, 2026
Fabian Meiswinkel (FabianMeiswinkel)
left a comment
Member
There was a problem hiding this comment.
LGTM
Abhijeet Mohanty (jeet1995)
merged commit Oct 26, 2026
54150b3
into
Azure:main
125 of 132 checks passed
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.


Motivation
Gateway request metrics currently lack a destination dimension, making it difficult to identify which regional endpoint is contributing failures, retries, or request charges. This also prevents separating traffic to Compute Gateway (
443) from GatewayV2 (10250).Approach
Extend the existing opt-in
ServiceEndpointdimension to Gateway requests. Attribute each recorded attempt to the destination it actually used, rather than assigning one endpoint to the entire logical operation: a single operation can retry across multiple destinations.This lets users break down existing request metrics by endpoint without changing what those meters measure. Endpoint labels are reused across requests to avoid repeated formatting, and document paths are excluded so endpoint cardinality follows destinations rather than individual documents.
Compatibility
The dimension remains disabled by default and follows the existing tag-selection and suppression settings. Direct-mode metrics and operation-level measurements are unchanged.
Short workload check
Ran a local live point-read workload using the PR SDK at
e76803a76caand the benchmark'sCsvMetricsReporter: 100 seeded documents (512-byte payload field), concurrency 4, 30 seconds per transport, CSV snapshots every 5 seconds.ServiceEndpointwas enabled and diagnostic-threshold filtering disabled. Fresh clients were used for each mode; response diagnostics verified the actual destination port and HTTP protocol.Actual
CsvMetricsReporterrequest-counter files and contents follow. Only the account name in the filenames is replaced withredacted-account; CSV timestamps and values are unchanged.Compute Gateway
cosmos.client.req.gw.requests.RequestOperationType.Document_Read.RequestStatusCode.200_0.ServiceEndpoint.redacted-account-centralus.documents.azure.com_443.csvGatewayV2
cosmos.client.req.gw.requests.RequestOperationType.Document_Read.RequestStatusCode.200_0.ServiceEndpoint.redacted-account-centralus.documents.azure.com_10250.csvAll recorded reads succeeded (
200/0). Each of the three request meters produced eight CSV snapshots per transport, with matching count deltas after excluding warm-up. The reporting registry omitted nonessential labels to keep CSV filenames short; endpoint, request type, and request status were retained. Temporary workload resources were deleted.This checks live metric emission, not relative transport performance or the CPU/allocation overhead of tagging. Account names are redacted; regional suffixes are retained. No credentials or raw logs are included.
Sustained workload benchmark results
Benchmark table layout follows Azure/azure-sdk-for-java#48662. These are this PR's measurements, not values copied from that benchmark.
Coverage: 48 of 54 planned measured runs accepted. Gateway and GatewayV2 are complete at concurrency 8, 32, and 128; Direct is complete at 8 and 32. Direct concurrency 128 is incomplete: its first pair was stopped by the runner's five-minute required-metric gate while a CPU row was delayed in export (the row subsequently arrived). That partial pair and all smoke runs are excluded. No Direct-c128 performance result or full-matrix pass is claimed.
Test configuration
com.azure:azure-cosmos:4.83.0.e76803a76ca9.azure-cosmos-benchmarkharness from that PR commit, with the same aligned runtime dependencies and JVM settings; only the Cosmos SDK artifact differs. Actual SDK class loading was verified. This evaluates 4.83.0 on the aligned dependency set, not its full published transitive-dependency stack.ReadThroughput, three independent JVM rounds per configuration, each with a recorded 600-second measurement window after seed/cool-down and 60-second read warm-up. Each process uses a native randomly seeded 1,000-item cohort with identical five-by-20-character data-field settings.Standard_D16s_v5Linux VMs in Central US, baseline and feature assigned to separate fixed VMs, reached through Bastion. OpenJDK 21.0.12.1; G1GC; 8 GiB initial/max heap. The workers were not crossed over between SDKs, and endpoint routing was not pinned.ServiceEndpointexplicitly enabled in both arms, preserving the other default tags; P50/P95/P99 configured. Diagnostic thresholds were set to zero for workload request-metric coverage. The native metrics and console exporters were enabled identically. Native Cosmos metric documents were ingested through Cosmos DB change feed into ADX.Throughput and operation latency