Visitar URL original
fix: ensure that multiple instances of a client in the same process dont clobber each other by igorbernstein2 · Pull Request #2590 · googleapis/java-bigtable · GitHub
Skip to content
This repository was archived by the owner on Aug 30, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -302,10 +303,14 @@ static class PublicTimeSeriesConverter implements TimeSeriesConverter {
.map(m -> METER_NAME + m)
.collect(ImmutableList.toImmutableList());

private static final AtomicLong nextTaskIdSuffix = new AtomicLong();
private final String taskId;

PublicTimeSeriesConverter() {
this(BigtableExporterUtils.DEFAULT_TASK_VALUE.get());
this(
BigtableExporterUtils.DEFAULT_TASK_VALUE.get()
+ "-"
+ nextTaskIdSuffix.getAndIncrement());
}

PublicTimeSeriesConverter(String taskId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicLong;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
Expand All @@ -102,6 +103,8 @@ class BigtableExporterUtils {
GCPPlatformDetector.SupportedPlatform.GOOGLE_COMPUTE_ENGINE, "gcp_compute_engine",
GCPPlatformDetector.SupportedPlatform.GOOGLE_KUBERNETES_ENGINE, "gcp_kubernetes_engine");

private static final AtomicLong nextUuidSuffix = new AtomicLong();

private BigtableExporterUtils() {}

/**
Expand Down Expand Up @@ -249,7 +252,7 @@ private static MonitoredResource detectResource(EnhancedBigtableStubSettings set
.putLabels("host_id", attrs.get(AttributeKeys.GKE_HOST_ID))
.putLabels("host_name", hostname)
.putLabels("client_name", CLIENT_NAME)
.putLabels("uuid", DEFAULT_TASK_VALUE.get())
.putLabels("uuid", DEFAULT_TASK_VALUE.get() + "-" + nextUuidSuffix.getAndIncrement())
.build();
}

Expand Down