Skip to content

Commit 1c2fae6

Browse files
unable to emit metric should not fail the pipeline
1 parent 0c1f8e9 commit 1c2fae6

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
<groupId>io.cdap.plugin</groupId>
2222
<artifactId>google-cloud</artifactId>
23-
<version>0.22.4</version>
23+
<version>0.22.5</version>
2424
<name>Google Cloud Plugins</name>
2525
<packaging>jar</packaging>
2626
<description>Plugins for Google Big Query</description>

src/main/java/io/cdap/plugin/gcp/bigquery/action/BigQueryExecute.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,24 @@ public void run(ActionContext context) throws Exception {
169169
}
170170
}
171171

172+
context.getMetrics().gauge(RECORDS_PROCESSED, rows);
173+
try {
174+
recordBytesProcessedMetric(context, queryJob);
175+
} catch (Exception exception) {
176+
// log the exception but not fail the pipeline
177+
LOG.warn("Exception while trying to emit bytes processed metric.",
178+
exception);
179+
}
180+
}
181+
182+
private void recordBytesProcessedMetric(ActionContext context, Job queryJob) {
172183
long processedBytes =
173184
((JobStatistics.QueryStatistics) queryJob.getStatistics()).getTotalBytesProcessed();
174185
LOG.info("Job {} processed {} bytes", queryJob.getJobId(), processedBytes);
175186
Map<String, String> tags = new ImmutableMap.Builder<String, String>()
176187
.put(Constants.Metrics.Tag.APP_ENTITY_TYPE, Action.PLUGIN_TYPE)
177188
.put(Constants.Metrics.Tag.APP_ENTITY_TYPE_NAME, BigQueryExecute.NAME)
178189
.build();
179-
context.getMetrics().gauge(RECORDS_PROCESSED, rows);
180190
context.getMetrics().child(tags).countLong(BigQuerySinkUtils.BYTES_PROCESSED_METRIC,
181191
processedBytes);
182192
}

0 commit comments

Comments
 (0)