Skip to content

Commit

Permalink
Revert "enableQueryStatement - add options choose between printing no…
Browse files Browse the repository at this point in the history
…ne, parameterized or all queries statement"

This reverts commit 602a5bf.
  • Loading branch information
JJ-WM committed May 17, 2024
1 parent 1c1a9f0 commit 2633f40
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import com.azure.cosmos.implementation.apachecommons.lang.StringUtils;
import com.azure.cosmos.implementation.batch.BatchExecutor;
import com.azure.cosmos.implementation.batch.BulkExecutor;
import com.azure.cosmos.implementation.clienttelemetry.ShowQueryOptions;
import com.azure.cosmos.implementation.faultinjection.IFaultInjectorProvider;
import com.azure.cosmos.implementation.feedranges.FeedRangeEpkImpl;
import com.azure.cosmos.implementation.feedranges.FeedRangeInternal;
Expand Down Expand Up @@ -109,9 +108,6 @@ public class CosmosAsyncContainer {
private static final ImplementationBridgeHelpers.CosmosReadManyRequestOptionsHelper.CosmosReadManyRequestOptionsAccessor readManyOptionsAccessor =
ImplementationBridgeHelpers.CosmosReadManyRequestOptionsHelper.getCosmosReadManyRequestOptionsAccessor();

private static final ImplementationBridgeHelpers.CosmosClientTelemetryConfigHelper.CosmosClientTelemetryConfigAccessor clientTelemetryConfigAccessor =
ImplementationBridgeHelpers.CosmosClientTelemetryConfigHelper.getCosmosClientTelemetryConfigAccessor();

private final CosmosAsyncDatabase database;
private final String id;
private final String link;
Expand Down Expand Up @@ -963,17 +959,7 @@ <T> Function<CosmosPagedFluxOptions, Flux<FeedResponse<T>>> queryItemsInternalFu
Function<CosmosPagedFluxOptions, Flux<FeedResponse<T>>> pagedFluxOptionsFluxFunction = (pagedFluxOptions -> {
String spanName = this.queryItemsSpanName;

ShowQueryOptions showQueryOptions = clientTelemetryConfigAccessor.showQueryOptions(client.getClientTelemetryConfig());

if (ShowQueryOptions.PARAMETERIZED_ONLY.equals(showQueryOptions)
&& sqlQuerySpec.getParameters() != null
&& sqlQuerySpec.getParameters().size() > 0) {

pagedFluxOptions.setQueryText(sqlQuerySpec.getQueryText());
} else if (ShowQueryOptions.PARAMETERIZED_AND_NON_PARAMETERIZED.equals(showQueryOptions)) {

pagedFluxOptions.setQueryText(sqlQuerySpec.getQueryText());
}
pagedFluxOptions.setQueryText(sqlQuerySpec.getQueryText());

QueryFeedOperationState state = new QueryFeedOperationState(
client,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import com.azure.cosmos.CosmosDiagnosticsHandler;
import com.azure.cosmos.CosmosDiagnosticsThresholds;
import com.azure.cosmos.CosmosException;
import com.azure.cosmos.implementation.clienttelemetry.ShowQueryOptions;
import com.azure.cosmos.implementation.directconnectivity.StoreResponseDiagnostics;
import com.azure.cosmos.implementation.directconnectivity.StoreResultDiagnostics;
import com.azure.cosmos.implementation.guava25.base.Splitter;
Expand Down Expand Up @@ -1167,11 +1166,7 @@ private boolean isTransportLevelTracingEnabled() {
}

private boolean showQueryStatement() {
if(ShowQueryOptions.PARAMETERIZED_AND_NON_PARAMETERIZED.equals(clientTelemetryConfigAccessor.showQueryOptions(this.config))
|| ShowQueryOptions.PARAMETERIZED_ONLY.equals(clientTelemetryConfigAccessor.showQueryOptions(this.config))) {
return true;
}
return false;
return clientTelemetryConfigAccessor.showQueryStatement(this.config);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import com.azure.cosmos.implementation.clienttelemetry.ClientTelemetry;
import com.azure.cosmos.implementation.clienttelemetry.CosmosMeterOptions;
import com.azure.cosmos.implementation.clienttelemetry.MetricCategory;
import com.azure.cosmos.implementation.clienttelemetry.ShowQueryOptions;
import com.azure.cosmos.implementation.clienttelemetry.TagName;
import com.azure.cosmos.implementation.directconnectivity.ContainerDirectConnectionMetadata;
import com.azure.cosmos.implementation.directconnectivity.Uri;
Expand Down Expand Up @@ -1493,7 +1492,7 @@ CosmosClientTelemetryConfig createSnapshot(
void setUseLegacyTracing(CosmosClientTelemetryConfig config, boolean useLegacyTracing);
void setTracer(CosmosClientTelemetryConfig config, Tracer tracer);
double getSamplingRate(CosmosClientTelemetryConfig config);
ShowQueryOptions showQueryOptions(CosmosClientTelemetryConfig config);
boolean showQueryStatement(CosmosClientTelemetryConfig config);
double[] getDefaultPercentiles(CosmosClientTelemetryConfig config);
boolean shouldPublishHistograms(CosmosClientTelemetryConfig config);
boolean shouldApplyDiagnosticThresholdsForTransportLevelMeters(CosmosClientTelemetryConfig config);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import com.azure.cosmos.implementation.clienttelemetry.ClientTelemetry;
import com.azure.cosmos.implementation.clienttelemetry.CosmosMeterOptions;
import com.azure.cosmos.implementation.clienttelemetry.MetricCategory;
import com.azure.cosmos.implementation.clienttelemetry.ShowQueryOptions;
import com.azure.cosmos.implementation.clienttelemetry.TagName;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
Expand Down Expand Up @@ -76,7 +75,7 @@ public final class CosmosClientTelemetryConfig {

private double samplingRate;

private ShowQueryOptions showQueryOptions = ShowQueryOptions.NONE;
private boolean showQueryStatement = false;

/**
* Instantiates a new Cosmos client telemetry configuration.
Expand Down Expand Up @@ -400,13 +399,12 @@ public CosmosClientTelemetryConfig enableTransportLevelTracing() {

/**
* Enables printing query in db.statement attribute. By default, query is not printed.
* Users have the option to enable printing parameterized or both parameterized and non-parameterized queries,
* but has to beware that customer data may be shown when the later option is chosen
* It's the user's responsibility to sanitize the queries if necessary.
* Users have to option to enable it, but has to beware customer data may be shown.
* It's the user's responsiblity to sanitize the query if necessary.
* @return current CosmosClientTelemetryConfig
*/
public CosmosClientTelemetryConfig showQueryOptions(ShowQueryOptions showQueryOptions) {
this.showQueryOptions = showQueryOptions;
public CosmosClientTelemetryConfig showQueryStatement() {
this.showQueryStatement = true;
return this;
}

Expand Down Expand Up @@ -452,7 +450,7 @@ public String toString() {
", clientTelemetryEnabled=" + this.effectiveIsClientTelemetryEnabled +
", clientMetricsEnabled=" + this.isClientMetricsEnabled +
", transportLevelTracingEnabled=" + this.isTransportLevelTracingEnabled +
", showQueryOptions=" + this.showQueryOptions +
", showQueryStatement=" + this.showQueryStatement +
", customTracerProvided=" + (this.tracer != null) +
", customDiagnosticHandlers=" + handlers +
"}";
Expand Down Expand Up @@ -678,8 +676,8 @@ public double getSamplingRate(CosmosClientTelemetryConfig config) {
}

@Override
public ShowQueryOptions showQueryOptions(CosmosClientTelemetryConfig config) {
return config.showQueryOptions;
public boolean showQueryStatement(CosmosClientTelemetryConfig config) {
return config.showQueryStatement;
}

@Override
Expand Down

0 comments on commit 2633f40

Please sign in to comment.