Source:
void handleJobCompletion(final JobFinishedEvent event) throws GenieException { final long start = System.nanoTime(); final String jobId = event.getId(); final Map<String, String> tags = MetricsUtils.newSuccessTagsMap(); try { try { final Cluster cluster = jobSearchService.getJobCluster(jobId); final Command command = jobSearchService.getJobCommand(jobId); MetricsUtils.addCommonJobWorkflowMetricTags(cluster, command, tags); } catch (final Exception e) { log.error("Failed getting cluster and command for the job: {}", jobId, e); } final Job job = this.retryTemplate.execute(context -> this.getJob(jobId)); final JobStatus status = job.getStatus(); if (status.isActive()) { try { this.retryTemplate.execute(context -> this.updateJob(job, event, tags)); } catch (final Exception e) { log.error("Failed updating for job: {}", jobId, e); } try { this.retryTemplate.execute(context -> this.processJobDir(job)); } catch (final Exception e) { log.error("Failed archiving directory for job: {}", jobId, e); this.incrementErrorCounter("JOB_DIRECTORY_FAILURE", e); } try { this.retryTemplate.execute(context -> sendEmail(jobId)); } catch (final Exception e) { log.error("Failed sending email for job: {}", jobId, e); this.incrementErrorCounter("JOB_UPDATE_FAILURE", e); } } } catch (final Exception e) { log.error("Failed getting job with id: {}", jobId, e); MetricsUtils.addFailureTagsWithException(tags, e); } finally { this.registry .timer(this.jobCompletionTimerId.withTags(tags)) .record(System.nanoTime() - start, TimeUnit.NANOSECONDS); } }

Target:
void handleJobCompletion(final JobFinishedEvent event) throws GenieException { final long start = System.nanoTime(); final String jobId = event.getId(); final Map<String, String> tags = MetricsUtils.newSuccessTagsMap(); try { Cluster cluster; Command command; try { cluster = this.jobSearchService.getJobCluster(jobId); } catch (final Exception e) { log.warn("Unable to tag metrics with cluster", e); cluster = null; } try { command = this.jobSearchService.getJobCommand(jobId); } catch (final Exception e) { log.warn("Unable to tag metrics with command", e); command = null; } MetricsUtils.addClusterAndCommandTags(cluster, command, tags); final Job job = this.retryTemplate.execute(context -> this.getJob(jobId)); final JobStatus status = job.getStatus(); if (status.isActive()) { try { this.retryTemplate.execute(context -> this.updateJob(job, event, tags)); } catch (final Exception e) { log.error("Failed updating for job: {}", jobId, e); } try { this.retryTemplate.execute(context -> this.processJobDir(job)); } catch (final Exception e) { log.error("Failed archiving directory for job: {}", jobId, e); this.incrementErrorCounter("JOB_DIRECTORY_FAILURE", e); } try { this.retryTemplate.execute(context -> sendEmail(jobId)); } catch (final Exception e) { log.error("Failed sending email for job: {}", jobId, e); this.incrementErrorCounter("JOB_UPDATE_FAILURE", e); } } } catch (final Exception e) { log.error("Failed getting job with id: {}", jobId, e); MetricsUtils.addFailureTagsWithException(tags, e); } finally { this.registry .timer(this.jobCompletionTimerId.withTags(tags)) .record(System.nanoTime() - start, TimeUnit.NANOSECONDS); } }