@@ -706,7 +706,7 @@ default boolean isEnableApiTracing() {
706706 }
707707
708708 default boolean isEnableBuiltInMetrics () {
709- return false ;
709+ return true ;
710710 }
711711
712712 default boolean isEnableEndToEndTracing () {
@@ -725,7 +725,6 @@ private static class SpannerEnvironmentImpl implements SpannerEnvironment {
725725 "SPANNER_OPTIMIZER_STATISTICS_PACKAGE" ;
726726 private static final String SPANNER_ENABLE_EXTENDED_TRACING = "SPANNER_ENABLE_EXTENDED_TRACING" ;
727727 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" ;
729728 private static final String SPANNER_ENABLE_END_TO_END_TRACING =
730729 "SPANNER_ENABLE_END_TO_END_TRACING" ;
731730
@@ -754,13 +753,6 @@ public boolean isEnableApiTracing() {
754753 return Boolean .parseBoolean (System .getenv (SPANNER_ENABLE_API_TRACING ));
755754 }
756755
757- @ Override
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 ));
762- }
763-
764756 @ Override
765757 public boolean isEnableEndToEndTracing () {
766758 return Boolean .parseBoolean (System .getenv (SPANNER_ENABLE_END_TO_END_TRACING ));
@@ -828,7 +820,7 @@ public static class Builder
828820 private OpenTelemetry openTelemetry ;
829821 private boolean enableApiTracing = SpannerOptions .environment .isEnableApiTracing ();
830822 private boolean enableExtendedTracing = SpannerOptions .environment .isEnableExtendedTracing ();
831- private boolean enableBuiltInMetrics = SpannerOptions . environment . isEnableBuiltInMetrics () ;
823+ private boolean enableBuiltInMetrics = true ;
832824 private boolean enableEndToEndTracing = SpannerOptions .environment .isEnableEndToEndTracing ();
833825
834826 private static String createCustomClientLibToken (String token ) {
@@ -1410,8 +1402,11 @@ public Builder setEnableApiTracing(boolean enableApiTracing) {
14101402 return this ;
14111403 }
14121404
1413- /** Enabling this will enable built in metrics for each individual RPC execution. */
1414- Builder setEnableBuiltInMetrics (boolean enableBuiltInMetrics ) {
1405+ /**
1406+ * Sets whether to enable or disable built in metrics for Data client Operations. Built in
1407+ * metrics are enabled as default.
1408+ */
1409+ public Builder setEnableBuiltInMetrics (boolean enableBuiltInMetrics ) {
14151410 this .enableBuiltInMetrics = enableBuiltInMetrics ;
14161411 return this ;
14171412 }
@@ -1726,13 +1721,13 @@ private ApiTracerFactory getDefaultApiTracerFactory() {
17261721 private ApiTracerFactory createMetricsApiTracerFactory () {
17271722 OpenTelemetry openTelemetry =
17281723 this .builtInOpenTelemetryMetricsProvider .getOrCreateOpenTelemetry (
1729- getDefaultProjectId (), getCredentials ());
1724+ getDefaultProject (), getCredentials ());
17301725
17311726 return openTelemetry != null
17321727 ? new MetricsTracerFactory (
17331728 new OpenTelemetryMetricsRecorder (openTelemetry , BuiltInMetricsConstant .METER_NAME ),
17341729 builtInOpenTelemetryMetricsProvider .createClientAttributes (
1735- getDefaultProjectId (),
1730+ getDefaultProject (),
17361731 "spanner-java/" + GaxProperties .getLibraryVersion (getClass ())))
17371732 : null ;
17381733 }
@@ -1750,7 +1745,7 @@ public boolean isEnableApiTracing() {
17501745 * Returns true if an {@link com.google.api.gax.tracing.MetricsTracer} should be created and set
17511746 * on the Spanner client.
17521747 */
1753- boolean isEnableBuiltInMetrics () {
1748+ public boolean isEnableBuiltInMetrics () {
17541749 return enableBuiltInMetrics ;
17551750 }
17561751
0 commit comments