From 0a2ad8dadbc6e4fa4b8cad117e0ccbc398fd33f6 Mon Sep 17 00:00:00 2001 From: NipunaMadhushan Date: Fri, 22 Nov 2024 14:28:05 +0530 Subject: [PATCH] Fix checkstyle errors --- .../stdlib/observe/internal/NativeFunctions.java | 6 +++--- .../observers/BallerinaMetricsLogsObserver.java | 8 +++++--- .../observe/observers/BallerinaMetricsObserver.java | 11 +++++++++-- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/native/src/main/java/io/ballerina/stdlib/observe/internal/NativeFunctions.java b/native/src/main/java/io/ballerina/stdlib/observe/internal/NativeFunctions.java index bb5f27b..34651d1 100644 --- a/native/src/main/java/io/ballerina/stdlib/observe/internal/NativeFunctions.java +++ b/native/src/main/java/io/ballerina/stdlib/observe/internal/NativeFunctions.java @@ -21,16 +21,16 @@ import io.ballerina.runtime.api.values.BError; import io.ballerina.runtime.api.values.BString; import io.ballerina.runtime.observability.ObserveUtils; -import io.ballerina.stdlib.observe.observers.BallerinaMetricsLogsObserver; -import io.ballerina.stdlib.observe.observers.BallerinaMetricsObserver; import io.ballerina.runtime.observability.metrics.DefaultMetricRegistry; import io.ballerina.runtime.observability.metrics.MetricRegistry; import io.ballerina.runtime.observability.metrics.noop.NoOpMetricProvider; import io.ballerina.runtime.observability.metrics.spi.MetricProvider; -import io.ballerina.stdlib.observe.observers.BallerinaTracingObserver; import io.ballerina.runtime.observability.tracer.TracersStore; import io.ballerina.runtime.observability.tracer.noop.NoOpTracerProvider; import io.ballerina.runtime.observability.tracer.spi.TracerProvider; +import io.ballerina.stdlib.observe.observers.BallerinaMetricsLogsObserver; +import io.ballerina.stdlib.observe.observers.BallerinaMetricsObserver; +import io.ballerina.stdlib.observe.observers.BallerinaTracingObserver; import java.io.PrintStream; import java.util.ServiceLoader; diff --git a/native/src/main/java/io/ballerina/stdlib/observe/observers/BallerinaMetricsLogsObserver.java b/native/src/main/java/io/ballerina/stdlib/observe/observers/BallerinaMetricsLogsObserver.java index f4a0ab1..a705496 100644 --- a/native/src/main/java/io/ballerina/stdlib/observe/observers/BallerinaMetricsLogsObserver.java +++ b/native/src/main/java/io/ballerina/stdlib/observe/observers/BallerinaMetricsLogsObserver.java @@ -24,7 +24,6 @@ import io.ballerina.runtime.api.values.BMap; import io.ballerina.runtime.api.values.BString; import io.ballerina.runtime.observability.BallerinaObserver; -import io.ballerina.runtime.observability.ObserveUtils; import io.ballerina.runtime.observability.ObserverContext; import io.ballerina.runtime.observability.metrics.Tag; @@ -34,10 +33,13 @@ import java.util.Optional; import java.util.Set; -import static io.ballerina.runtime.observability.ObservabilityConstants.*; +import static io.ballerina.runtime.observability.ObservabilityConstants.PROPERTY_KEY_HTTP_STATUS_CODE; +import static io.ballerina.runtime.observability.ObservabilityConstants.STATUS_CODE_GROUP_SUFFIX; +import static io.ballerina.runtime.observability.ObservabilityConstants.TAG_KEY_HTTP_STATUS_CODE_GROUP; public class BallerinaMetricsLogsObserver implements BallerinaObserver { private static final String ORG_NAME = "ballerinax"; + private static final String MODULE_NAME = "metrics.logs"; private static final String METRIC_LOG_FUNCTION_NAME = "printMetricsLog"; private static final String PROPERTY_START_TIME = "_observation_start_time_"; private static final PrintStream consoleError = System.err; @@ -121,7 +123,7 @@ private void handleError(String metricName, Set tags, RuntimeException e) { private static void printMetricLog(BMap logAttributes) { // TODO: Remove version when the API is finalized, and add the configured org name. - Module metricsLogsModule = new Module(ORG_NAME, ObserveUtils.getMetricsLogsProvider().getValue(), "1"); + Module metricsLogsModule = new Module(ORG_NAME, MODULE_NAME, "1"); environment.getRuntime().callFunction(metricsLogsModule, METRIC_LOG_FUNCTION_NAME, null, logAttributes); } } diff --git a/native/src/main/java/io/ballerina/stdlib/observe/observers/BallerinaMetricsObserver.java b/native/src/main/java/io/ballerina/stdlib/observe/observers/BallerinaMetricsObserver.java index 093bb36..da409ed 100644 --- a/native/src/main/java/io/ballerina/stdlib/observe/observers/BallerinaMetricsObserver.java +++ b/native/src/main/java/io/ballerina/stdlib/observe/observers/BallerinaMetricsObserver.java @@ -19,7 +19,12 @@ import io.ballerina.runtime.observability.BallerinaObserver; import io.ballerina.runtime.observability.ObserverContext; -import io.ballerina.runtime.observability.metrics.*; +import io.ballerina.runtime.observability.metrics.DefaultMetricRegistry; +import io.ballerina.runtime.observability.metrics.Gauge; +import io.ballerina.runtime.observability.metrics.MetricId; +import io.ballerina.runtime.observability.metrics.MetricRegistry; +import io.ballerina.runtime.observability.metrics.StatisticConfig; +import io.ballerina.runtime.observability.metrics.Tag; import java.io.PrintStream; import java.time.Duration; @@ -27,7 +32,9 @@ import java.util.Map; import java.util.Set; -import static io.ballerina.runtime.observability.ObservabilityConstants.*; +import static io.ballerina.runtime.observability.ObservabilityConstants.PROPERTY_KEY_HTTP_STATUS_CODE; +import static io.ballerina.runtime.observability.ObservabilityConstants.STATUS_CODE_GROUP_SUFFIX; +import static io.ballerina.runtime.observability.ObservabilityConstants.TAG_KEY_HTTP_STATUS_CODE_GROUP; /** * Observe the runtime and collect measurements.