Skip to content

Commit cfc616d

Browse files
fix: ensure that EnvInfo stays constant between metric exports (#2853)
The previous metrics refactor accidentally recomputed the uuid for metrics labels for each export, causing each export to create a new stream Change-Id: I14e7cfb691750c4017b65e09c58bf8b729e625c3 Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [ ] Make sure to open an issue as a [bug/issue](https://togithub.com/googleapis/java-bigtable/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) - [ ] Rollback plan is reviewed and LGTMed - [ ] All new data plane features have a completed end to end testing plan Fixes #<issue_number_goes_here> ☕️ If you write sample code, please follow the [samples format]( https://togithub.com/GoogleCloudPlatform/java-docs-samples/blob/main/SAMPLE_FORMAT.md).
1 parent 60d6a71 commit cfc616d

File tree

1 file changed

+3
-1
lines changed
  • google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/csm

1 file changed

+3
-1
lines changed

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/csm/MetricsImpl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import com.google.cloud.bigtable.data.v2.internal.csm.tracers.CompositeTracerFactory;
3434
import com.google.cloud.bigtable.data.v2.internal.csm.tracers.Pacemaker;
3535
import com.google.common.base.Preconditions;
36+
import com.google.common.base.Suppliers;
3637
import com.google.common.collect.ImmutableList;
3738
import com.google.common.collect.ImmutableMap;
3839
import io.grpc.ManagedChannelBuilder;
@@ -190,7 +191,8 @@ public static OpenTelemetrySdk createBuiltinOtel(
190191
BigtableCloudMonitoringExporter exporter =
191192
BigtableCloudMonitoringExporter.create(
192193
metricRegistry,
193-
EnvInfo::detect,
194+
// Lazily compute EnvInfo, but memoize it to make sure it stays constant
195+
Suppliers.memoize(EnvInfo::detect),
194196
clientInfo,
195197
credentials,
196198
metricsEndpoint,

0 commit comments

Comments
 (0)