Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.

Commit 7eb0ba8

Browse files
re-add missing endpoint prop
Change-Id: Ifcb6af1b9cb041ce79bc38a67817ae94904de83b
1 parent 8fd7eef commit 7eb0ba8

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

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

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,21 @@ public class BigtableCloudMonitoringExporter implements MetricExporter {
6060
private static final Logger LOGGER =
6161
Logger.getLogger(BigtableCloudMonitoringExporter.class.getName());
6262

63+
// This system property can be used to override the monitoring endpoint
64+
// to a different environment. It's meant for internal testing only and
65+
// will be removed in future versions. Use settings in EnhancedBigtableStubSettings
66+
// to override the endpoint.
67+
@Deprecated @Nullable
68+
private static final String MONITORING_ENDPOINT_OVERRIDE_SYS_PROP =
69+
System.getProperty("bigtable.test-monitoring-endpoint");
70+
6371
// This the quota limit from Cloud Monitoring. More details in
6472
// https://cloud.google.com/monitoring/quotas#custom_metrics_quotas.
6573
private static final int EXPORT_BATCH_SIZE_LIMIT = 200;
6674

6775
private final Supplier<EnvInfo> envInfo;
6876
private final ClientInfo clientInfo;
69-
private MetricRegistry metricRegistry;
77+
private final MetricRegistry metricRegistry;
7078
private final MetricServiceClient client;
7179

7280
private final AtomicReference<State> state;
@@ -98,6 +106,13 @@ public static BigtableCloudMonitoringExporter create(
98106
.<CredentialsProvider>map(FixedCredentialsProvider::create)
99107
.orElse(NoCredentialsProvider.create()));
100108

109+
if (MONITORING_ENDPOINT_OVERRIDE_SYS_PROP != null) {
110+
LOGGER.warning(
111+
"Setting the monitoring endpoint through system variable will be removed in future"
112+
+ " versions");
113+
settingsBuilder.setEndpoint(MONITORING_ENDPOINT_OVERRIDE_SYS_PROP);
114+
}
115+
101116
if (endpoint != null) {
102117
settingsBuilder.setEndpoint(endpoint);
103118
}
@@ -131,12 +146,6 @@ public void close() {
131146
public CompletableResultCode export(Collection<MetricData> metricData) {
132147
Preconditions.checkState(state.get() != State.Closed, "Exporter is closed");
133148

134-
if (metricRegistry == null) {
135-
String msg = "Bigtable exporter tried to export before fully configured";
136-
LOGGER.warning(msg);
137-
return CompletableResultCode.ofExceptionalFailure(new IllegalStateException(msg));
138-
}
139-
140149
lastExportCode = doExport(metricData);
141150
return lastExportCode;
142151
}

0 commit comments

Comments
 (0)