Skip to content

fix: ensure that multiple instances of a client in the same process dont clobber each other #2590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
fix: ensure that multiple instances of a client in the same process d…
…ont clobber each other

Change-Id: I2087777f1f2d37c62f33c63a7ecb67f7a93712b8
  • Loading branch information
igorbernstein2 committed May 28, 2025
commit bc20fcfdca0d438a501f63e4240aa30e2c678631
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,11 @@ 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
Loading