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 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
Prev Previous commit
Next Next commit
small fix
  • Loading branch information
mutianf committed Jan 22, 2024
commit c3f36edf2673bc28c100e6ca9fb310d71896f4fe
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public CompletableResultCode export(Collection<MetricData> collection) {
new ApiFutureCallback<Empty>() {
@Override
public void onFailure(Throwable throwable) {
logger.log(Level.WARNING, "createServiceTimeSeries request failed. ", throwable);
lastExportCode.fail();
}

Expand All @@ -149,14 +150,14 @@ public CompletableResultCode flush() {
@Override
public CompletableResultCode shutdown() {
Comment thread
mutianf marked this conversation as resolved.
Resolved
if (!isShutdown.compareAndSet(false, true)) {
logger.log(Level.INFO, "shutdown is called multiple times");
logger.log(Level.WARNING, "shutdown is called multiple times");
return CompletableResultCode.ofSuccess();
}
CompletableResultCode resultCode = flush();
try {
client.shutdown();
} catch (Throwable e) {
logger.log(Level.WARNING, "failed to shutdown the client", e);
logger.log(Level.WARNING, "failed to shutdown the monitoring client", e);
return CompletableResultCode.ofFailure();
}
return resultCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ private BigtableExporterUtils() {}

/**
* In most cases this should look like java-${UUID}@${hostname}. The hostname will be retrieved
* from the jvm name but fallback on the local hostname.
* from the jvm name and fallback to the local hostname.
*/
static String getDefaultTaskValue() {
Comment thread
mutianf marked this conversation as resolved.
Resolved
// Something like '<pid>@<hostname>'
final String jvmName = ManagementFactory.getRuntimeMXBean().getName();
// If not the expected format then fallback to localhost
// If jvm doesn't have the expected format, fallback to the local hostname
if (jvmName.indexOf('@') < 1) {
String hostname = "localhost";
try {
Expand All @@ -95,6 +95,10 @@ static String getDefaultTaskValue() {
return "java-" + UUID.randomUUID() + jvmName;
}

static String getProjectId(PointData pointData) {
return pointData.getAttributes().get(PROJECT_ID);
}

static List<TimeSeries> convertCollectionToListOfTimeSeries(
Collection<MetricData> collection, String taskId, MonitoredResource monitoredResource) {
List<TimeSeries> allTimeSeries = new ArrayList<>();
Expand All @@ -120,7 +124,6 @@ private static TimeSeries convertPointToTimeSeries(
MonitoredResource monitoredResource) {
Attributes attributes = pointData.getAttributes();
MonitoredResource.Builder monitoredResourceBuilder = monitoredResource.toBuilder();

Metric.Builder metricBuilder = Metric.newBuilder().setType(metricData.getName());

for (AttributeKey<?> key : attributes.asMap().keySet()) {
Expand Down Expand Up @@ -150,10 +153,6 @@ private static TimeSeries convertPointToTimeSeries(
return builder.build();
}

static String getProjectId(PointData pointData) {
return pointData.getAttributes().get(PROJECT_ID);
}

private static MetricKind convertMetricKind(MetricData metricData) {
switch (metricData.getType()) {
Comment thread
igorbernstein2 marked this conversation as resolved.
Resolved
case HISTOGRAM:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ class BuiltinMetricsAttributes {
static final AttributeKey<String> TABLE_ID = AttributeKey.stringKey("table");
static final AttributeKey<String> CLUSTER_ID = AttributeKey.stringKey("cluster");
static final AttributeKey<String> ZONE_ID = AttributeKey.stringKey("zone");
static final AttributeKey<String> CLIENT_UID = AttributeKey.stringKey("client_uid");

static final AttributeKey<String> APP_PROFILE = AttributeKey.stringKey("app_profile");
static final AttributeKey<Boolean> STREAMING = AttributeKey.booleanKey("streaming");
static final AttributeKey<String> METHOD = AttributeKey.stringKey("method");
static final AttributeKey<String> STATUS = AttributeKey.stringKey("status");
static final AttributeKey<String> CLIENT_NAME = AttributeKey.stringKey("client_name");
static final AttributeKey<String> CLIENT_UID = AttributeKey.stringKey("client_uid");
}
⌂ 换网址