Skip to content
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

Routing: Fixes ExcludeRegions for ReadMany operation. #4713

Merged
merged 3 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Microsoft.Azure.Cosmos/src/ReadManyRequestOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ internal QueryRequestOptions ConvertToQueryRequestOptions()
IfMatchEtag = this.IfMatchEtag,
IfNoneMatchEtag = this.IfNoneMatchEtag,
Properties = this.Properties,
AddRequestHeaders = this.AddRequestHeaders
AddRequestHeaders = this.AddRequestHeaders,
ExcludeRegions = this.ExcludeRegions
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ public override Task<ResponseMessage> ReadManyItemsStreamAsync(
containerName: this.Id,
databaseName: this.Database.Id,
operationType: Documents.OperationType.Read,
requestOptions: null,
requestOptions: readManyRequestOptions,
task: (trace) => base.ReadManyItemsStreamAsync(items, trace, readManyRequestOptions, cancellationToken),
openTelemetry: new (OpenTelemetryConstants.Operations.ReadManyItems, (response) => new OpenTelemetryResponse(responseMessage: response)));
}
Expand All @@ -457,7 +457,7 @@ public override Task<FeedResponse<T>> ReadManyItemsAsync<T>(
containerName: this.Id,
databaseName: this.Database.Id,
operationType: Documents.OperationType.Read,
requestOptions: null,
requestOptions: readManyRequestOptions,
task: (trace) => base.ReadManyItemsAsync<T>(items, trace, readManyRequestOptions, cancellationToken),
openTelemetry: new (OpenTelemetryConstants.Operations.ReadManyItems, (response) => new OpenTelemetryResponse<T>(responseMessage: response)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,33 @@ public async Task ExlcudeRegionDiagnosticsTest()
Assert.IsTrue(excludeRegionsList.Contains("East US"));
}

[TestMethod]
[TestCategory("MultiRegion")]
public async Task ExcludeRegionWithReadManyDiagnosticsTest()
{
this.container = this.database.GetContainer(CosmosMultiRegionDiagnosticsTests.containerName);

FeedResponse<AvailabilityStrategyTestObject> feedResonse = await this.container.ReadManyItemsAsync<AvailabilityStrategyTestObject>(
new List<(string, PartitionKey)>()
{
("testId", new PartitionKey("pk")),
("testId2", new PartitionKey("pk2")),
("testId3", new PartitionKey("pk3")),
("testId4", new PartitionKey("pk4"))
},
new ReadManyRequestOptions()
{
ExcludeRegions = new List<string>() { "North Central US", "East US" }
});

List<string> excludeRegionsList;
CosmosTraceDiagnostics traceDiagnostic = feedResonse.Diagnostics as CosmosTraceDiagnostics;
traceDiagnostic.Value.Data.TryGetValue("ExcludedRegions", out object excludeRegionObject);
excludeRegionsList = excludeRegionObject as List<string>;
Assert.IsTrue(excludeRegionsList.Contains("North Central US"));
Assert.IsTrue(excludeRegionsList.Contains("East US"));
}

[TestMethod]
[TestCategory("MultiRegion")]
public async Task HedgeNestingDiagnosticsTest()
Expand Down
Loading