Skip to content

Commit

Permalink
Merge pull request #152 from NipunaMadhushan/test-java
Browse files Browse the repository at this point in the history
Remove ballerina/regex dependency
  • Loading branch information
keizer619 authored Apr 30, 2024
2 parents bc8d456 + bdb83df commit 364eeed
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ jobs:
./gradlew clean build --stacktrace --scan --console=plain --no-daemon
./gradlew codeCoverageReport --console=plain --no-daemon
- name: Upload Coverage Report
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}

windows-build:
runs-on: windows-latest
Expand Down
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ subprojects {
ballerinaStdLibs "io.ballerina:observe-ballerina:${observeInternalVersion}"

// Standard Library Dependencies
ballerinaStdLibs "io.ballerina.stdlib:regex-ballerina:${stdlibRegexVersion}"
ballerinaStdLibs "io.ballerina.stdlib:http-ballerina:${stdlibHttpVersion}"

// Standard Library Transitive Dependencies
Expand Down
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 364eeed

Please sign in to comment.