diff --git a/java-spanner/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java b/java-spanner/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java index 3b4190a237c7..72b33b3315a1 100644 --- a/java-spanner/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java +++ b/java-spanner/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java @@ -997,7 +997,11 @@ protected SpannerOptions(Builder builder) { monitoringHost = builder.monitoringHost; defaultTransactionOptions = builder.defaultTransactionOptions; clientContext = builder.clientContext; - autoTaggingEnabled = builder.autoTaggingEnabled; + if (environment.isAutoTaggingDisabled()) { + autoTaggingEnabled = false; + } else { + autoTaggingEnabled = builder.autoTaggingEnabled || environment.isAutoTaggingEnabled(); + } autoTaggingPackages = builder.autoTaggingPackages; autoTaggingTracerLimit = builder.autoTaggingTracerLimit; } @@ -2611,10 +2615,7 @@ public TransactionOptions getDefaultTransactionOptions() { } public boolean isAutoTaggingEnabled() { - if (environment.isAutoTaggingDisabled()) { - return false; - } - return autoTaggingEnabled || environment.isAutoTaggingEnabled(); + return autoTaggingEnabled; } public List getAutoTaggingPackages() { @@ -2625,10 +2626,6 @@ public int getAutoTaggingTracerLimit() { return autoTaggingTracerLimit; } - public boolean isAutoTaggingDisabled() { - return environment.isAutoTaggingDisabled(); - } - @BetaApi public boolean isUseVirtualThreads() { return useVirtualThreads;