You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: allow factory to export to different projects (#2374)
This fix removed the check on Bigtable project id and gets the BigtableTable resource project id directly from metrics attribute. BigtableDataClientFactory can create one client for multiple projects. Removing the check allows people using BigtableDataClientFactory to export to different projects.
Copy file name to clipboardExpand all lines: google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BigtableCloudMonitoringExporter.java
+36-47
Original file line number
Diff line number
Diff line change
@@ -58,6 +58,7 @@
58
58
importjava.util.Arrays;
59
59
importjava.util.Collection;
60
60
importjava.util.List;
61
+
importjava.util.Map;
61
62
importjava.util.Optional;
62
63
importjava.util.concurrent.atomic.AtomicBoolean;
63
64
importjava.util.logging.Level;
@@ -94,7 +95,6 @@ public final class BigtableCloudMonitoringExporter implements MetricExporter {
94
95
95
96
privatefinalMetricServiceClientclient;
96
97
97
-
privatefinalStringbigtableProjectId;
98
98
privatefinalStringtaskId;
99
99
100
100
// The resource the client application is running on
@@ -128,8 +128,7 @@ public final class BigtableCloudMonitoringExporter implements MetricExporter {
if (bigtableExportFailureLogged.compareAndSet(false, true)) {
244
-
Stringmsg = "createServiceTimeSeries request failed for bigtable metrics.";
245
-
if (throwableinstanceofPermissionDeniedException) {
246
-
msg +=
247
-
String.format(
248
-
" Need monitoring metric writer permission on project=%s. Follow https://cloud.google.com/bigtable/docs/client-side-metrics-setup to set up permissions.",
if (bigtableExportFailureLogged.compareAndSet(false, true)) {
232
+
Stringmsg = "createServiceTimeSeries request failed for bigtable metrics.";
233
+
if (throwableinstanceofPermissionDeniedException) {
234
+
msg +=
235
+
String.format(
236
+
" Need monitoring metric writer permission on project=%s. Follow https://cloud.google.com/bigtable/docs/client-side-metrics-setup to set up permissions.",
237
+
projectName.getProject());
238
+
}
239
+
logger.log(Level.WARNING, msg, throwable);
240
+
}
241
+
bigtableExportCode.fail();
242
+
}
255
243
256
-
@Override
257
-
publicvoidonSuccess(List<Empty> emptyList) {
258
-
// When an export succeeded reset the export failure flag to false so if there's a
259
-
// transient failure it'll be logged.
260
-
bigtableExportFailureLogged.set(false);
261
-
bigtableExportCode.succeed();
262
-
}
263
-
},
264
-
MoreExecutors.directExecutor());
244
+
@Override
245
+
publicvoidonSuccess(List<Empty> emptyList) {
246
+
// When an export succeeded reset the export failure flag to false so if there's a
Copy file name to clipboardExpand all lines: google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BigtableExporterUtils.java
Copy file name to clipboardExpand all lines: google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BuiltinMetricsView.java
Copy file name to clipboardExpand all lines: google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/CustomOpenTelemetryMetricsProvider.java
Copy file name to clipboardExpand all lines: google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/DefaultMetricsProvider.java
0 commit comments