Skip to content

Commit c8f16eb

Browse files
xinlian12annie-macFabianMeiswinkelkushagraThapar
authored
emptyPageDiagnsticsShouldOnlyControlLogging (Azure#37199)
* emptyPageDiagnostics should only control the logging Co-authored-by: Fabian Meiswinkel <[email protected]> Co-authored-by: Kushagra Thapar <[email protected]> --------- Co-authored-by: annie-mac <[email protected]> Co-authored-by: Fabian Meiswinkel <[email protected]> Co-authored-by: Kushagra Thapar <[email protected]>
1 parent 9e1c6d5 commit c8f16eb

File tree

4 files changed

+7
-40
lines changed

4 files changed

+7
-40
lines changed

sdk/cosmos/azure-cosmos/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#### Breaking Changes
88

99
#### Bugs Fixed
10+
* Fixed an issue where `emptyPageDiagnosticsEnabled` in `CosmosQueryRequestOptions` was being overridden. This caused empty page diagnostics to be logged (with INFO level) even when the flag was set to false - See [PR 37199](https://github.com/Azure/azure-sdk-for-java/pull/37199)
1011

1112
#### Other Changes
1213

sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosAsyncContainer.java

+6-19
Original file line numberDiff line numberDiff line change
@@ -646,10 +646,7 @@ <T> CosmosPagedFlux<T> readAllItems(Class<T> classType) {
646646
<T> CosmosPagedFlux<T> readAllItems(CosmosQueryRequestOptions options, Class<T> classType) {
647647
return UtilBridgeInternal.createCosmosPagedFlux(pagedFluxOptions -> {
648648
CosmosAsyncClient client = this.getDatabase().getClient();
649-
CosmosQueryRequestOptions nonNullOptions = options != null ? options : new CosmosQueryRequestOptions();
650-
CosmosQueryRequestOptions requestOptions = clientAccessor.shouldEnableEmptyPageDiagnostics(client) ?
651-
queryOptionsAccessor.withEmptyPageDiagnosticsEnabled(nonNullOptions, true)
652-
: nonNullOptions;
649+
CosmosQueryRequestOptions requestOptions = options != null ? options : new CosmosQueryRequestOptions();
653650

654651
QueryFeedOperationState state = new QueryFeedOperationState(
655652
client,
@@ -946,11 +943,8 @@ <T> CosmosPagedFlux<T> queryItemsInternal(
946943
<T> Function<CosmosPagedFluxOptions, Flux<FeedResponse<T>>> queryItemsInternalFunc(
947944
SqlQuerySpec sqlQuerySpec, CosmosQueryRequestOptions cosmosQueryRequestOptions, Class<T> classType) {
948945
CosmosAsyncClient client = this.getDatabase().getClient();
949-
CosmosQueryRequestOptions nonNullOptions =
946+
CosmosQueryRequestOptions options =
950947
cosmosQueryRequestOptions != null ? cosmosQueryRequestOptions : new CosmosQueryRequestOptions();
951-
CosmosQueryRequestOptions options = clientAccessor.shouldEnableEmptyPageDiagnostics(client) ?
952-
queryOptionsAccessor.withEmptyPageDiagnosticsEnabled(nonNullOptions, true)
953-
: nonNullOptions;
954948

955949
Function<CosmosPagedFluxOptions, Flux<FeedResponse<T>>> pagedFluxOptionsFluxFunction = (pagedFluxOptions -> {
956950
String spanName = this.queryItemsSpanName;
@@ -982,11 +976,9 @@ <T> Function<CosmosPagedFluxOptions, Flux<FeedResponse<T>>> queryItemsInternalFu
982976
Mono<SqlQuerySpec> sqlQuerySpecMono, CosmosQueryRequestOptions cosmosQueryRequestOptions, Class<T> classType) {
983977
Function<CosmosPagedFluxOptions, Flux<FeedResponse<T>>> pagedFluxOptionsFluxFunction = (pagedFluxOptions -> {
984978
CosmosAsyncClient client = this.getDatabase().getClient();
985-
CosmosQueryRequestOptions nonNullOptions =
979+
CosmosQueryRequestOptions options =
986980
cosmosQueryRequestOptions != null ? cosmosQueryRequestOptions : new CosmosQueryRequestOptions();
987-
CosmosQueryRequestOptions options = clientAccessor.shouldEnableEmptyPageDiagnostics(client) ?
988-
queryOptionsAccessor.withEmptyPageDiagnosticsEnabled(nonNullOptions, true)
989-
: nonNullOptions;
981+
990982
String spanName = this.queryItemsSpanName;
991983

992984
QueryFeedOperationState state = new QueryFeedOperationState(
@@ -1556,13 +1548,8 @@ public <T> CosmosPagedFlux<T> readAllItems(
15561548
CosmosQueryRequestOptions options,
15571549
Class<T> classType) {
15581550
CosmosAsyncClient client = this.getDatabase().getClient();
1559-
final CosmosQueryRequestOptions requestOptions = options == null
1560-
? queryOptionsAccessor.withEmptyPageDiagnosticsEnabled(
1561-
new CosmosQueryRequestOptions(),
1562-
clientAccessor.shouldEnableEmptyPageDiagnostics(client))
1563-
: clientAccessor.shouldEnableEmptyPageDiagnostics(client)
1564-
? queryOptionsAccessor.withEmptyPageDiagnosticsEnabled(options, true)
1565-
: options;
1551+
final CosmosQueryRequestOptions requestOptions = options == null ? new CosmosQueryRequestOptions() : options;
1552+
15661553
requestOptions.setPartitionKey(partitionKey);
15671554

15681555
return UtilBridgeInternal.createCosmosPagedFlux(pagedFluxOptions -> {

sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/ImplementationBridgeHelpers.java

-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ CosmosQueryRequestOptions clone(
269269
UUID getCorrelationActivityId(CosmosQueryRequestOptions queryRequestOptions);
270270
CosmosQueryRequestOptions setCorrelationActivityId(CosmosQueryRequestOptions queryRequestOptions, UUID correlationActivityId);
271271
boolean isEmptyPageDiagnosticsEnabled(CosmosQueryRequestOptions queryRequestOptions);
272-
CosmosQueryRequestOptions withEmptyPageDiagnosticsEnabled(CosmosQueryRequestOptions queryRequestOptions, boolean emptyPageDiagnosticsEnabled);
273272
<T> Function<JsonNode, T> getItemFactoryMethod(CosmosQueryRequestOptions queryRequestOptions, Class<T> classOfT);
274273
CosmosQueryRequestOptions setItemFactoryMethod(CosmosQueryRequestOptions queryRequestOptions, Function<JsonNode, ?> factoryMethod);
275274
String getQueryNameOrDefault(CosmosQueryRequestOptions queryRequestOptions, String defaultQueryName);

sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosQueryRequestOptions.java

-20
Original file line numberDiff line numberDiff line change
@@ -687,21 +687,6 @@ boolean isQueryPlanRetrievalDisallowed() {
687687

688688
boolean isEmptyPageDiagnosticsEnabled() { return this.emptyPageDiagnosticsEnabled; }
689689

690-
CosmosQueryRequestOptions setEmptyPageDiagnosticsEnabled(boolean emptyPageDiagnosticsEnabled) {
691-
this.emptyPageDiagnosticsEnabled = emptyPageDiagnosticsEnabled;
692-
return this;
693-
}
694-
695-
CosmosQueryRequestOptions withEmptyPageDiagnosticsEnabled(boolean emptyPageDiagnosticsEnabled) {
696-
if (this.emptyPageDiagnosticsEnabled == emptyPageDiagnosticsEnabled)
697-
{
698-
return this;
699-
}
700-
701-
return new CosmosQueryRequestOptions(this)
702-
.setEmptyPageDiagnosticsEnabled(emptyPageDiagnosticsEnabled);
703-
}
704-
705690
Function<JsonNode, ?> getItemFactoryMethod() { return this.itemFactoryMethod; }
706691

707692
CosmosQueryRequestOptions setItemFactoryMethod(Function<JsonNode, ?> factoryMethod) {
@@ -789,11 +774,6 @@ public boolean isEmptyPageDiagnosticsEnabled(CosmosQueryRequestOptions queryRequ
789774
return queryRequestOptions.isEmptyPageDiagnosticsEnabled();
790775
}
791776

792-
@Override
793-
public CosmosQueryRequestOptions withEmptyPageDiagnosticsEnabled(CosmosQueryRequestOptions queryRequestOptions, boolean emptyPageDiagnosticsEnabled) {
794-
return queryRequestOptions.withEmptyPageDiagnosticsEnabled(emptyPageDiagnosticsEnabled);
795-
}
796-
797777
@Override
798778
@SuppressWarnings("unchecked")
799779
public <T> Function<JsonNode, T> getItemFactoryMethod(

0 commit comments

Comments
 (0)