Skip to content

Commit 367f795

Browse files
committed
Added environment variable for disabling client metrics
1 parent b0560ac commit 367f795

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,7 @@ private static class SpannerEnvironmentImpl implements SpannerEnvironment {
727727
private static final String SPANNER_ENABLE_API_TRACING = "SPANNER_ENABLE_API_TRACING";
728728
private static final String SPANNER_ENABLE_END_TO_END_TRACING =
729729
"SPANNER_ENABLE_END_TO_END_TRACING";
730+
private static final String SPANNER_DISABLE_BUILTIN_METRICS = "SPANNER_DISABLE_BUILTIN_METRICS";
730731

731732
private SpannerEnvironmentImpl() {}
732733

@@ -753,6 +754,11 @@ public boolean isEnableApiTracing() {
753754
return Boolean.parseBoolean(System.getenv(SPANNER_ENABLE_API_TRACING));
754755
}
755756

757+
@Override
758+
public boolean isEnableBuiltInMetrics() {
759+
return !Boolean.parseBoolean(System.getenv(SPANNER_DISABLE_BUILTIN_METRICS));
760+
}
761+
756762
@Override
757763
public boolean isEnableEndToEndTracing() {
758764
return Boolean.parseBoolean(System.getenv(SPANNER_ENABLE_END_TO_END_TRACING));
@@ -821,7 +827,7 @@ public static class Builder
821827
private boolean enableApiTracing = SpannerOptions.environment.isEnableApiTracing();
822828
private boolean enableExtendedTracing = SpannerOptions.environment.isEnableExtendedTracing();
823829
private boolean enableEndToEndTracing = SpannerOptions.environment.isEnableEndToEndTracing();
824-
private boolean enableBuiltInMetrics = true;
830+
private boolean enableBuiltInMetrics = SpannerOptions.environment.isEnableBuiltInMetrics();
825831

826832
private static String createCustomClientLibToken(String token) {
827833
return token + " " + ServiceOptions.getGoogApiClientLibName();

0 commit comments

Comments
 (0)