diff --git a/airbyte-connector-builder-server/src/main/java/io/airbyte/connector_builder/config/MetricClientFactory.java b/airbyte-connector-builder-server/src/main/java/io/airbyte/connector_builder/config/MetricClientFactory.java new file mode 100644 index 00000000000..b319a1d15b7 --- /dev/null +++ b/airbyte-connector-builder-server/src/main/java/io/airbyte/connector_builder/config/MetricClientFactory.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2020-2024 Airbyte, Inc., all rights reserved. + */ + +package io.airbyte.connector_builder.config; + +import io.airbyte.metrics.lib.MetricClient; +import io.airbyte.metrics.lib.MetricEmittingApps; +import io.micronaut.context.annotation.Factory; +import io.micronaut.context.annotation.Replaces; +import jakarta.inject.Singleton; + +/** + * Micronaut singleton factory for the creation and initialization of the {@link MetricClient}. + */ +@Factory +public class MetricClientFactory { + + /** + * Creates and initializes the {@link MetricClient}. + * + * @return The initialized {@link MetricClient}. + */ + @Singleton + @Replaces(MetricClient.class) + public MetricClient metricClient() { + // Initialize the metric client + io.airbyte.metrics.lib.MetricClientFactory.initialize(MetricEmittingApps.CONNECTOR_BUILDER_SERVER); + return io.airbyte.metrics.lib.MetricClientFactory.getMetricClient(); + } + +} diff --git a/airbyte-metrics/metrics-lib/src/main/java/io/airbyte/metrics/lib/MetricEmittingApps.java b/airbyte-metrics/metrics-lib/src/main/java/io/airbyte/metrics/lib/MetricEmittingApps.java index bf0c61d2c29..e0712ce8b6f 100644 --- a/airbyte-metrics/metrics-lib/src/main/java/io/airbyte/metrics/lib/MetricEmittingApps.java +++ b/airbyte-metrics/metrics-lib/src/main/java/io/airbyte/metrics/lib/MetricEmittingApps.java @@ -31,7 +31,8 @@ public enum MetricEmittingApps implements MetricEmittingApp { WORKER("worker"), WORKLOAD_API("workload-api"), WORKLOAD_INIT("workload-init"), - WORKLOAD_LAUNCHER("workload-launcher"); + WORKLOAD_LAUNCHER("workload-launcher"), + CONNECTOR_BUILDER_SERVER("connector-builder-server"); private final String applicationName;