From d646d6e668a6f30f5438f70156dbe0bb13326e43 Mon Sep 17 00:00:00 2001 From: NipunaMadhushan Date: Tue, 19 Nov 2024 21:53:07 +0530 Subject: [PATCH] Add metrics logs provider configuration --- ballerina/commons.bal | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/ballerina/commons.bal b/ballerina/commons.bal index be73c21..9bfb302 100644 --- a/ballerina/commons.bal +++ b/ballerina/commons.bal @@ -24,11 +24,13 @@ configurable string metricsReporter = ""; configurable boolean tracingEnabled = false; configurable string tracingProvider = ""; configurable boolean metricsLogsEnabled = false; +configurable string metricsLogsProvider = ""; function init() returns error? { boolean isMissingMetricsReporter = ((enabled || metricsEnabled) && (provider == "" && metricsReporter == "")); boolean isMissingTracingProvider = ((enabled || tracingEnabled) && (provider == "" && tracingProvider == "")); - if (isMissingMetricsReporter || isMissingTracingProvider) { + boolean isMissingMetricsLogsProvider = ((enabled || metricsLogsEnabled) && (provider == "" && metricsLogsProvider == "")); + if (isMissingMetricsReporter || isMissingTracingProvider || isMissingMetricsLogsProvider) { string[] enabledObservers = []; string[] missingProviders = []; if (isMissingMetricsReporter) { @@ -39,6 +41,10 @@ function init() returns error? { enabledObservers.push("tracing"); missingProviders.push("tracing provider"); } + if (isMissingMetricsLogsProvider) { + enabledObservers.push("metrics logs"); + missingProviders.push("metrics logs provider"); + } return error("Observability (" + " and ".join(...enabledObservers) + ") enabled without " + " and ".join(...missingProviders) + ". Please visit https://central.ballerina.io/ballerina/observe for " + "the list of officially supported Observability providers."); @@ -61,6 +67,13 @@ public isolated function isMetricsEnabled() returns boolean = @java:Method { 'class: "io.ballerina.runtime.observability.ObserveUtils" } external; +# Check whether metrics logs is enabled. +# + return - metrics enabled/disabled. +public isolated function isMetricsLogsEnabled() returns boolean = @java:Method { + name: "isMetricsLogsEnabled", + 'class: "io.ballerina.runtime.observability.ObserveUtils" +} external; + # Retrieve metrics provider. # + return - metrics provider. public isolated function getMetricsProvider() returns string = @java:Method { @@ -68,6 +81,13 @@ public isolated function getMetricsProvider() returns string = @java:Method { 'class: "io.ballerina.runtime.observability.ObserveUtils" } external; +# Retrieve metrics logs provider. +# + return - metrics logs provider. +public isolated function getMetricsLogsProvider() returns string = @java:Method { + name: "getMetricsLogsProvider", + 'class: "io.ballerina.runtime.observability.ObserveUtils" +} external; + # Retrieve metrics reporter. # + return - metrics reporter. public isolated function getMetricsReporter() returns string = @java:Method {