Skip to content

Commit

Permalink
emptyPageDiagnsticsShouldOnlyControlLogging (Azure#37199)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
4 people authored Oct 16, 2023
1 parent 9e1c6d5 commit c8f16eb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 40 deletions.
1 change: 1 addition & 0 deletions sdk/cosmos/azure-cosmos/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#### Breaking Changes

#### Bugs Fixed
* 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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,10 +646,7 @@ <T> CosmosPagedFlux<T> readAllItems(Class<T> classType) {
<T> CosmosPagedFlux<T> readAllItems(CosmosQueryRequestOptions options, Class<T> 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,
Expand Down Expand Up @@ -946,11 +943,8 @@ <T> CosmosPagedFlux<T> queryItemsInternal(
<T> Function<CosmosPagedFluxOptions, Flux<FeedResponse<T>>> queryItemsInternalFunc(
SqlQuerySpec sqlQuerySpec, CosmosQueryRequestOptions cosmosQueryRequestOptions, Class<T> 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<CosmosPagedFluxOptions, Flux<FeedResponse<T>>> pagedFluxOptionsFluxFunction = (pagedFluxOptions -> {
String spanName = this.queryItemsSpanName;
Expand Down Expand Up @@ -982,11 +976,9 @@ <T> Function<CosmosPagedFluxOptions, Flux<FeedResponse<T>>> queryItemsInternalFu
Mono<SqlQuerySpec> sqlQuerySpecMono, CosmosQueryRequestOptions cosmosQueryRequestOptions, Class<T> classType) {
Function<CosmosPagedFluxOptions, Flux<FeedResponse<T>>> 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(
Expand Down Expand Up @@ -1556,13 +1548,8 @@ public <T> CosmosPagedFlux<T> readAllItems(
CosmosQueryRequestOptions options,
Class<T> 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 -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
<T> Function<JsonNode, T> getItemFactoryMethod(CosmosQueryRequestOptions queryRequestOptions, Class<T> classOfT);
CosmosQueryRequestOptions setItemFactoryMethod(CosmosQueryRequestOptions queryRequestOptions, Function<JsonNode, ?> factoryMethod);
String getQueryNameOrDefault(CosmosQueryRequestOptions queryRequestOptions, String defaultQueryName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<JsonNode, ?> getItemFactoryMethod() { return this.itemFactoryMethod; }

CosmosQueryRequestOptions setItemFactoryMethod(Function<JsonNode, ?> factoryMethod) {
Expand Down Expand Up @@ -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 <T> Function<JsonNode, T> getItemFactoryMethod(
Expand Down

0 comments on commit c8f16eb

Please sign in to comment.