Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ballerina/regex dependency #152

Merged
merged 4 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading