From 63e39e6142f8a4accd42994068315168789d41f4 Mon Sep 17 00:00:00 2001 From: Cole Snodgrass Date: Tue, 11 Oct 2022 16:03:02 -0700 Subject: [PATCH] fix metric reporter not producing metrics (#17863) * init metric client before fetching it * move init to Application * semi-colon * remove double query --- .../main/java/io/airbyte/metrics/reporter/Application.java | 3 +++ .../java/io/airbyte/metrics/reporter/MetricRepository.java | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/airbyte-metrics/reporter/src/main/java/io/airbyte/metrics/reporter/Application.java b/airbyte-metrics/reporter/src/main/java/io/airbyte/metrics/reporter/Application.java index f64527149ba7..f8af2de13b23 100644 --- a/airbyte-metrics/reporter/src/main/java/io/airbyte/metrics/reporter/Application.java +++ b/airbyte-metrics/reporter/src/main/java/io/airbyte/metrics/reporter/Application.java @@ -4,6 +4,8 @@ package io.airbyte.metrics.reporter; +import io.airbyte.metrics.lib.MetricClientFactory; +import io.airbyte.metrics.lib.MetricEmittingApps; import io.micronaut.runtime.Micronaut; /** @@ -14,6 +16,7 @@ public class Application { public static void main(final String[] args) { + MetricClientFactory.initialize(MetricEmittingApps.METRICS_REPORTER); Micronaut.run(Application.class, args); } diff --git a/airbyte-metrics/reporter/src/main/java/io/airbyte/metrics/reporter/MetricRepository.java b/airbyte-metrics/reporter/src/main/java/io/airbyte/metrics/reporter/MetricRepository.java index 267426209283..b36f6ad15b30 100644 --- a/airbyte-metrics/reporter/src/main/java/io/airbyte/metrics/reporter/MetricRepository.java +++ b/airbyte-metrics/reporter/src/main/java/io/airbyte/metrics/reporter/MetricRepository.java @@ -146,8 +146,9 @@ SELECT status, extract(epoch from age(updated_at, created_at)) AS sec FROM jobs WHERE updated_at >= NOW() - INTERVAL '1 HOUR' AND (jobs.status = 'failed' OR jobs.status = 'succeeded' OR jobs.status = 'cancelled'); """; - final var statuses = ctx.fetch(query).getValues("status", JobStatus.class); - final var times = ctx.fetch(query).getValues("sec", double.class); + final var queryResults = ctx.fetch(query); + final var statuses = queryResults.getValues("status", JobStatus.class); + final var times = queryResults.getValues("sec", double.class); final var results = new HashMap(); for (int i = 0; i < statuses.size(); i++) {