From 9ade34602f6c1ab7931c7459a5ef30ad41033f05 Mon Sep 17 00:00:00 2001 From: annie-mac Date: Mon, 16 Oct 2023 07:31:08 -0700 Subject: [PATCH 1/4] emptyPageDiagnostics should only control the logging --- .../azure/cosmos/CosmosAsyncContainer.java | 25 +++++-------------- .../ImplementationBridgeHelpers.java | 1 - .../models/CosmosQueryRequestOptions.java | 20 --------------- 3 files changed, 6 insertions(+), 40 deletions(-) diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosAsyncContainer.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosAsyncContainer.java index 2539632a3d37..12c351e1b3e7 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosAsyncContainer.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosAsyncContainer.java @@ -646,10 +646,7 @@ CosmosPagedFlux readAllItems(Class classType) { CosmosPagedFlux readAllItems(CosmosQueryRequestOptions options, Class classType) { return UtilBridgeInternal.createCosmosPagedFlux(pagedFluxOptions -> { CosmosAsyncClient client = this.getDatabase().getClient(); - CosmosQueryRequestOptions nonNullOptions = options != null ? options : new CosmosQueryRequestOptions(); - CosmosQueryRequestOptions requestOptions = clientAccessor.shouldEnableEmptyPageDiagnostics(client) ? - queryOptionsAccessor.withEmptyPageDiagnosticsEnabled(nonNullOptions, true) - : nonNullOptions; + CosmosQueryRequestOptions requestOptions = options != null ? options : new CosmosQueryRequestOptions(); QueryFeedOperationState state = new QueryFeedOperationState( client, @@ -946,11 +943,8 @@ CosmosPagedFlux queryItemsInternal( Function>> queryItemsInternalFunc( SqlQuerySpec sqlQuerySpec, CosmosQueryRequestOptions cosmosQueryRequestOptions, Class classType) { CosmosAsyncClient client = this.getDatabase().getClient(); - CosmosQueryRequestOptions nonNullOptions = + CosmosQueryRequestOptions options = cosmosQueryRequestOptions != null ? cosmosQueryRequestOptions : new CosmosQueryRequestOptions(); - CosmosQueryRequestOptions options = clientAccessor.shouldEnableEmptyPageDiagnostics(client) ? - queryOptionsAccessor.withEmptyPageDiagnosticsEnabled(nonNullOptions, true) - : nonNullOptions; Function>> pagedFluxOptionsFluxFunction = (pagedFluxOptions -> { String spanName = this.queryItemsSpanName; @@ -982,11 +976,9 @@ Function>> queryItemsInternalFu Mono sqlQuerySpecMono, CosmosQueryRequestOptions cosmosQueryRequestOptions, Class classType) { Function>> pagedFluxOptionsFluxFunction = (pagedFluxOptions -> { CosmosAsyncClient client = this.getDatabase().getClient(); - CosmosQueryRequestOptions nonNullOptions = + CosmosQueryRequestOptions options = cosmosQueryRequestOptions != null ? cosmosQueryRequestOptions : new CosmosQueryRequestOptions(); - CosmosQueryRequestOptions options = clientAccessor.shouldEnableEmptyPageDiagnostics(client) ? - queryOptionsAccessor.withEmptyPageDiagnosticsEnabled(nonNullOptions, true) - : nonNullOptions; + String spanName = this.queryItemsSpanName; QueryFeedOperationState state = new QueryFeedOperationState( @@ -1556,13 +1548,8 @@ public CosmosPagedFlux readAllItems( CosmosQueryRequestOptions options, Class classType) { CosmosAsyncClient client = this.getDatabase().getClient(); - final CosmosQueryRequestOptions requestOptions = options == null - ? queryOptionsAccessor.withEmptyPageDiagnosticsEnabled( - new CosmosQueryRequestOptions(), - clientAccessor.shouldEnableEmptyPageDiagnostics(client)) - : clientAccessor.shouldEnableEmptyPageDiagnostics(client) - ? queryOptionsAccessor.withEmptyPageDiagnosticsEnabled(options, true) - : options; + final CosmosQueryRequestOptions requestOptions = options == null ? new CosmosQueryRequestOptions() : options; + requestOptions.setPartitionKey(partitionKey); return UtilBridgeInternal.createCosmosPagedFlux(pagedFluxOptions -> { diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/ImplementationBridgeHelpers.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/ImplementationBridgeHelpers.java index 82bb8c3b9e00..54f112037132 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/ImplementationBridgeHelpers.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/ImplementationBridgeHelpers.java @@ -269,7 +269,6 @@ CosmosQueryRequestOptions clone( UUID getCorrelationActivityId(CosmosQueryRequestOptions queryRequestOptions); CosmosQueryRequestOptions setCorrelationActivityId(CosmosQueryRequestOptions queryRequestOptions, UUID correlationActivityId); boolean isEmptyPageDiagnosticsEnabled(CosmosQueryRequestOptions queryRequestOptions); - CosmosQueryRequestOptions withEmptyPageDiagnosticsEnabled(CosmosQueryRequestOptions queryRequestOptions, boolean emptyPageDiagnosticsEnabled); Function getItemFactoryMethod(CosmosQueryRequestOptions queryRequestOptions, Class classOfT); CosmosQueryRequestOptions setItemFactoryMethod(CosmosQueryRequestOptions queryRequestOptions, Function factoryMethod); String getQueryNameOrDefault(CosmosQueryRequestOptions queryRequestOptions, String defaultQueryName); diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosQueryRequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosQueryRequestOptions.java index fb6a9a627fe1..a82199422205 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosQueryRequestOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosQueryRequestOptions.java @@ -687,21 +687,6 @@ boolean isQueryPlanRetrievalDisallowed() { boolean isEmptyPageDiagnosticsEnabled() { return this.emptyPageDiagnosticsEnabled; } - CosmosQueryRequestOptions setEmptyPageDiagnosticsEnabled(boolean emptyPageDiagnosticsEnabled) { - this.emptyPageDiagnosticsEnabled = emptyPageDiagnosticsEnabled; - return this; - } - - CosmosQueryRequestOptions withEmptyPageDiagnosticsEnabled(boolean emptyPageDiagnosticsEnabled) { - if (this.emptyPageDiagnosticsEnabled == emptyPageDiagnosticsEnabled) - { - return this; - } - - return new CosmosQueryRequestOptions(this) - .setEmptyPageDiagnosticsEnabled(emptyPageDiagnosticsEnabled); - } - Function getItemFactoryMethod() { return this.itemFactoryMethod; } CosmosQueryRequestOptions setItemFactoryMethod(Function factoryMethod) { @@ -789,11 +774,6 @@ public boolean isEmptyPageDiagnosticsEnabled(CosmosQueryRequestOptions queryRequ return queryRequestOptions.isEmptyPageDiagnosticsEnabled(); } - @Override - public CosmosQueryRequestOptions withEmptyPageDiagnosticsEnabled(CosmosQueryRequestOptions queryRequestOptions, boolean emptyPageDiagnosticsEnabled) { - return queryRequestOptions.withEmptyPageDiagnosticsEnabled(emptyPageDiagnosticsEnabled); - } - @Override @SuppressWarnings("unchecked") public Function getItemFactoryMethod( From c18a3ac2b268de2ee4200ed55d88716ab921d15b Mon Sep 17 00:00:00 2001 From: annie-mac Date: Mon, 16 Oct 2023 08:05:05 -0700 Subject: [PATCH 2/4] update changelog --- sdk/cosmos/azure-cosmos/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/cosmos/azure-cosmos/CHANGELOG.md b/sdk/cosmos/azure-cosmos/CHANGELOG.md index be2e2b8b3b5e..c45f6bb76907 100644 --- a/sdk/cosmos/azure-cosmos/CHANGELOG.md +++ b/sdk/cosmos/azure-cosmos/CHANGELOG.md @@ -7,6 +7,7 @@ #### Breaking Changes #### Bugs Fixed +* Fixed an issue where `emptyPageDiagnosticsEnabled` is being override which cause empty page diagnostics being logged out - See [PR 37199](https://github.com/Azure/azure-sdk-for-java/pull/37199) #### Other Changes From 3b8c471bb300eecce17f04215551e1a934a7438d Mon Sep 17 00:00:00 2001 From: Annie Liang <64233642+xinlian12@users.noreply.github.com> Date: Mon, 16 Oct 2023 08:29:19 -0700 Subject: [PATCH 3/4] Update sdk/cosmos/azure-cosmos/CHANGELOG.md Co-authored-by: Fabian Meiswinkel --- sdk/cosmos/azure-cosmos/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/cosmos/azure-cosmos/CHANGELOG.md b/sdk/cosmos/azure-cosmos/CHANGELOG.md index c45f6bb76907..b148092ed2c7 100644 --- a/sdk/cosmos/azure-cosmos/CHANGELOG.md +++ b/sdk/cosmos/azure-cosmos/CHANGELOG.md @@ -7,7 +7,7 @@ #### Breaking Changes #### Bugs Fixed -* Fixed an issue where `emptyPageDiagnosticsEnabled` is being override which cause empty page diagnostics being logged out - See [PR 37199](https://github.com/Azure/azure-sdk-for-java/pull/37199) +* Fixed an issue where `emptyPageDiagnosticsEnabled` is being overriden with different meaning - this causes empty page diagnostics being logged (with INFO level) when they shouldn't - See [PR 37199](https://github.com/Azure/azure-sdk-for-java/pull/37199) #### Other Changes From 048f9c372000902d1d19a40f0865c96c1bc72243 Mon Sep 17 00:00:00 2001 From: Annie Liang <64233642+xinlian12@users.noreply.github.com> Date: Mon, 16 Oct 2023 14:40:08 -0700 Subject: [PATCH 4/4] Update sdk/cosmos/azure-cosmos/CHANGELOG.md Co-authored-by: Kushagra Thapar --- sdk/cosmos/azure-cosmos/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/cosmos/azure-cosmos/CHANGELOG.md b/sdk/cosmos/azure-cosmos/CHANGELOG.md index b148092ed2c7..b30f97dc7e1f 100644 --- a/sdk/cosmos/azure-cosmos/CHANGELOG.md +++ b/sdk/cosmos/azure-cosmos/CHANGELOG.md @@ -7,7 +7,7 @@ #### Breaking Changes #### Bugs Fixed -* Fixed an issue where `emptyPageDiagnosticsEnabled` is being overriden with different meaning - this causes empty page diagnostics being logged (with INFO level) when they shouldn't - See [PR 37199](https://github.com/Azure/azure-sdk-for-java/pull/37199) +* 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) #### Other Changes