Hedging Detection API: Adds IsHedged() and GetHedgedRegions() to CosmosDiagnostics#5741
Closed
NaluTripician wants to merge 9 commits intomasterfrom
Closed
Hedging Detection API: Adds IsHedged() and GetHedgedRegions() to CosmosDiagnostics#5741NaluTripician wants to merge 9 commits intomasterfrom
NaluTripician wants to merge 9 commits intomasterfrom
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
… all hedged regions Replaces the single-region GetRespondingRegion() API with GetHedgedRegions() that returns IReadOnlyList<string> of all regions that received hedge requests, matching the data already tracked in the diagnostics Hedge Context datum. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Contributor
Author
|
closing, new APIs being proposed in offline discussion |
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.
Proposal
Users of the Azure Cosmos DB .NET SDK who enable cross-region hedging via
AvailabilityStrategy.CrossRegionHedgingStrategy()have no performant, first-class API to determine whether a given response was produced by a hedged request. Today the only way to detect hedging is to callDiagnostics.ToString()and parse the resulting JSON for\"Hedge Context\"— a string-parsing approach that is fragile, allocates heavily, and is inappropriate for hot paths.What Changes
IsHedged()onCosmosDiagnostics— returnsboolindicating whether the availability strategy activated hedging. Default returnsfalse(back-compat).GetHedgedRegions()onCosmosDiagnostics— returnsIReadOnlyList<string>containing all regions that received hedge requests, in dispatch order. Default returns an empty list. This mirrors the\"Hedge Context\"datum already stored in diagnostics.CosmosTraceDiagnostics— set directly byCrossRegionHedgingAvailabilityStrategy, true O(1) with zero allocations.Design Decisions
CosmosDiagnostics(notResponseMessage) — follows established pattern (GetClientElapsedTime,GetContactedRegions, etc.)SetWalkingStateRecursively()overheadImpact
CosmosDiagnostics.cs— 2 new virtual methodsCosmosTraceDiagnostics.cs— internal fields + overridesCrossRegionHedgingAvailabilityStrategy.cs— set flags on responseOpenSpec Artifacts
Full design, specs, and task breakdown in
openspec/changes/hedging-detection-api/