@@ -706,7 +706,7 @@ default boolean isEnableApiTracing() {
706
706
}
707
707
708
708
default boolean isEnableBuiltInMetrics () {
709
- return false ;
709
+ return true ;
710
710
}
711
711
712
712
default boolean isEnableEndToEndTracing () {
@@ -725,9 +725,9 @@ private static class SpannerEnvironmentImpl implements SpannerEnvironment {
725
725
"SPANNER_OPTIMIZER_STATISTICS_PACKAGE" ;
726
726
private static final String SPANNER_ENABLE_EXTENDED_TRACING = "SPANNER_ENABLE_EXTENDED_TRACING" ;
727
727
private static final String SPANNER_ENABLE_API_TRACING = "SPANNER_ENABLE_API_TRACING" ;
728
- private static final String SPANNER_ENABLE_BUILTIN_METRICS = "SPANNER_ENABLE_BUILTIN_METRICS" ;
729
728
private static final String SPANNER_ENABLE_END_TO_END_TRACING =
730
729
"SPANNER_ENABLE_END_TO_END_TRACING" ;
730
+ private static final String SPANNER_DISABLE_BUILTIN_METRICS = "SPANNER_DISABLE_BUILTIN_METRICS" ;
731
731
732
732
private SpannerEnvironmentImpl () {}
733
733
@@ -756,9 +756,7 @@ public boolean isEnableApiTracing() {
756
756
757
757
@ Override
758
758
public boolean isEnableBuiltInMetrics () {
759
- // The environment variable SPANNER_ENABLE_BUILTIN_METRICS is used for testing and will be
760
- // removed in the future.
761
- return Boolean .parseBoolean (System .getenv (SPANNER_ENABLE_BUILTIN_METRICS ));
759
+ return !Boolean .parseBoolean (System .getenv (SPANNER_DISABLE_BUILTIN_METRICS ));
762
760
}
763
761
764
762
@ Override
@@ -828,8 +826,8 @@ public static class Builder
828
826
private OpenTelemetry openTelemetry ;
829
827
private boolean enableApiTracing = SpannerOptions .environment .isEnableApiTracing ();
830
828
private boolean enableExtendedTracing = SpannerOptions .environment .isEnableExtendedTracing ();
831
- private boolean enableBuiltInMetrics = SpannerOptions .environment .isEnableBuiltInMetrics ();
832
829
private boolean enableEndToEndTracing = SpannerOptions .environment .isEnableEndToEndTracing ();
830
+ private boolean enableBuiltInMetrics = SpannerOptions .environment .isEnableBuiltInMetrics ();
833
831
834
832
private static String createCustomClientLibToken (String token ) {
835
833
return token + " " + ServiceOptions .getGoogApiClientLibName ();
@@ -1410,8 +1408,11 @@ public Builder setEnableApiTracing(boolean enableApiTracing) {
1410
1408
return this ;
1411
1409
}
1412
1410
1413
- /** Enabling this will enable built in metrics for each individual RPC execution. */
1414
- Builder setEnableBuiltInMetrics (boolean enableBuiltInMetrics ) {
1411
+ /**
1412
+ * Sets whether to enable or disable built in metrics for Data client operations. Built in
1413
+ * metrics are enabled by default.
1414
+ */
1415
+ public Builder setBuiltInMetricsEnabled (boolean enableBuiltInMetrics ) {
1415
1416
this .enableBuiltInMetrics = enableBuiltInMetrics ;
1416
1417
return this ;
1417
1418
}
@@ -1749,7 +1750,7 @@ public boolean isEnableApiTracing() {
1749
1750
* Returns true if an {@link com.google.api.gax.tracing.MetricsTracer} should be created and set
1750
1751
* on the Spanner client.
1751
1752
*/
1752
- boolean isEnableBuiltInMetrics () {
1753
+ public boolean isEnableBuiltInMetrics () {
1753
1754
return enableBuiltInMetrics ;
1754
1755
}
1755
1756
0 commit comments