Skip to content

Commit

Permalink
Remove ballerina/regex dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
NipunaMadhushan committed Apr 25, 2024
1 parent 9fa0930 commit 262bfc1
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 11 deletions.
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ observeInternalVersion=1.2.2-20240404-122400-22ed15c
stdlibConstraintVersion=1.4.0-20230831-142400-50e4023
stdlibHttpVersion=2.10.13-20240327-141300-ecd1355
stdlibIoVersion=1.6.0-20230831-135000-049f91a
stdlibRegexVersion=1.3.2
stdlibOsVersion=1.8.0-20230831-142200-cb96913
stdlibTimeVersion=2.4.0-20230831-134800-62143cd
stdlibUrlVersion=2.4.0-20230831-134600-aab5a12
Expand Down
5 changes: 0 additions & 5 deletions prometheus-extension-ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ org = "ballerina"
name = "io"
version = "@stdlib.io.version@"

[[dependency]]
org = "ballerina"
name = "regex"
version = "@stdlib.regex.version@"

[[dependency]]
org = "ballerina"
name = "http"
Expand Down
2 changes: 0 additions & 2 deletions prometheus-extension-ballerina/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,13 @@ def stripBallerinaExtensionVersion(String extVersion) {
task updateTomlVerions {
doLast {
def stdlibDependentIoVersion = stripBallerinaExtensionVersion(project.stdlibIoVersion)
def stdlibDependentRegexVersion = stripBallerinaExtensionVersion(project.stdlibRegexVersion)
def stdlibDependentHttpVersion = stripBallerinaExtensionVersion(project.stdlibHttpVersion)

def newConfig = ballerinaConfigFile.text.replace("@project.version@", project.version)
newConfig = newConfig.replace("@toml.version@", tomlVersion)
ballerinaConfigFile.text = newConfig

def newDependencyConfig = ballerinaDependencyFile.text.replace("@stdlib.io.version@", stdlibDependentIoVersion)
newDependencyConfig = newDependencyConfig.replace("@stdlib.regex.version@", stdlibDependentRegexVersion)
newDependencyConfig = newDependencyConfig.replace("@stdlib.http.version@", stdlibDependentHttpVersion)
ballerinaDependencyFile.text = newDependencyConfig
}
Expand Down
7 changes: 4 additions & 3 deletions prometheus-extension-ballerina/metric_reporter.bal
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import ballerina/io;
import ballerina/http;
import ballerina/lang.'string as str;
import ballerina/observe;
import ballerina/regex;

const REPORTER_NAME = "prometheus";

Expand Down Expand Up @@ -161,7 +160,8 @@ isolated function getTagsString(map<string> labels) returns string {
# + str - string to be escaped.
# + return - escaped string.
isolated function getEscapedName(string str) returns string {
return regex:replaceAll(str, "[^a-zA-Z0-9:_]", "_");
string:RegExp regExp = re `[^a-zA-Z0-9:_]`;
return regExp.replaceAll(str, "_");
}

# Only [^a-zA-Z0-9\\/.:_* ] are valid in metric lable values, any other characters
Expand All @@ -170,7 +170,8 @@ isolated function getEscapedName(string str) returns string {
# + str - string to be escaped.
# + return - escaped string.
isolated function getEscapedLabelValue(string str) returns string {
return regex:replaceAll(str, "[^a-zA-Z0-9\\/.:_* ]", "_");
string:RegExp regExp = re `[^a-zA-Z0-9\\/.:_* ]`;
return regExp.replaceAll(str, "_");
}

# Add the summary type name to summary type metrics.
Expand Down

0 comments on commit 262bfc1

Please sign in to comment.