Skip to content

Commit 8d3dca4

Browse files
fix: ensure that multiple instances of a client in the same process dont clobber each other (#2590)
* fix: ensure that multiple instances of a client in the same process dont clobber each other Change-Id: I2087777f1f2d37c62f33c63a7ecb67f7a93712b8 * chore: generate libraries at Wed May 28 14:16:03 UTC 2025 --------- Co-authored-by: cloud-java-bot <[email protected]>
1 parent 051e8cb commit 8d3dca4

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BigtableCloudMonitoringExporter.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
import java.util.Map;
6767
import java.util.Optional;
6868
import java.util.concurrent.atomic.AtomicBoolean;
69+
import java.util.concurrent.atomic.AtomicLong;
6970
import java.util.logging.Level;
7071
import java.util.logging.Logger;
7172
import java.util.stream.Collectors;
@@ -302,10 +303,14 @@ static class PublicTimeSeriesConverter implements TimeSeriesConverter {
302303
.map(m -> METER_NAME + m)
303304
.collect(ImmutableList.toImmutableList());
304305

306+
private static final AtomicLong nextTaskIdSuffix = new AtomicLong();
305307
private final String taskId;
306308

307309
PublicTimeSeriesConverter() {
308-
this(BigtableExporterUtils.DEFAULT_TASK_VALUE.get());
310+
this(
311+
BigtableExporterUtils.DEFAULT_TASK_VALUE.get()
312+
+ "-"
313+
+ nextTaskIdSuffix.getAndIncrement());
309314
}
310315

311316
PublicTimeSeriesConverter(String taskId) {

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BigtableExporterUtils.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
import java.util.Optional;
8080
import java.util.Set;
8181
import java.util.UUID;
82+
import java.util.concurrent.atomic.AtomicLong;
8283
import java.util.logging.Level;
8384
import java.util.logging.Logger;
8485
import java.util.stream.Collectors;
@@ -102,6 +103,8 @@ class BigtableExporterUtils {
102103
GCPPlatformDetector.SupportedPlatform.GOOGLE_COMPUTE_ENGINE, "gcp_compute_engine",
103104
GCPPlatformDetector.SupportedPlatform.GOOGLE_KUBERNETES_ENGINE, "gcp_kubernetes_engine");
104105

106+
private static final AtomicLong nextUuidSuffix = new AtomicLong();
107+
105108
private BigtableExporterUtils() {}
106109

107110
/**
@@ -249,7 +252,7 @@ private static MonitoredResource detectResource(EnhancedBigtableStubSettings set
249252
.putLabels("host_id", attrs.get(AttributeKeys.GKE_HOST_ID))
250253
.putLabels("host_name", hostname)
251254
.putLabels("client_name", CLIENT_NAME)
252-
.putLabels("uuid", DEFAULT_TASK_VALUE.get())
255+
.putLabels("uuid", DEFAULT_TASK_VALUE.get() + "-" + nextUuidSuffix.getAndIncrement())
253256
.build();
254257
}
255258

0 commit comments

Comments
 (0)