diff --git a/.github/workflows/build-main.yml b/.github/workflows/build-main.yml index eb17fb64..4b585a4f 100644 --- a/.github/workflows/build-main.yml +++ b/.github/workflows/build-main.yml @@ -2,10 +2,18 @@ name: Build on: workflow_dispatch: + inputs: + ballerina_version: + description: 'Ballerina version' + required: true + default: '2201.9.0' push: branches: - main +env: + BALLERINA_DISTRIBUTION_VERSION: 2201.9.0 # Update this with the latest Ballerina version + jobs: build: runs-on: ubuntu-latest @@ -16,8 +24,27 @@ jobs: - name: Set up JDK 17 uses: actions/setup-java@v3 with: - distribution: adopt + distribution: 'temurin' java-version: 17.0.7 + - name: Set up Ballerina + if: github.event_name == 'workflow_dispatch' + uses: ballerina-platform/setup-ballerina@v1.1.0 + with: + version: ${{ github.event.inputs.ballerina_version }} + - name: Set up Ballerina + if: github.event_name == 'push' + uses: ballerina-platform/setup-ballerina@v1.1.0 + with: + version: ${{ env.BALLERINA_DISTRIBUTION_VERSION }} + - name: Change to Timestamped Version + run: | + startTime=$(TZ="Asia/Kolkata" date +'%Y%m%d-%H%M00') + latestCommit=$(git log -n 1 --pretty=format:"%h") + VERSION=$((grep -w 'version' | cut -d= -f2) < gradle.properties | rev | cut --complement -d- -f1 | rev) + updatedVersion=$VERSION-$startTime-$latestCommit + echo $updatedVersion + echo TIMESTAMPED_VERSION=$updatedVersion >> $GITHUB_ENV + sed -i "s/version=\(.*\)/version=$updatedVersion/g" gradle.properties - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Set Docker Host env variable @@ -40,5 +67,5 @@ jobs: with: name: distribution path: | - jaeger-extension-ballerina/build/distributions/jaeger-extension-ballerina-*.zip + ballerina/build/distributions/jaeger-extension-ballerina-*.zip if-no-files-found: error diff --git a/.github/workflows/central-publish.yml b/.github/workflows/central-publish.yml index 5afb9c37..08a72c13 100644 --- a/.github/workflows/central-publish.yml +++ b/.github/workflows/central-publish.yml @@ -3,6 +3,10 @@ name: Publish to the Ballerina central on: workflow_dispatch: inputs: + ballerina_version: + description: 'Ballerina version' + required: true + default: '2201.9.0' environment: type: choice description: Select environment @@ -23,18 +27,20 @@ jobs: with: distribution: 'temurin' java-version: 17.0.7 + - name: Set up Ballerina + uses: ballerina-platform/setup-ballerina@v1.1.0 + with: + version: ${{ github.event.inputs.ballerina_version }} - name: Build with Gradle env: packageUser: ${{ github.actor }} packagePAT: ${{ secrets.GITHUB_TOKEN }} run: ./gradlew build -x check -x test - - name: Create lib directory if not exists - run: mkdir -p jaeger-extension-ballerina/lib - name: Run Trivy vulnerability scanner uses: aquasecurity/trivy-action@master with: scan-type: 'rootfs' - scan-ref: '/github/workspace/jaeger-extension-ballerina/lib' + scan-ref: '/github/workspace/ballerina/lib' format: 'table' timeout: '10m0s' exit-code: '1' diff --git a/.github/workflows/daily-build.yml b/.github/workflows/daily-build.yml index 7d8f9396..ac57090f 100644 --- a/.github/workflows/daily-build.yml +++ b/.github/workflows/daily-build.yml @@ -1,31 +1,66 @@ -name: Daily build +name: Daily Build on: schedule: - - cron: '30 2 * * *' + - cron: '30 18 * * *' + workflow_dispatch: + inputs: + ballerina_version: + description: 'Ballerina version' + required: true + default: '2201.9.0' + +env: + BALLERINA_DISTRIBUTION_VERSION: 2201.9.0 # Update this with the latest Ballerina version jobs: build: runs-on: ubuntu-latest - + if: github.repository_owner == 'ballerina-platform' steps: - - uses: actions/checkout@v3 - + - name: Checkout Repository + uses: actions/checkout@v3 - name: Set up JDK 17 uses: actions/setup-java@v3 with: - distribution: adopt + distribution: 'temurin' java-version: 17.0.7 - - # Build the project with Gradle + - name: Set up Ballerina + if: github.event_name == 'workflow_dispatch' + uses: ballerina-platform/setup-ballerina@v1.1.0 + with: + version: ${{ github.event.inputs.ballerina_version }} + - name: Set up Ballerina + if: github.event_name == 'push' + uses: ballerina-platform/setup-ballerina@v1.1.0 + with: + version: ${{ env.BALLERINA_DISTRIBUTION_VERSION }} + - name: Change to Timestamped Version + run: | + startTime=$(TZ="Asia/Kolkata" date +'%Y%m%d-%H%M00') + latestCommit=$(git log -n 1 --pretty=format:"%h") + VERSION=$((grep -w 'version' | cut -d= -f2) < gradle.properties | rev | cut --complement -d- -f1 | rev) + updatedVersion=$VERSION-$startTime-$latestCommit + echo $updatedVersion + echo TIMESTAMPED_VERSION=$updatedVersion >> $GITHUB_ENV + sed -i "s/version=\(.*\)/version=$updatedVersion/g" gradle.properties + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Set Docker Host env variable + run: echo "DOCKER_HOST=$(docker context ls --format '{{print .DockerEndpoint}}' | tr -d '\n')" >> $GITHUB_ENV - name: Build with Gradle env: - packageUser: ${{ github.actor }} - packagePAT: ${{ secrets.GITHUB_TOKEN }} + DOCKER_HOST: unix:///var/run/docker.sock + packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }} + packagePAT: ${{ secrets.BALLERINA_BOT_TOKEN }} + packagePublishRepo: ${{ github.repository }} run: | - ./gradlew clean build - - # Send notification when build fails + ./gradlew clean build publish --stacktrace --scan --console=plain --no-daemon + ./gradlew codeCoverageReport --console=plain --no-daemon + - name: Upload Coverage Report + uses: codecov/codecov-action@v1 + with: + fail_ci_if_error: true - name: Notify failure if: ${{ failure() }} run: | diff --git a/.github/workflows/graalvm-check.yml b/.github/workflows/graalvm-check.yml index 381093e1..e90ef61f 100644 --- a/.github/workflows/graalvm-check.yml +++ b/.github/workflows/graalvm-check.yml @@ -4,6 +4,14 @@ on: schedule: - cron: '30 18 * * *' workflow_dispatch: + inputs: + ballerina_version: + description: 'Ballerina version' + required: true + default: '2201.9.0' + +env: + BALLERINA_DISTRIBUTION_VERSION: 2201.9.0 # Update this with the latest Ballerina version jobs: build: @@ -11,7 +19,6 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up GraalVM uses: graalvm/setup-graalvm@v1 with: @@ -19,16 +26,23 @@ jobs: java-version: '17.0.7' components: 'native-image' github-token: ${{ secrets.GITHUB_TOKEN }} - - name: Check GraalVM installation run: | echo "GRAALVM_HOME: ${{ env.GRAALVM_HOME }}" echo "JAVA_HOME: ${{ env.JAVA_HOME }}" native-image --version - + - name: Set up Ballerina + if: github.event_name == 'workflow_dispatch' + uses: ballerina-platform/setup-ballerina@v1.1.0 + with: + version: ${{ github.event.inputs.ballerina_version }} + - name: Set up Ballerina + if: github.event_name == 'schedule' + uses: ballerina-platform/setup-ballerina@v1.1.0 + with: + version: ${{ env.BALLERINA_DISTRIBUTION_VERSION }} - name: Grant execute permission for gradlew run: chmod +x gradlew - - name: Build with Gradle env: packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }} @@ -36,21 +50,13 @@ jobs: JAVA_OPTS: -DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true run: | ./gradlew build - - - name: Set Up Ballerina - uses: ballerina-platform/setup-ballerina@v1 - with: - version: 2201.6.0 - - name: Update dependency versions run: ./gradlew :jaeger-extension-ballerina:updateTomlVerions env: packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }} packagePAT: ${{ secrets.BALLERINA_BOT_TOKEN }} JAVA_OPTS: -DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true - - name: Run Ballerina build using the native executable - run: bal build --native ./jaeger-extension-ballerina - + run: bal build --native ./ballerina - name: Run Ballerina tests using the native executable - run: bal test --native ./jaeger-extension-ballerina + run: bal test --native ./ballerina diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index b8fa9166..a4073b85 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -1,6 +1,12 @@ name: Publish Release -on: [workflow_dispatch] +on: + workflow_dispatch: + inputs: + distribution_version: + description: 'Ballerina distribution version (e.g.; 2201.9.0)' + required: true + default: '2201.9.0' jobs: publish-release: @@ -12,8 +18,12 @@ jobs: - name: Set up JDK 17 uses: actions/setup-java@v3 with: - distribution: adopt + distribution: 'temurin' java-version: 17.0.7 + - name: Set up Ballerina + uses: ballerina-platform/setup-ballerina@v1.1.0 + with: + version: ${{ github.event.inputs.ballerina_version }} - name: Set version env variable run: echo "VERSION=$((grep -w 'version' | cut -d= -f2) < gradle.properties | rev | cut --complement -d- -f1 | rev)" >> $GITHUB_ENV - name: Pre release depenency version update @@ -24,18 +34,25 @@ jobs: git config user.name ${{ secrets.BALLERINA_BOT_USERNAME }} git config user.email ${{ secrets.BALLERINA_BOT_EMAIL }} git checkout -b release-${VERSION} - sed -i 's/ballerinaLangVersion=\(.*\)-SNAPSHOT/ballerinaLangVersion=\1/g' gradle.properties - sed -i 's/ballerinaLangVersion=\(.*\)-[0-9]\{8\}-[0-9]\{6\}-.*$/ballerinaLangVersion=\1/g' gradle.properties - sed -i 's/observe\(.*\)=\(.*\)-SNAPSHOT/observe\1=\2/g' gradle.properties - sed -i 's/observe\(.*\)=\(.*\)-[0-9]\{8\}-[0-9]\{6\}-.*$/observe\1=\2/g' gradle.properties - sed -i 's/stdlib\(.*\)=\(.*\)-SNAPSHOT/stdlib\1=\2/g' gradle.properties - sed -i 's/stdlib\(.*\)=\(.*\)-[0-9]\{8\}-[0-9]\{6\}-.*$/stdlib\1=\2/g' gradle.properties git add gradle.properties git commit -m "Move dependencies to stable version" || echo "No changes to commit" - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Set Docker Host env variable run: echo "DOCKER_HOST=$(docker context ls --format '{{print .DockerEndpoint}}' | tr -d '\n')" >> $GITHUB_ENV + - name: Build with Gradle + env: + packageUser: ${{ github.actor }} + packagePAT: ${{ secrets.GITHUB_TOKEN }} + run: ./gradlew build -x check -x test + - name: Run Trivy vulnerability scanner + uses: aquasecurity/trivy-action@master + with: + scan-type: 'rootfs' + scan-ref: '/github/workspace/ballerina/lib' + format: 'table' + timeout: '10m0s' + exit-code: '1' - name: Publish artifact env: DOCKER_HOST: unix:///var/run/docker.sock @@ -45,11 +62,12 @@ jobs: packagePAT: ${{ secrets.BALLERINA_BOT_TOKEN }} packagePublishRepo: ${{ github.repository }} run: | + git stash ./gradlew release -Prelease.useAutomaticVersion=true ./gradlew -Pversion=${VERSION} publish -x test - name: Create Github release from the release tag run: | - curl --request POST 'https://api.github.com/repos/ballerina-platform/module-ballerinax-jaeger/releases' \ + curl --request POST 'https://api.github.com/repos/${{ github.repository }}/releases' \ --header 'Accept: application/vnd.github.v3+json' \ --header 'Authorization: Bearer ${{ secrets.BALLERINA_BOT_TOKEN }}' \ --header 'Content-Type: application/json' \ diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 16661e79..660927e2 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -2,6 +2,9 @@ name: Validate Pull Request on: pull_request +env: + BALLERINA_DISTRIBUTION_VERSION: 2201.9.0 # Update this with the latest Ballerina version + jobs: ubuntu-build: runs-on: ubuntu-latest @@ -13,6 +16,10 @@ jobs: with: distribution: adopt java-version: 17.0.7 + - name: Set up Ballerina + uses: ballerina-platform/setup-ballerina@v1.1.0 + with: + version: ${{ env.BALLERINA_DISTRIBUTION_VERSION }} - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Set Docker Host env variable @@ -25,33 +32,6 @@ 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 - with: - fail_ci_if_error: true - - windows-build: - if: false # because there is no opentelemetry-jaeger-executable available - runs-on: windows-latest - steps: - - name: Checkout Repository - uses: actions/checkout@v3 - - name: Set up JDK 17 - uses: actions/setup-java@v3 + uses: codecov/codecov-action@v3 with: - distribution: adopt - java-version: 17.0.7 - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Download Jaeger server executable - env: - JAEGER_VERSION: 1.21.0 - run: | - Invoke-WebRequest https://github.com/jaegertracing/jaeger/releases/download/v$env:JAEGER_VERSION/jaeger-$env:JAEGER_VERSION-windows-amd64.tar.gz -O jaeger.tar.gz - tar -xzvf jaeger.tar.gz - mv jaeger-$env:JAEGER_VERSION-windows-amd64 jaeger - echo "JAEGER_SERVER_EXECUTABLE=$(Resolve-Path jaeger\jaeger-all-in-one.exe)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - - name: Build with Gradle - env: - packageUser: ${{ github.actor }} - packagePAT: ${{ secrets.GITHUB_TOKEN }} - run: ./gradlew.bat clean build --stacktrace --scan --console=plain --no-daemon + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.gitignore b/.gitignore index 12a2c2cb..12afb611 100644 --- a/.gitignore +++ b/.gitignore @@ -38,6 +38,8 @@ build/ gradle-app.setting !gradle-wrapper.jar .gradletasknamecache +.DS_Store # Ballerina target/ +bin/ diff --git a/ballerina-tests/build.gradle b/ballerina-tests/build.gradle new file mode 100644 index 00000000..2a2ec79b --- /dev/null +++ b/ballerina-tests/build.gradle @@ -0,0 +1,205 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com) All Rights Reserved. + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.tools.ant.taskdefs.condition.Os + +description = 'Ballerina - Jaeger Extension - Ballerina Tests' + +configurations { + nativeJar { + transitive false + } + externalJars { + transitive false + } + distribution { + canBeConsumed true + canBeResolved false + } +} + +clean { + delete "${project.projectDir}/target" + delete "${project.projectDir}/Ballerina.lock" + delete "${project.projectDir}/ballerina-internal.log" +} + +jar { + manifest { + attributes('Implementation-Title': project.name, 'Implementation-Version': project.version) + } +} + +def groupParams = "" +def disableGroups = "" +def windowsDisableGroups = "--disable-groups disabledOnWindows" +def debugParams = "" +def balJavaDebugParam = "" +def testParams = "" +def nativeFlag = "" + +def packageOrg = "ballerinax" +def packageName = "jaeger" +def tomlVersion = stripBallerinaExtensionVersion("${project.version}") +def testPackages = ["jaeger-server-tests"] + +def jaegerServerTestConfigFile = new File("${project.projectDir}/jaeger-server-tests/Ballerina.toml") +def jaegerServerTestOriginalConfig = jaegerServerTestConfigFile.text +def jaegerServerTestDependenciesFile = new File("${project.projectDir}/jaeger-server-tests/Dependencies.toml") +def jaegerServerTestOriginalDependencies = jaegerServerTestDependenciesFile.text + +def stripBallerinaExtensionVersion(String extVersion) { + if (extVersion.matches(project.ext.timestampedVersionRegex)) { + def splitVersion = extVersion.split('-'); + if (splitVersion.length > 3) { + def strippedValues = splitVersion[0..-4] + return strippedValues.join('-') + } else { + return extVersion + } + } else { + return extVersion.replace("${project.ext.snapshotVersion}", "") + } +} + +def skipTests = false + +gradle.taskGraph.whenReady { graph -> + if (graph.hasTask(":jaeger-extension-ballerina-tests:ballerinaTest")) { + skipTests = true + } +} + +task initializeVariables { + if (project.hasProperty("groups")) { + groupParams = "--groups ${project.findProperty("groups")}" + } + if (project.hasProperty("disable")) { + disableGroups = "--disable-groups ${project.findProperty("disable")}" + } + if (project.hasProperty("debug")) { + debugParams = "--debug ${project.findProperty("debug")}" + } + if (project.hasProperty("balJavaDebug")) { + balJavaDebugParam = "BAL_JAVA_DEBUG=${project.findProperty("balJavaDebug")}" + } + if (project.hasProperty('balNativeTest')) { + nativeFlag = '--native' + } + if (project.hasProperty('balTests')) { + testPackages = project.findProperty('balTests').toString().split(",") + } + if (project.hasProperty('skipBalTests')) { + project.findProperty('skipBalTests').toString().split(",").each {testPackage -> + testPackages.remove(testPackage) + } + } +} + +task updateTomlVerions { + dependsOn ":jaeger-extension-ballerina:ballerinaBuild" + + doLast { + def newConfig = jaegerServerTestConfigFile.text.replace("@toml.version@", tomlVersion) + jaegerServerTestConfigFile.text = newConfig + def newDependencies = jaegerServerTestDependenciesFile.text.replace("@toml.version@", tomlVersion) + jaegerServerTestDependenciesFile.text = newDependencies + } +} + +task startJaegerServer() { + dependsOn ":jaeger-extension-ballerina:ballerinaBuild" + + doLast { + // This check is added to prevent starting the server in Windows OS, since the Docker image does not support + // for Windows OS. + if (!Os.isFamily(Os.FAMILY_WINDOWS)) { + def stdOut = new ByteArrayOutputStream() + exec { + commandLine 'sh', '-c', "docker ps --filter name=jaeger-server" + standardOutput = stdOut + } + if (!stdOut.toString().contains("jaeger-server")) { + println "Starting Jaeger server." + exec { + commandLine 'sh', '-c', "docker-compose -f $project.projectDir/resources/jaeger-server/docker-compose.yml up -d" + standardOutput = stdOut + } + println stdOut.toString() + println "Waiting 15s until the Jaeger server get initiated." + sleep(15 * 1000) + } else { + println "Jaeger server is already started." + } + } + } +} + +task stopJaegerServer() { + doLast { + // This check is added to prevent trying to stop the server in Windows OS, since the Docker image not started + // in Windows OS. + if (!Os.isFamily(Os.FAMILY_WINDOWS)) { + def stdOut = new ByteArrayOutputStream() + exec { + commandLine 'sh', '-c', "docker ps --filter name=jaeger-server" + standardOutput = stdOut + } + if (stdOut.toString().contains("jaeger-server")) { + println "Stopping LDAP server." + exec { + commandLine 'sh', '-c', "docker stop jaeger-server" + standardOutput = stdOut + } + println stdOut.toString() + println "Waiting 5s until the Jaeger server get stopped." + sleep(5 * 1000) + } else { + println "Jaeger server is not started." + } + } + } +} + +task revertTomlFile { + doLast { + jaegerServerTestConfigFile.text = jaegerServerTestOriginalConfig + jaegerServerTestDependenciesFile.text = jaegerServerTestOriginalDependencies + } +} + +task ballerinaTest { + dependsOn ":jaeger-extension-ballerina:ballerinaBuild" + dependsOn ":jaeger-extension-ballerina:publishBalaFileToLocal" + dependsOn initializeVariables + dependsOn updateTomlVerions + dependsOn startJaegerServer + + finalizedBy(revertTomlFile) + finalizedBy(stopJaegerServer) + + doLast { + testPackages.each { testPackage -> + def env = "JAVA_OPTS -DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true ${testParams} ${groupParams}" + + " ${disableGroups} ${windowsDisableGroups} ${debugParams}" + executeBalCommand("test", "${project.projectDir}/${testPackage}", env) + } + } +} + +test.dependsOn ballerinaTest diff --git a/ballerina-tests/jaeger-server-tests/.devcontainer.json b/ballerina-tests/jaeger-server-tests/.devcontainer.json new file mode 100644 index 00000000..22579f99 --- /dev/null +++ b/ballerina-tests/jaeger-server-tests/.devcontainer.json @@ -0,0 +1,4 @@ +{ + "image": "ballerina/ballerina-devcontainer:2201.8.0-20230830-220400-8a7556d8", + "extensions": ["WSO2.ballerina"], +} diff --git a/ballerina-tests/jaeger-server-tests/.gitignore b/ballerina-tests/jaeger-server-tests/.gitignore new file mode 100644 index 00000000..b61463aa --- /dev/null +++ b/ballerina-tests/jaeger-server-tests/.gitignore @@ -0,0 +1,2 @@ +target +generated diff --git a/ballerina-tests/jaeger-server-tests/Ballerina.toml b/ballerina-tests/jaeger-server-tests/Ballerina.toml new file mode 100644 index 00000000..6314c820 --- /dev/null +++ b/ballerina-tests/jaeger-server-tests/Ballerina.toml @@ -0,0 +1,14 @@ +[package] +org = "ballerinax" +name = "jaeger_server_tests" +version = "0.1.0" +distribution = "2201.8.3" + +[build-options] +observabilityIncluded = true + +[[dependency]] +org="ballerinax" +name="jaeger" +repository="local" +version = "@toml.version@" diff --git a/ballerina-tests/jaeger-server-tests/Config.toml b/ballerina-tests/jaeger-server-tests/Config.toml new file mode 100644 index 00000000..b34d4ca6 --- /dev/null +++ b/ballerina-tests/jaeger-server-tests/Config.toml @@ -0,0 +1,7 @@ +[ballerina.observe] +tracingEnabled=true +tracingProvider="jaeger" + +[ballerinax.jaeger] +agentHostname="localhost" # Optional Configuration. Default value is localhost +agentPort=4317 # Optional Configuration. Default value is 4317 diff --git a/ballerina-tests/jaeger-server-tests/Dependencies.toml b/ballerina-tests/jaeger-server-tests/Dependencies.toml new file mode 100644 index 00000000..4ef3c272 --- /dev/null +++ b/ballerina-tests/jaeger-server-tests/Dependencies.toml @@ -0,0 +1,358 @@ +# AUTO-GENERATED FILE. DO NOT MODIFY. + +# This file is auto-generated by Ballerina for managing dependency versions. +# It should not be modified by hand. + +[ballerina] +dependencies-toml-version = "2" +distribution-version = "2201.8.5-SNAPSHOT" + +[[package]] +org = "ballerina" +name = "auth" +version = "2.10.0" +dependencies = [ + {org = "ballerina", name = "crypto"}, + {org = "ballerina", name = "jballerina.java"}, + {org = "ballerina", name = "lang.array"}, + {org = "ballerina", name = "lang.string"}, + {org = "ballerina", name = "log"} +] + +[[package]] +org = "ballerina" +name = "cache" +version = "3.7.0" +dependencies = [ + {org = "ballerina", name = "constraint"}, + {org = "ballerina", name = "jballerina.java"}, + {org = "ballerina", name = "task"}, + {org = "ballerina", name = "time"} +] + +[[package]] +org = "ballerina" +name = "constraint" +version = "1.5.0" +dependencies = [ + {org = "ballerina", name = "jballerina.java"} +] + +[[package]] +org = "ballerina" +name = "crypto" +version = "2.6.1" +dependencies = [ + {org = "ballerina", name = "jballerina.java"}, + {org = "ballerina", name = "time"} +] + +[[package]] +org = "ballerina" +name = "file" +version = "1.9.0" +dependencies = [ + {org = "ballerina", name = "io"}, + {org = "ballerina", name = "jballerina.java"}, + {org = "ballerina", name = "os"}, + {org = "ballerina", name = "time"} +] + +[[package]] +org = "ballerina" +name = "http" +version = "2.10.5" +dependencies = [ + {org = "ballerina", name = "auth"}, + {org = "ballerina", name = "cache"}, + {org = "ballerina", name = "constraint"}, + {org = "ballerina", name = "crypto"}, + {org = "ballerina", name = "file"}, + {org = "ballerina", name = "io"}, + {org = "ballerina", name = "jballerina.java"}, + {org = "ballerina", name = "jwt"}, + {org = "ballerina", name = "lang.array"}, + {org = "ballerina", name = "lang.decimal"}, + {org = "ballerina", name = "lang.int"}, + {org = "ballerina", name = "lang.regexp"}, + {org = "ballerina", name = "lang.runtime"}, + {org = "ballerina", name = "lang.string"}, + {org = "ballerina", name = "lang.value"}, + {org = "ballerina", name = "log"}, + {org = "ballerina", name = "mime"}, + {org = "ballerina", name = "oauth2"}, + {org = "ballerina", name = "observe"}, + {org = "ballerina", name = "time"}, + {org = "ballerina", name = "url"} +] +modules = [ + {org = "ballerina", packageName = "http", moduleName = "http"}, + {org = "ballerina", packageName = "http", moduleName = "http.httpscerr"} +] + +[[package]] +org = "ballerina" +name = "io" +version = "1.6.0" +dependencies = [ + {org = "ballerina", name = "jballerina.java"}, + {org = "ballerina", name = "lang.value"} +] + +[[package]] +org = "ballerina" +name = "jballerina.java" +version = "0.0.0" + +[[package]] +org = "ballerina" +name = "jwt" +version = "2.10.0" +dependencies = [ + {org = "ballerina", name = "cache"}, + {org = "ballerina", name = "crypto"}, + {org = "ballerina", name = "jballerina.java"}, + {org = "ballerina", name = "lang.int"}, + {org = "ballerina", name = "lang.string"}, + {org = "ballerina", name = "log"}, + {org = "ballerina", name = "time"} +] + +[[package]] +org = "ballerina" +name = "lang.__internal" +version = "0.0.0" +dependencies = [ + {org = "ballerina", name = "jballerina.java"}, + {org = "ballerina", name = "lang.object"} +] + +[[package]] +org = "ballerina" +name = "lang.array" +version = "0.0.0" +dependencies = [ + {org = "ballerina", name = "jballerina.java"}, + {org = "ballerina", name = "lang.__internal"} +] + +[[package]] +org = "ballerina" +name = "lang.decimal" +version = "0.0.0" +dependencies = [ + {org = "ballerina", name = "jballerina.java"} +] + +[[package]] +org = "ballerina" +name = "lang.error" +version = "0.0.0" +scope = "testOnly" +dependencies = [ + {org = "ballerina", name = "jballerina.java"} +] + +[[package]] +org = "ballerina" +name = "lang.int" +version = "0.0.0" +dependencies = [ + {org = "ballerina", name = "jballerina.java"}, + {org = "ballerina", name = "lang.__internal"}, + {org = "ballerina", name = "lang.object"} +] + +[[package]] +org = "ballerina" +name = "lang.object" +version = "0.0.0" + +[[package]] +org = "ballerina" +name = "lang.regexp" +version = "0.0.0" +dependencies = [ + {org = "ballerina", name = "jballerina.java"} +] + +[[package]] +org = "ballerina" +name = "lang.runtime" +version = "0.0.0" +dependencies = [ + {org = "ballerina", name = "jballerina.java"} +] +modules = [ + {org = "ballerina", packageName = "lang.runtime", moduleName = "lang.runtime"} +] + +[[package]] +org = "ballerina" +name = "lang.string" +version = "0.0.0" +dependencies = [ + {org = "ballerina", name = "jballerina.java"}, + {org = "ballerina", name = "lang.regexp"} +] + +[[package]] +org = "ballerina" +name = "lang.value" +version = "0.0.0" +dependencies = [ + {org = "ballerina", name = "jballerina.java"} +] + +[[package]] +org = "ballerina" +name = "log" +version = "2.9.0" +dependencies = [ + {org = "ballerina", name = "io"}, + {org = "ballerina", name = "jballerina.java"}, + {org = "ballerina", name = "lang.value"}, + {org = "ballerina", name = "observe"} +] + +[[package]] +org = "ballerina" +name = "mime" +version = "2.9.0" +dependencies = [ + {org = "ballerina", name = "io"}, + {org = "ballerina", name = "jballerina.java"}, + {org = "ballerina", name = "lang.int"} +] + +[[package]] +org = "ballerina" +name = "oauth2" +version = "2.10.0" +dependencies = [ + {org = "ballerina", name = "cache"}, + {org = "ballerina", name = "crypto"}, + {org = "ballerina", name = "jballerina.java"}, + {org = "ballerina", name = "log"}, + {org = "ballerina", name = "time"}, + {org = "ballerina", name = "url"} +] + +[[package]] +org = "ballerina" +name = "observe" +version = "1.2.0" +dependencies = [ + {org = "ballerina", name = "jballerina.java"} +] +modules = [ + {org = "ballerina", packageName = "observe", moduleName = "observe"}, + {org = "ballerina", packageName = "observe", moduleName = "observe.mockextension"} +] + +[[package]] +org = "ballerina" +name = "os" +version = "1.8.0" +dependencies = [ + {org = "ballerina", name = "io"}, + {org = "ballerina", name = "jballerina.java"} +] + +[[package]] +org = "ballerina" +name = "task" +version = "2.5.0" +dependencies = [ + {org = "ballerina", name = "jballerina.java"}, + {org = "ballerina", name = "time"} +] + +[[package]] +org = "ballerina" +name = "test" +version = "0.0.0" +scope = "testOnly" +dependencies = [ + {org = "ballerina", name = "jballerina.java"}, + {org = "ballerina", name = "lang.error"} +] +modules = [ + {org = "ballerina", packageName = "test", moduleName = "test"} +] + +[[package]] +org = "ballerina" +name = "time" +version = "2.4.0" +dependencies = [ + {org = "ballerina", name = "jballerina.java"} +] + +[[package]] +org = "ballerina" +name = "toml" +version = "0.5.0" +scope = "testOnly" +dependencies = [ + {org = "ballerina", name = "file"}, + {org = "ballerina", name = "io"}, + {org = "ballerina", name = "time"} +] +modules = [ + {org = "ballerina", packageName = "toml", moduleName = "toml"}, + {org = "ballerina", packageName = "toml", moduleName = "toml.lexer"}, + {org = "ballerina", packageName = "toml", moduleName = "toml.parser"}, + {org = "ballerina", packageName = "toml", moduleName = "toml.writer"} +] + +[[package]] +org = "ballerina" +name = "url" +version = "2.4.0" +dependencies = [ + {org = "ballerina", name = "jballerina.java"} +] + +[[package]] +org = "ballerinai" +name = "observe" +version = "0.0.0" +dependencies = [ + {org = "ballerina", name = "jballerina.java"}, + {org = "ballerina", name = "observe"} +] +modules = [ + {org = "ballerinai", packageName = "observe", moduleName = "observe"} +] + +[[package]] +org = "ballerinax" +name = "jaeger" +version = "0.5.0" +dependencies = [ + {org = "ballerina", name = "io"}, + {org = "ballerina", name = "jballerina.java"}, + {org = "ballerina", name = "observe"} +] +modules = [ + {org = "ballerinax", packageName = "jaeger", moduleName = "jaeger"} +] + +[[package]] +org = "ballerinax" +name = "jaeger_server_tests" +version = "0.1.0" +dependencies = [ + {org = "ballerina", name = "http"}, + {org = "ballerina", name = "lang.runtime"}, + {org = "ballerina", name = "observe"}, + {org = "ballerina", name = "test"}, + {org = "ballerina", name = "toml"}, + {org = "ballerinai", name = "observe"}, + {org = "ballerinax", name = "jaeger"} +] +modules = [ + {org = "ballerinax", packageName = "jaeger_server_tests", moduleName = "jaeger_server_tests"} +] + diff --git a/ballerina-tests/jaeger-server-tests/main.bal b/ballerina-tests/jaeger-server-tests/main.bal new file mode 100644 index 00000000..ba09f49a --- /dev/null +++ b/ballerina-tests/jaeger-server-tests/main.bal @@ -0,0 +1,53 @@ +// Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com) All Rights Reserved. +// +// WSO2 LLC. licenses this file to you under the Apache License, +// Version 2.0 (the "License"); you may not use this file except +// in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +import ballerina/http; +import ballerina/observe; +import ballerinax/jaeger as _; + +service /test on new http:Listener(9091) { + # Description. + # + # + caller - http caller + # + req - http request + resource function get sum(http:Caller caller, http:Request req) { + ObservableAdderClass adder = new ObservableAdder(20, 33); + var sum = adder.getSum(); + + http:Response resp = new; + resp.setTextPayload(<@untainted> "Sum: " + sum.toString()); + checkpanic caller->respond(resp); + } +} + +type ObservableAdderClass object { + @observe:Observable + function getSum() returns int; +}; + +class ObservableAdder { + private int firstNumber; + private int secondNumber; + + function init(int a, int b) { + self.firstNumber = a; + self.secondNumber = b; + } + + function getSum() returns int { + return self.firstNumber + self.secondNumber; + } +} diff --git a/ballerina-tests/jaeger-server-tests/tests/Config.toml b/ballerina-tests/jaeger-server-tests/tests/Config.toml new file mode 100644 index 00000000..b34d4ca6 --- /dev/null +++ b/ballerina-tests/jaeger-server-tests/tests/Config.toml @@ -0,0 +1,7 @@ +[ballerina.observe] +tracingEnabled=true +tracingProvider="jaeger" + +[ballerinax.jaeger] +agentHostname="localhost" # Optional Configuration. Default value is localhost +agentPort=4317 # Optional Configuration. Default value is 4317 diff --git a/ballerina-tests/jaeger-server-tests/tests/get_http_version.bal b/ballerina-tests/jaeger-server-tests/tests/get_http_version.bal new file mode 100644 index 00000000..e47969d5 --- /dev/null +++ b/ballerina-tests/jaeger-server-tests/tests/get_http_version.bal @@ -0,0 +1,58 @@ +// Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com) All Rights Reserved. +// +// WSO2 LLC. licenses this file to you under the Apache License, +// Version 2.0 (the "License"); you may not use this file except +// in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +import ballerina/toml; + +const string DEPENDENCIES_TOML_FILE = "Dependencies.toml"; + +type DependenciesTomlData record {| + ProjectDetails ballerina; + Package[] package; +|}; + +type Package record {| + string org; + string name; + string version; + string scope?; + Dependency[] dependencies?; + Module[] modules?; +|}; + +type Module record {| + string org; + string packageName; + string moduleName; +|}; + +type Dependency record {| + string org; + string name; +|}; + +type ProjectDetails record {| + string dependencies\-toml\-version; + string distribution\-version; +|}; + +public function getHTTPModuleVersion() returns string|error { + map tomlFile = check toml:readFile(DEPENDENCIES_TOML_FILE); + DependenciesTomlData dependenciesTomlData = check (tomlFile.toJson()).fromJsonWithType(); + Package[] packages = dependenciesTomlData.package; + Package httpModuleData = packages.filter(package => package.name == "http")[0]; + + return httpModuleData.version; +} diff --git a/ballerina-tests/jaeger-server-tests/tests/test.bal b/ballerina-tests/jaeger-server-tests/tests/test.bal new file mode 100644 index 00000000..d727b280 --- /dev/null +++ b/ballerina-tests/jaeger-server-tests/tests/test.bal @@ -0,0 +1,411 @@ +// Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com) All Rights Reserved. +// +// WSO2 LLC. licenses this file to you under the Apache License, +// Version 2.0 (the "License"); you may not use this file except +// in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +import ballerina/http; +import ballerina/test; +import ballerina/lang.runtime; + +type ServicePayload record {| + string[] data; + int total; + int 'limit; + int offset; + string? 'errors; +|}; + +type TracePayload record {| + Trace[] data; + int total; + int 'limit; + int offset; + string? 'errors; +|}; + +type Trace record {| + string traceID; + Span[] spans; + json processes; + string? warnings; +|}; + +type Span record {| + string traceID; + string spanID; + string operationName; + Reference[] references; + int startTime; + int duration; + Tag[] tags; + Log[] logs; + string processID; + string[]? warnings; +|}; + +type Log record {| + int timestamp; + Tag[] fields; +|}; + +type Tag record {| + string key; + string 'type; + string|int value; +|}; + +type Reference record {| + string refType; + string traceID; + string spanID; +|}; + +const string GET_SUM_SPAN_NAME = "get /sum"; +const string OBSERVABLE_ADDER_SPAN_NAME = "ballerinax/jaeger_server_tests/ObservableAdder:getSum"; +const string HTTP_CALLER_SPAN_NAME = "ballerina/http/Caller:respond"; +const string CLIENT_SPAN_NAME = "ballerina/http/Client:get"; +const string HTTP_CLIENT_SPAN_NAME = "ballerina/http/HttpClient:get"; +const string HTTP_CACHING_CLIENT_SPAN_NAME = "ballerina/http/HttpCachingClient:get"; + +const string CLIENT_SPAN_KIND = "client"; +const string SERVER_SPAN_KIND = "server"; + +http:Client jaegerClient = check new (string `http://localhost:16686`); +http:Client cl = check new (string `http://localhost:9091`); +http:Response res = new(); +string httpModuleVersion = check getHTTPModuleVersion(); +Trace? testServiceTrace = null; +map spanMap = {}; + +@test:BeforeSuite +function sendRequest() returns error? { + res = check cl->get("/test/sum"); + + runtime:sleep(10); + + json testServiceTracePayloadData = check jaegerClient->get("/api/traces?service=%2Ftest"); + TracePayload testServiceTracePayload = check testServiceTracePayloadData.fromJsonWithType(TracePayload); + + do { + testServiceTrace = testServiceTracePayload.data[0]; + } on fail { + test:assertFail("No traces found with service name: \"/test\"."); + } + + foreach Span span in ( testServiceTrace).spans { + spanMap[span.operationName] = span; + } +} + +@test:Config +function testResponse() returns error? { + test:assertEquals(res.statusCode, http:STATUS_OK, "Status code mismatched"); + test:assertEquals(res.getTextPayload(), "Sum: 53", "Payload mismatched"); +} + +@test:Config +function testServices() returns error? { + json servicesPayloadData = check jaegerClient->get("/api/services"); + ServicePayload servicesPayload = check servicesPayloadData.fromJsonWithType(ServicePayload); + + test:assertTrue(isContain(servicesPayload.data, "/test")); + test:assertTrue(isContain(servicesPayload.data, "Ballerina")); +} + +@test:Config +function testSpanNames() returns error? { + string[] spanNames = spanMap.keys(); + + test:assertTrue(isContain(spanNames, GET_SUM_SPAN_NAME), "Span name: \""+ GET_SUM_SPAN_NAME +"\" not found"); + test:assertTrue(isContain(spanNames, OBSERVABLE_ADDER_SPAN_NAME), "Span name: \"" + OBSERVABLE_ADDER_SPAN_NAME + "\" not found"); + test:assertTrue(isContain(spanNames, HTTP_CALLER_SPAN_NAME), "Span name: \"" + HTTP_CALLER_SPAN_NAME + "\" not found"); + + test:assertTrue(isContain(spanNames, CLIENT_SPAN_NAME), "Span name: \"" + CLIENT_SPAN_NAME + "\" not found"); + test:assertTrue(isContain(spanNames, HTTP_CACHING_CLIENT_SPAN_NAME), "Span name: \"" + HTTP_CACHING_CLIENT_SPAN_NAME + "\" not found"); + test:assertTrue(isContain(spanNames, HTTP_CLIENT_SPAN_NAME), "Span name: \"" + HTTP_CLIENT_SPAN_NAME + "\" not found"); +} + +@test:Config +function testProcessIDs() returns error? { + // Spans in the Ballerina service + test:assertEquals(( spanMap[CLIENT_SPAN_NAME]).processID, + ( spanMap[HTTP_CACHING_CLIENT_SPAN_NAME]).processID); + test:assertEquals(( spanMap[HTTP_CACHING_CLIENT_SPAN_NAME]).processID, + ( spanMap[HTTP_CLIENT_SPAN_NAME]).processID); + + // Spans in the /test service + test:assertEquals(( spanMap[GET_SUM_SPAN_NAME]).processID, + ( spanMap[OBSERVABLE_ADDER_SPAN_NAME]).processID); + test:assertEquals(( spanMap[OBSERVABLE_ADDER_SPAN_NAME]).processID, + ( spanMap[HTTP_CALLER_SPAN_NAME]).processID); +} + +@test:Config +function testSpanInheritance() returns error? { + Span clientSpan = spanMap[CLIENT_SPAN_NAME]; + Span httpCachingClientSpan = spanMap[HTTP_CACHING_CLIENT_SPAN_NAME]; + Span httpClientSpan = spanMap[HTTP_CLIENT_SPAN_NAME]; + Span getSumSpan = spanMap[GET_SUM_SPAN_NAME]; + Span observableAdderSpan = spanMap[OBSERVABLE_ADDER_SPAN_NAME]; + Span httpCallerSpan = spanMap[HTTP_CALLER_SPAN_NAME]; + + test:assertEquals(clientSpan.spanID, httpCachingClientSpan.references[0].spanID, + "ParentId mismatched for " + HTTP_CACHING_CLIENT_SPAN_NAME); + test:assertEquals(httpCachingClientSpan.spanID, httpClientSpan.references[0].spanID, + "ParentId mismatched for " + HTTP_CLIENT_SPAN_NAME); + test:assertEquals(httpClientSpan.spanID, getSumSpan.references[0].spanID, + "ParentId mismatched for " + GET_SUM_SPAN_NAME); + test:assertEquals(getSumSpan.spanID, observableAdderSpan.references[0].spanID, + "ParentId mismatched for " + OBSERVABLE_ADDER_SPAN_NAME); + test:assertEquals(getSumSpan.spanID, httpCallerSpan.references[0].spanID, + "ParentId mismatched for " + HTTP_CALLER_SPAN_NAME); +} + +@test:Config +function testSpanKind() returns error? { + string|int clientSpanKind = ( spanMap[CLIENT_SPAN_NAME]).tags.filter(tag => tag.key == "span.kind")[0].value; + string|int httpCachingClientSpanKind = ( spanMap[HTTP_CACHING_CLIENT_SPAN_NAME]).tags.filter(tag => tag.key == "span.kind")[0].value; + string|int httpClientSpanKind = ( spanMap[HTTP_CLIENT_SPAN_NAME]).tags.filter(tag => tag.key == "span.kind")[0].value; + string|int getSumSpanKind = ( spanMap[GET_SUM_SPAN_NAME]).tags.filter(tag => tag.key == "span.kind")[0].value; + string|int observableAdderSpanKind = ( spanMap[OBSERVABLE_ADDER_SPAN_NAME]).tags.filter(tag => tag.key == "span.kind")[0].value; + string|int httpCallerSpanKind = ( spanMap[HTTP_CALLER_SPAN_NAME]).tags.filter(tag => tag.key == "span.kind")[0].value; + + test:assertEquals(clientSpanKind, CLIENT_SPAN_KIND, "Span kind mismatched for " + CLIENT_SPAN_NAME); + test:assertEquals(httpCachingClientSpanKind, CLIENT_SPAN_KIND, "Span kind mismatched for " + HTTP_CACHING_CLIENT_SPAN_NAME); + test:assertEquals(httpClientSpanKind, CLIENT_SPAN_KIND, "Span kind mismatched for " + HTTP_CLIENT_SPAN_NAME); + test:assertEquals(getSumSpanKind, SERVER_SPAN_KIND, "Span kind mismatched for " + GET_SUM_SPAN_NAME); + test:assertEquals(observableAdderSpanKind, CLIENT_SPAN_KIND, "Span kind mismatched for " + OBSERVABLE_ADDER_SPAN_NAME); + test:assertEquals(httpCallerSpanKind, CLIENT_SPAN_KIND, "Span kind mismatched for " + HTTP_CALLER_SPAN_NAME); +} + +@test:Config +function testGetSumSpanTags() returns error? { + map getSumSpanTags = {}; + foreach Tag tag in ( spanMap[GET_SUM_SPAN_NAME]).tags { + getSumSpanTags[tag.key] = tag.value.toString(); + } + string[] getSumSpanTagKeys = getSumSpanTags.keys(); + + test:assertTrue(containsTag("entrypoint.function.module", getSumSpanTagKeys)); + test:assertEquals(getSumSpanTags["entrypoint.function.module"], "ballerinax/jaeger_server_tests:0.1.0"); + test:assertTrue(containsTag("entrypoint.function.name", getSumSpanTagKeys)); + test:assertEquals(getSumSpanTags["entrypoint.function.name"], "/sum"); + test:assertTrue(containsTag("entrypoint.resource.accessor", getSumSpanTagKeys)); + test:assertEquals(getSumSpanTags["entrypoint.resource.accessor"], "get"); + test:assertTrue(containsTag("entrypoint.service.name", getSumSpanTagKeys)); + test:assertEquals(getSumSpanTags["entrypoint.service.name"], "/test"); + test:assertTrue(containsTag("http.method", getSumSpanTagKeys)); + test:assertEquals(getSumSpanTags["http.method"], http:GET); + test:assertTrue(containsTag("http.status_code", getSumSpanTagKeys)); + test:assertEquals(getSumSpanTags["http.status_code"], http:STATUS_OK.toString()); + test:assertTrue(containsTag("http.url", getSumSpanTagKeys)); + test:assertEquals(getSumSpanTags["http.url"], "/test/sum"); + test:assertTrue(containsTag("listener.name", getSumSpanTagKeys)); + test:assertEquals(getSumSpanTags["listener.name"], "http"); + test:assertTrue(containsTag("otlp.instrumentation.library.name", getSumSpanTagKeys)); + test:assertEquals(getSumSpanTags["otlp.instrumentation.library.name"], "jaeger"); + test:assertTrue(containsTag("protocol", getSumSpanTagKeys)); + test:assertEquals(getSumSpanTags["protocol"], "http"); + test:assertTrue(containsTag("span.kind", getSumSpanTagKeys)); + test:assertEquals(getSumSpanTags["span.kind"], "server"); + test:assertTrue(containsTag("src.module", getSumSpanTagKeys)); + test:assertEquals(getSumSpanTags["src.module"], "ballerinax/jaeger_server_tests:0.1.0"); + test:assertTrue(containsTag("src.object.name", getSumSpanTagKeys)); + test:assertEquals(getSumSpanTags["src.object.name"], "/test"); + test:assertTrue(containsTag("src.position", getSumSpanTagKeys)); + test:assertEquals(getSumSpanTags["src.position"], "main.bal:26:5"); + test:assertTrue(containsTag("src.resource.accessor", getSumSpanTagKeys)); + test:assertEquals(getSumSpanTags["src.resource.accessor"], "get"); + test:assertTrue(containsTag("src.resource.path", getSumSpanTagKeys)); + test:assertEquals(getSumSpanTags["src.resource.path"], "/sum"); + test:assertTrue(containsTag("src.service.resource", getSumSpanTagKeys)); + test:assertEquals(getSumSpanTags["src.service.resource"], "true"); +} + +@test:Config +function testObservableAdderSpanTags() returns error? { + map observableAdderSpanTags = {}; + foreach Tag tag in ( spanMap[OBSERVABLE_ADDER_SPAN_NAME]).tags { + observableAdderSpanTags[tag.key] = tag.value.toString(); + } + string[] observableAdderSpanTagKeys = observableAdderSpanTags.keys(); + + test:assertTrue(containsTag("entrypoint.function.module", observableAdderSpanTagKeys)); + test:assertEquals(observableAdderSpanTags["entrypoint.function.module"], "ballerinax/jaeger_server_tests:0.1.0"); + test:assertTrue(containsTag("entrypoint.function.name", observableAdderSpanTagKeys)); + test:assertEquals(observableAdderSpanTags["entrypoint.function.name"], "/sum"); + test:assertTrue(containsTag("entrypoint.resource.accessor", observableAdderSpanTagKeys)); + test:assertEquals(observableAdderSpanTags["entrypoint.resource.accessor"], "get"); + test:assertTrue(containsTag("entrypoint.service.name", observableAdderSpanTagKeys)); + test:assertEquals(observableAdderSpanTags["entrypoint.service.name"], "/test"); + test:assertTrue(containsTag("otlp.instrumentation.library.name", observableAdderSpanTagKeys)); + test:assertEquals(observableAdderSpanTags["otlp.instrumentation.library.name"], "jaeger"); + test:assertTrue(containsTag("span.kind", observableAdderSpanTagKeys)); + test:assertEquals(observableAdderSpanTags["span.kind"], "client"); + test:assertTrue(containsTag("src.function.name", observableAdderSpanTagKeys)); + test:assertEquals(observableAdderSpanTags["src.function.name"], "getSum"); + test:assertTrue(containsTag("src.module", observableAdderSpanTagKeys)); + test:assertEquals(observableAdderSpanTags["src.module"], "ballerinax/jaeger_server_tests:0.1.0"); + test:assertTrue(containsTag("src.object.name", observableAdderSpanTagKeys)); + test:assertEquals(observableAdderSpanTags["src.object.name"], "ballerinax/jaeger_server_tests/ObservableAdder"); + test:assertTrue(containsTag("src.position", observableAdderSpanTagKeys)); + test:assertEquals(observableAdderSpanTags["src.position"], "main.bal:28:19"); +} + +@test:Config +function testHttpCallerSpanTags() returns error? { + map httpCallerSpanTags = {}; + foreach Tag tag in ( spanMap[HTTP_CALLER_SPAN_NAME]).tags { + httpCallerSpanTags[tag.key] = tag.value.toString(); + } + string[] httpCallerSpanTagKeys = httpCallerSpanTags.keys(); + + test:assertTrue(containsTag("entrypoint.function.module", httpCallerSpanTagKeys)); + test:assertEquals(httpCallerSpanTags["entrypoint.function.module"], "ballerinax/jaeger_server_tests:0.1.0"); + test:assertTrue(containsTag("entrypoint.function.name", httpCallerSpanTagKeys)); + test:assertEquals(httpCallerSpanTags["entrypoint.function.name"], "/sum"); + test:assertTrue(containsTag("entrypoint.resource.accessor", httpCallerSpanTagKeys)); + test:assertEquals(httpCallerSpanTags["entrypoint.resource.accessor"], "get"); + test:assertTrue(containsTag("entrypoint.service.name", httpCallerSpanTagKeys)); + test:assertEquals(httpCallerSpanTags["entrypoint.service.name"], "/test"); + test:assertTrue(containsTag("http.status_code", httpCallerSpanTagKeys)); + test:assertEquals(httpCallerSpanTags["http.status_code"], http:STATUS_OK.toString()); + test:assertTrue(containsTag("otlp.instrumentation.library.name", httpCallerSpanTagKeys)); + test:assertEquals(httpCallerSpanTags["otlp.instrumentation.library.name"], "jaeger"); + test:assertTrue(containsTag("span.kind", httpCallerSpanTagKeys)); + test:assertEquals(httpCallerSpanTags["span.kind"], "client"); + test:assertTrue(containsTag("src.client.remote", httpCallerSpanTagKeys)); + test:assertEquals(httpCallerSpanTags["src.client.remote"], "true"); + test:assertTrue(containsTag("src.function.name", httpCallerSpanTagKeys)); + test:assertEquals(httpCallerSpanTags["src.function.name"], "respond"); + test:assertTrue(containsTag("src.module", httpCallerSpanTagKeys)); + test:assertEquals(httpCallerSpanTags["src.module"], "ballerinax/jaeger_server_tests:0.1.0"); + test:assertTrue(containsTag("src.object.name", httpCallerSpanTagKeys)); + test:assertEquals(httpCallerSpanTags["src.object.name"], "ballerina/http/Caller"); + test:assertTrue(containsTag("src.position", httpCallerSpanTagKeys)); + test:assertEquals(httpCallerSpanTags["src.position"], "main.bal:32:20"); +} + +@test:Config +function testClientSpanTags() returns error? { + map clientSpanTags = {}; + foreach Tag tag in ( spanMap[CLIENT_SPAN_NAME]).tags { + clientSpanTags[tag.key] = tag.value.toString(); + } + string[] clientSpanTagKeys = clientSpanTags.keys(); + + test:assertTrue(containsTag("entrypoint.function.module", clientSpanTagKeys)); + test:assertEquals(clientSpanTags["entrypoint.function.module"], "ballerinax/jaeger_server_tests:0.1.0"); + test:assertTrue(containsTag("entrypoint.function.name", clientSpanTagKeys)); + test:assertEquals(clientSpanTags["entrypoint.function.name"], "get"); + test:assertTrue(containsTag("http.base_url", clientSpanTagKeys)); + test:assertEquals(clientSpanTags["http.base_url"], "http://localhost:9091"); + test:assertTrue(containsTag("http.method", clientSpanTagKeys)); + test:assertEquals(clientSpanTags["http.method"], http:GET); + test:assertTrue(containsTag("http.status_code", clientSpanTagKeys)); + test:assertEquals(clientSpanTags["http.status_code"], http:STATUS_OK.toString()); + test:assertTrue(containsTag("http.url", clientSpanTagKeys)); + test:assertEquals(clientSpanTags["http.url"], "/test/sum"); + test:assertTrue(containsTag("otlp.instrumentation.library.name", clientSpanTagKeys)); + test:assertEquals(clientSpanTags["otlp.instrumentation.library.name"], "jaeger"); + test:assertTrue(containsTag("span.kind", clientSpanTagKeys)); + test:assertEquals(clientSpanTags["span.kind"], "client"); + test:assertTrue(containsTag("src.client.remote", clientSpanTagKeys)); + test:assertEquals(clientSpanTags["src.client.remote"], "true"); + test:assertTrue(containsTag("src.function.name", clientSpanTagKeys)); + test:assertEquals(clientSpanTags["src.function.name"], "get"); + test:assertTrue(containsTag("src.module", clientSpanTagKeys)); + test:assertEquals(clientSpanTags["src.module"], "ballerinax/jaeger_server_tests:0.1.0"); + test:assertTrue(containsTag("src.object.name", clientSpanTagKeys)); + test:assertEquals(clientSpanTags["src.object.name"], "ballerina/http/Client"); + test:assertTrue(containsTag("src.position", clientSpanTagKeys)); + test:assertEquals(clientSpanTags["src.position"], "tests/test.bal:93:17"); +} + +@test:Config +function testHttpCachingClientSpanTags() returns error? { + map httpCachingClientSpanTags = {}; + foreach Tag tag in ( spanMap[HTTP_CACHING_CLIENT_SPAN_NAME]).tags { + httpCachingClientSpanTags[tag.key] = tag.value.toString(); + } + string[] httpCachingClientSpanTagKeys = httpCachingClientSpanTags.keys(); + + test:assertTrue(containsTag("entrypoint.function.module", httpCachingClientSpanTagKeys)); + test:assertEquals(httpCachingClientSpanTags["entrypoint.function.module"], "ballerinax/jaeger_server_tests:0.1.0"); + test:assertTrue(containsTag("entrypoint.function.name", httpCachingClientSpanTagKeys)); + test:assertEquals(httpCachingClientSpanTags["entrypoint.function.name"], "get"); + test:assertTrue(containsTag("otlp.instrumentation.library.name", httpCachingClientSpanTagKeys)); + test:assertEquals(httpCachingClientSpanTags["otlp.instrumentation.library.name"], "jaeger"); + test:assertTrue(containsTag("span.kind", httpCachingClientSpanTagKeys)); + test:assertEquals(httpCachingClientSpanTags["span.kind"], "client"); + test:assertTrue(containsTag("src.client.remote", httpCachingClientSpanTagKeys)); + test:assertEquals(httpCachingClientSpanTags["src.client.remote"], "true"); + test:assertTrue(containsTag("src.function.name", httpCachingClientSpanTagKeys)); + test:assertEquals(httpCachingClientSpanTags["src.function.name"], "get"); + test:assertTrue(containsTag("src.module", httpCachingClientSpanTagKeys)); + test:assertEquals(httpCachingClientSpanTags["src.module"], string `ballerina/http:${httpModuleVersion}`); + test:assertTrue(containsTag("src.object.name", httpCachingClientSpanTagKeys)); + test:assertEquals(httpCachingClientSpanTags["src.object.name"], "ballerina/http/HttpCachingClient"); + test:assertTrue(containsTag("src.position", httpCachingClientSpanTagKeys)); + test:assertEquals(httpCachingClientSpanTags["src.position"], "http_client_endpoint.bal:282:41"); +} + +@test:Config +function testHttpClientSpanTags() returns error? { + map httpClientSpanTags = {}; + foreach Tag tag in ( spanMap[HTTP_CLIENT_SPAN_NAME]).tags { + httpClientSpanTags[tag.key] = tag.value.toString(); + } + string[] httpClientSpanTagKeys = httpClientSpanTags.keys(); + + test:assertTrue(containsTag("entrypoint.function.module", httpClientSpanTagKeys)); + test:assertEquals(httpClientSpanTags["entrypoint.function.module"], "ballerinax/jaeger_server_tests:0.1.0"); + test:assertTrue(containsTag("entrypoint.function.name", httpClientSpanTagKeys)); + test:assertEquals(httpClientSpanTags["entrypoint.function.name"], "get"); + test:assertTrue(containsTag("http.method", httpClientSpanTagKeys)); + test:assertEquals(httpClientSpanTags["http.method"], http:GET); + test:assertTrue(containsTag("http.status_code", httpClientSpanTagKeys)); + test:assertEquals(httpClientSpanTags["http.status_code"], http:STATUS_OK.toString()); + test:assertTrue(containsTag("http.url", httpClientSpanTagKeys)); + test:assertEquals(httpClientSpanTags["http.url"], "/test/sum"); + test:assertTrue(containsTag("otlp.instrumentation.library.name", httpClientSpanTagKeys)); + test:assertEquals(httpClientSpanTags["otlp.instrumentation.library.name"], "jaeger"); + test:assertTrue(containsTag("peer.address", httpClientSpanTagKeys)); + test:assertEquals(httpClientSpanTags["peer.address"], "localhost:9091"); + test:assertTrue(containsTag("span.kind", httpClientSpanTagKeys)); + test:assertEquals(httpClientSpanTags["span.kind"], "client"); + test:assertTrue(containsTag("src.client.remote", httpClientSpanTagKeys)); + test:assertEquals(httpClientSpanTags["src.client.remote"], "true"); + test:assertTrue(containsTag("src.function.name", httpClientSpanTagKeys)); + test:assertEquals(httpClientSpanTags["src.function.name"], "get"); + test:assertTrue(containsTag("src.module", httpClientSpanTagKeys)); + test:assertEquals(httpClientSpanTags["src.module"], string `ballerina/http:${httpModuleVersion}`); + test:assertTrue(containsTag("src.object.name", httpClientSpanTagKeys)); + test:assertEquals(httpClientSpanTags["src.object.name"], "ballerina/http/HttpClient"); + test:assertTrue(containsTag("src.position", httpClientSpanTagKeys)); + test:assertEquals(httpClientSpanTags["src.position"], "caching_http_caching_client.bal:371:16"); +} + +function isContain(string[] array, string id) returns boolean { + return array.indexOf(id) != (); +} + +function containsTag(string tagKey, string[] traceTagKeys) returns boolean { + foreach string key in traceTagKeys { + if (key == tagKey) { + return true; + } + } + return false; +} diff --git a/ballerina-tests/resources/jaeger-server/docker-compose.yml b/ballerina-tests/resources/jaeger-server/docker-compose.yml new file mode 100644 index 00000000..f053e675 --- /dev/null +++ b/ballerina-tests/resources/jaeger-server/docker-compose.yml @@ -0,0 +1,9 @@ +version: '3.7' +services: + jaeger_server: + image: jaegertracing/opentelemetry-all-in-one:latest + container_name: jaeger-server + ports: + - 13133:13133 + - 16686:16686 + - 4317:4317 diff --git a/jaeger-extension-ballerina/Ballerina.toml b/ballerina/Ballerina.toml similarity index 78% rename from jaeger-extension-ballerina/Ballerina.toml rename to ballerina/Ballerina.toml index c574e646..9273d2c0 100644 --- a/jaeger-extension-ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -18,64 +18,58 @@ org = "ballerinax" name = "jaeger" version = "@toml.version@" -distribution = "2201.7.0" +distribution = "2201.9.0" [platform.java17] graalvmCompatible = true [[platform.java17.dependency]] -path = "../jaeger-extension-native/build/libs/jaeger-extension-native-@project.version@.jar" +path = "../native/build/libs/jaeger-extension-native-@project.version@.jar" groupId = "ballerina" artifactId = "jaeger-extension-native" version = "@project.version@" [[platform.java17.dependency]] -path = "./lib/jaeger-core-@jaeger.version@.jar" -groupId = "io.jaegertracing" -artifactId = "jaeger-core" -version = "@jaeger.version@" - -[[platform.java17.dependency]] -path = "./lib/opentelemetry-api-metrics-@openTelemetryAlpha.version@.jar" +path = "./lib/opentelemetry-api-@opentelemetry.version@.jar" groupId = "io.opentelemetry" -artifactId = "opentelemetry-api-metrics" -version = "@openTelemetryAlpha.version@" +artifactId = "opentelemetry-api" +version = "@opentelemetry.version@" [[platform.java17.dependency]] -path = "./lib/opentelemetry-sdk-trace-@opentelemetry.version@.jar" +path = "./lib/opentelemetry-sdk-trace-@opentelemetrySDK.version@.jar" groupId = "io.opentelemetry" artifactId = "opentelemetry-sdk-trace" -version = "@opentelemetry.version@" +version = "@opentelemetrySDK.version@" [[platform.java17.dependency]] -path = "./lib/opentelemetry-sdk-common-@opentelemetry.version@.jar" +path = "./lib/opentelemetry-sdk-common-@opentelemetrySDK.version@.jar" groupId = "io.opentelemetry" artifactId = "opentelemetry-sdk-common" -version = "@opentelemetry.version@" +version = "@opentelemetrySDK.version@" [[platform.java17.dependency]] -path = "./lib/opentelemetry-semconv-@openTelemetryAlpha.version@.jar" +path = "./lib/opentelemetry-semconv-@opentelemetrySemconv.version@.jar" groupId = "io.opentelemetry" artifactId = "opentelemetry-semconv" -version = "@openTelemetryAlpha.version@" +version = "@opentelemetrySemconv.version@" [[platform.java17.dependency]] -path = "./lib/opentelemetry-proto-@openTelemetryAlpha.version@.jar" +path = "./lib/opentelemetry-proto-@opentelemetryProto.version@.jar" groupId = "io.opentelemetry" artifactId = "opentelemetry-proto" -version = "@openTelemetryAlpha.version@" +version = "@opentelemetryProto.version@" [[platform.java17.dependency]] -path = "./lib/opentelemetry-exporter-otlp-trace-@opentelemetry.version@.jar" +path = "./lib/opentelemetry-exporter-otlp-trace-@opentelemetryExporter.version@.jar" groupId = "io.opentelemetry" artifactId = "opentelemetry-exporter-otlp-trace" -version = "@opentelemetry.version@" +version = "@opentelemetryExporter.version@" [[platform.java17.dependency]] -path = "./lib/opentelemetry-exporter-otlp-common-@opentelemetry.version@.jar" +path = "./lib/opentelemetry-exporter-otlp-common-@opentelemetryExporter.version@.jar" groupId = "io.opentelemetry" artifactId = "opentelemetry-exporter-otlp-common" -version = "@opentelemetry.version@" +version = "@opentelemetryExporter.version@" [[platform.java17.dependency]] path = "./lib/opentelemetry-extension-trace-propagators-@opentelemetry.version@.jar" diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml new file mode 100644 index 00000000..7d38d6f5 --- /dev/null +++ b/ballerina/Dependencies.toml @@ -0,0 +1,62 @@ +# AUTO-GENERATED FILE. DO NOT MODIFY. + +# This file is auto-generated by Ballerina for managing dependency versions. +# It should not be modified by hand. + +[ballerina] +dependencies-toml-version = "2" +distribution-version = "2201.9.0" + +[[package]] +org = "ballerina" +name = "io" +version = "1.6.0" +dependencies = [ + {org = "ballerina", name = "jballerina.java"}, + {org = "ballerina", name = "lang.value"} +] +modules = [ + {org = "ballerina", packageName = "io", moduleName = "io"} +] + +[[package]] +org = "ballerina" +name = "jballerina.java" +version = "0.0.0" +modules = [ + {org = "ballerina", packageName = "jballerina.java", moduleName = "jballerina.java"} +] + +[[package]] +org = "ballerina" +name = "lang.value" +version = "0.0.0" +dependencies = [ + {org = "ballerina", name = "jballerina.java"} +] + +[[package]] +org = "ballerina" +name = "observe" +version = "1.2.3" +dependencies = [ + {org = "ballerina", name = "jballerina.java"} +] +modules = [ + {org = "ballerina", packageName = "observe", moduleName = "observe"}, + {org = "ballerina", packageName = "observe", moduleName = "observe.mockextension"} +] + +[[package]] +org = "ballerinax" +name = "jaeger" +version = "0.5.0" +dependencies = [ + {org = "ballerina", name = "io"}, + {org = "ballerina", name = "jballerina.java"}, + {org = "ballerina", name = "observe"} +] +modules = [ + {org = "ballerinax", packageName = "jaeger", moduleName = "jaeger"} +] + diff --git a/jaeger-extension-ballerina/Package.md b/ballerina/Package.md similarity index 100% rename from jaeger-extension-ballerina/Package.md rename to ballerina/Package.md diff --git a/jaeger-extension-ballerina/build.gradle b/ballerina/build.gradle similarity index 67% rename from jaeger-extension-ballerina/build.gradle rename to ballerina/build.gradle index bed44b34..e786c7c9 100644 --- a/jaeger-extension-ballerina/build.gradle +++ b/ballerina/build.gradle @@ -34,17 +34,14 @@ configurations { dependencies { nativeJar project(':jaeger-extension-native') - externalJars "io.jaegertracing:jaeger-core:${jaegerVersion}" - externalJars "io.jaegertracing:jaeger-thrift:${jaegerVersion}" externalJars "io.opentelemetry:opentelemetry-api:${openTelemetryVersion}" - externalJars "io.opentelemetry:opentelemetry-api-metrics:${openTelemetryAlphaVersion}" externalJars "io.opentelemetry:opentelemetry-context:${openTelemetryVersion}" externalJars "io.opentelemetry:opentelemetry-sdk-trace:${openTelemetryVersion}" externalJars "io.opentelemetry:opentelemetry-sdk-common:${openTelemetryVersion}" - externalJars "io.opentelemetry:opentelemetry-semconv:${openTelemetryAlphaVersion}" - externalJars "io.opentelemetry:opentelemetry-proto:${openTelemetryAlphaVersion}" - externalJars "io.opentelemetry:opentelemetry-exporter-otlp-trace:${openTelemetryVersion}" - externalJars "io.opentelemetry:opentelemetry-exporter-otlp-common:${openTelemetryVersion}" + externalJars "io.opentelemetry.semconv:opentelemetry-semconv:${openTelemetrySemconvVersion}" + externalJars "io.opentelemetry:opentelemetry-proto:${openTelemetryProtoVersion}" + externalJars "io.opentelemetry:opentelemetry-exporter-otlp-trace:${openTelemetryExporterVersion}" + externalJars "io.opentelemetry:opentelemetry-exporter-otlp-common:${openTelemetryExporterVersion}" externalJars "io.opentelemetry:opentelemetry-extension-trace-propagators:${openTelemetryVersion}" externalJars "com.google.guava:guava:${guavaVersion}" externalJars "com.google.guava:failureaccess:${failureAccessVersion}" @@ -72,63 +69,23 @@ jar { } } -task unpackJballerinaTools(type: Copy, dependsOn: configurations.jbalTools) { - configurations.jbalTools.resolvedConfiguration.resolvedArtifacts.each { artifact -> - from zipTree(artifact.getFile()) - into new File("${buildDir}/extracted-distributions", "jballerina-tools-zip") - } -} - -task unpackStdLibs(dependsOn: configurations.ballerinaStdLibs) { - doLast { - configurations.ballerinaStdLibs.resolvedConfiguration.resolvedArtifacts.each { artifact -> - copy { - from project.zipTree(artifact.getFile()) - into new File("${buildDir}/extracted-distributions", artifact.name + "-zip") - } - } - } -} - task copyExternalJarsToLib(type: Copy) { into "${project.projectDir}/lib" from configurations.externalJars } -task copyStdlibs(type: Copy) { - dependsOn unpackJballerinaTools - dependsOn unpackStdLibs - - duplicatesStrategy = DuplicatesStrategy.EXCLUDE - into "${project.buildDir}/extracted-distributions/jballerina-tools-zip/jballerina-tools-${ballerinaLangVersion}" - - /* Standard Libraries */ - configurations.ballerinaStdLibs.resolvedConfiguration.resolvedArtifacts.each { artifact -> - def artifactExtractedPath = "${buildDir}/extracted-distributions/" + artifact.name + "-zip" - into("repo/bala") { - from "${artifactExtractedPath}/bala" - } - into("repo/cache") { - from "${artifactExtractedPath}/cache" - } - } -} - def packageOrg = "ballerinax" def packageName = "jaeger" def ballerinaConfigFile = new File("${project.projectDir}/Ballerina.toml") -def ballerinaDependencyFile = new File("$project.projectDir/Dependencies.toml") def artifactBallerinaDocs = file("${project.projectDir}/build/docs_parent/") def artifactCacheParent = file("${project.buildDir}/cache_parent/") def artifactLibParent = file("${project.buildDir}/lib_parent/") -def snapshotVersion = "-SNAPSHOT" def tomlVersion = stripBallerinaExtensionVersion("${project.version}") def ballerinaCentralAccessToken = System.getenv('BALLERINA_CENTRAL_ACCESS_TOKEN') def originalConfig = ballerinaConfigFile.text -def originalDependencyConfig = ballerinaDependencyFile.text def artifactJar = file("$project.projectDir/target/cache/${packageOrg}/${packageName}/${tomlVersion}/java17/") def platform = "java17" -def distributionBinPath = "${project.buildDir.absolutePath}/extracted-distributions/jballerina-tools-zip/jballerina-tools-${ballerinaLangVersion}/bin" +def skipTests = false def stripBallerinaExtensionVersion(String extVersion) { if (extVersion.matches(project.ext.timestampedVersionRegex)) { @@ -144,12 +101,13 @@ def stripBallerinaExtensionVersion(String extVersion) { } } -task updateTomlVerions { +task updateTomlVersions { doLast { - def stdlibDependentIoVersion = stripBallerinaExtensionVersion(project.stdlibIoVersion) - def jaegerVersion = project.jaegerVersion def openTelemetryVersion = project.openTelemetryVersion - def openTelemetryAlphaVersion = project.openTelemetryAlphaVersion + def openTelemetrySDKVersion = project.openTelemetrySDKVersion + def openTelemetryExporterVersion = project.openTelemetryExporterVersion + def openTelemetrySemconvVersion = project.openTelemetrySemconvVersion + def openTelemetryProtoVersion = project.openTelemetryProtoVersion def guavaVersion = project.guavaVersion def failureAccessVersion = project.failureAccessVersion def grpcVersion = project.grpcVersion @@ -159,9 +117,11 @@ task updateTomlVerions { def newConfig = ballerinaConfigFile.text.replace("@project.version@", project.version) newConfig = newConfig.replace("@toml.version@", tomlVersion) - newConfig = newConfig.replace("@jaeger.version@", jaegerVersion) newConfig = newConfig.replace("@opentelemetry.version@", openTelemetryVersion) - newConfig = newConfig.replace("@openTelemetryAlpha.version@", openTelemetryAlphaVersion) + newConfig = newConfig.replace("@opentelemetrySDK.version@", openTelemetrySDKVersion) + newConfig = newConfig.replace("@opentelemetryExporter.version@", openTelemetryExporterVersion) + newConfig = newConfig.replace("@opentelemetrySemconv.version@", openTelemetrySemconvVersion) + newConfig = newConfig.replace("@opentelemetryProto.version@", openTelemetryProtoVersion) newConfig = newConfig.replace("@guava.version@", guavaVersion) newConfig = newConfig.replace("@failureAccess.version@", failureAccessVersion) newConfig = newConfig.replace("@grpc.version@", grpcVersion) @@ -169,25 +129,20 @@ task updateTomlVerions { newConfig = newConfig.replace("@protobuf.version@", protobufVersion) newConfig = newConfig.replace("@perfmark.version@", perfmarkVersion) ballerinaConfigFile.text = newConfig - - def newDependencyConfig = ballerinaDependencyFile.text.replace("@stdlib.io.version@", stdlibDependentIoVersion) - ballerinaDependencyFile.text = newDependencyConfig } } task revertTomlFile { doLast { ballerinaConfigFile.text = originalConfig - ballerinaDependencyFile.text = originalDependencyConfig } } task ballerinaBuild { - dependsOn copyExternalJarsToLib - dependsOn copyStdlibs - dependsOn updateTomlVerions + dependsOn updateTomlVersions dependsOn configurations.nativeJar dependsOn configurations.externalJars + dependsOn copyExternalJarsToLib dependsOn compileJava dependsOn compileTestJava dependsOn jar @@ -195,10 +150,13 @@ task ballerinaBuild { dependsOn checkstyleTest dependsOn spotbugsMain dependsOn spotbugsTest + dependsOn test dependsOn ":jaeger-extension-ballerina:generatePomFileForMavenJavaPublication" inputs.dir file(project.projectDir) - finalizedBy(revertTomlFile) + if (skipTests) { + finalizedBy(revertTomlFile) + } doLast { def additionalBuildParams = "" @@ -206,15 +164,10 @@ task ballerinaBuild { additionalBuildParams = "--debug ${project.findProperty("debug")}" } - exec { - workingDir project.projectDir - environment "JAVA_OPTS", "-DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true" - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - commandLine 'cmd', '/c', "${distributionBinPath}/bal.bat pack --offline ${additionalBuildParams} && exit %%ERRORLEVEL%%" - } else { - commandLine 'sh', '-c', "${distributionBinPath}/bal pack --offline ${additionalBuildParams}" - } - } + // build bala file + executeBalCommand ("build", "${project.projectDir}") + executeBalCommand ("pack", "${project.projectDir}") + // extract bala file to artifact cache directory file("${project.projectDir}/target/bala").eachFileMatch(~/.*.bala/) { balaFile -> copy { @@ -230,19 +183,26 @@ task ballerinaBuild { } // Doc creation and packing - exec { - workingDir project.projectDir - environment "JAVA_OPTS", "-DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true" - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - commandLine 'cmd', '/c', "$distributionBinPath/bal.bat doc && exit %%ERRORLEVEL%%" - } else { - commandLine 'sh', '-c', "$distributionBinPath/bal doc" - } - } + executeBalCommand ("doc", "${project.projectDir}") + copy { from file("$project.projectDir/target/apidocs/${packageName}") into file("$project.buildDir/docs_parent/docs/${packageName}") } + + boolean publishToCentral = project.hasProperty('publishToCentral') ? project.publishToCentral.toBoolean() : false + if (publishToCentral) { + if (project.version.toString().split("-").length > 1) { + return + } + if (ballerinaCentralAccessToken != null) { + println("Publishing to the ballerina central...") + def env = "JAVA_OPTS -DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true" + executeBalCommand ("push", "${project.projectDir}", env) + } else { + throw new InvalidUserDataException("Central Access Token is not present") + } + } } outputs.dir artifactCacheParent @@ -260,28 +220,20 @@ artifacts { } task ballerinaPublish { - dependsOn updateTomlVerions + dependsOn updateTomlVersions dependsOn ballerinaBuild - dependsOn ":${packageName}-extension-tests:test" dependsOn ":jaeger-extension-ballerina:generatePomFileForMavenJavaPublication" finalizedBy(revertTomlFile) doLast { - if (project.version.endsWith('-SNAPSHOT')) { + if (project.version.toString().split("-").length > 1) { return } if (ballerinaCentralAccessToken != null) { println("Publishing to the ballerina central...") - exec { - workingDir project.projectDir - environment "JAVA_OPTS", "-DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true" - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - commandLine 'cmd', '/c', "$distributionBinPath/bal.bat push && exit %%ERRORLEVEL%%" - } else { - commandLine 'sh', '-c', "$distributionBinPath/bal push" - } - } + def env = "JAVA_OPTS -DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true" + executeBalCommand ("push", "${project.projectDir}", env) } else { throw new InvalidUserDataException("Central Access Token is not present") } @@ -324,3 +276,23 @@ task extractBallerinaClassFiles(type: Copy) { into "${project.rootDir.absolutePath}/build/classes" } } + +task publishBalaFileToLocal { + dependsOn ballerinaBuild + + finalizedBy(revertTomlFile) + + doLast { + if (!skipTests) { + exec { + workingDir "${project.rootDir}/ballerina" + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + commandLine 'cmd', '/c', "bal.bat push --repository=local" + + " && exit %%ERRORLEVEL%%" + } else { + commandLine 'sh', '-c', "bal push --repository=local" + } + } + } + } +} diff --git a/jaeger-extension-ballerina/tracer_provider.bal b/ballerina/tracer_provider.bal similarity index 100% rename from jaeger-extension-ballerina/tracer_provider.bal rename to ballerina/tracer_provider.bal diff --git a/build.gradle b/build.gradle index 64bff9c5..9192abff 100644 --- a/build.gradle +++ b/build.gradle @@ -14,6 +14,8 @@ * limitations under the License. */ +import org.apache.tools.ant.taskdefs.condition.Os + plugins { id 'checkstyle' id "com.github.spotbugs" version "5.0.14" @@ -68,35 +70,6 @@ subprojects { ballerinaStdLibs } - dependencies { - // Ballerina Pack - jbalTools "org.ballerinalang:jballerina-tools:${ballerinaLangVersion}" - - // Observe Modules - ballerinaStdLibs "io.ballerina.stdlib:observe-ballerina:${observeVersion}" - 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 - ballerinaStdLibs "io.ballerina.stdlib:io-ballerina:${stdlibIoVersion}" - ballerinaStdLibs "io.ballerina.stdlib:os-ballerina:${stdlibOsVersion}" - ballerinaStdLibs "io.ballerina.stdlib:time-ballerina:${stdlibTimeVersion}" - ballerinaStdLibs "io.ballerina.stdlib:url-ballerina:${stdlibUrlVersion}" - ballerinaStdLibs "io.ballerina.stdlib:task-ballerina:${stdlibTaskVersion}" - ballerinaStdLibs "io.ballerina.stdlib:file-ballerina:${stdlibFileVersion}" - ballerinaStdLibs "io.ballerina.stdlib:crypto-ballerina:${stdlibCryptoVersion}" - ballerinaStdLibs "io.ballerina.stdlib:log-ballerina:${stdlibLogVersion}" - ballerinaStdLibs "io.ballerina.stdlib:mime-ballerina:${stdlibMimeVersion}" - ballerinaStdLibs "io.ballerina.stdlib:cache-ballerina:${stdlibCacheVersion}" - ballerinaStdLibs "io.ballerina.stdlib:auth-ballerina:${stdlibAuthVersion}" - ballerinaStdLibs "io.ballerina.stdlib:jwt-ballerina:${stdlibJwtVersion}" - ballerinaStdLibs "io.ballerina.stdlib:oauth2-ballerina:${stdlibOAuth2Version}" - ballerinaStdLibs "io.ballerina.stdlib:uuid-ballerina:${stdlibUuidVersion}" - } - checkstyle { toolVersion '10.12.1' } @@ -136,6 +109,23 @@ subprojects { def moduleVersion = project.version.replace("-SNAPSHOT", "") +def executeBalCommand(String command, String dir, env = "") { + try { + exec { + workingDir dir + environment environment: env + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + commandLine 'cmd', '/c', "bal.bat ${command} && exit %%ERRORLEVEL%%" + } else { + commandLine 'sh', '-c', "bal ${command}" + } + } + } catch (Exception e) { + println("bal command failed. " + e.message) + throw e + } +} + release { failOnPublishNeeded = false failOnSnapshotDependencies = true diff --git a/gradle.properties b/gradle.properties index 98394a39..c654fa1c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,46 +13,26 @@ # limitations under the License. group=org.ballerinalang -version=0.4.1-SNAPSHOT -ballerinaLangVersion=2201.8.2 +version=0.5.0-SNAPSHOT +ballerinaLangVersion=2201.9.0 org.gradle.caching=true org.gradle.parallel=true org.gradle.jvmargs='-Dfile.encoding=UTF-8' org.gradle.workers.max=3 # Native Dependency Versions -jaegerVersion=1.8.1 -openTelemetryVersion=1.0.0 -openTelemetryAlphaVersion=1.0.0-alpha +openTelemetryVersion=1.32.0 +openTelemetryExporterVersion=1.14.0 +openTelemetrySDKVersion=1.32.0 +openTelemetrySemconvVersion=1.21.0-alpha +openTelemetryProtoVersion=1.7.1-alpha guavaVersion=30.1-jre failureAccessVersion=1.0.1 grpcVersion=1.35.0 protobufVersion=3.20.3 -nettyVersion=4.1.100.Final +nettyVersion=4.1.108.Final perfmarkVersion=0.23.0 -# Observe Modules -observeVersion=1.0.2 -observeInternalVersion=1.0.2 - -# Test Module Dependecy Versions -stdlibHttpVersion=2.2.1 -stdlibIoVersion=1.2.1 -stdlibRegexVersion=1.2.1 -stdlibOsVersion=1.2.1 -stdlibTimeVersion=2.2.1 -stdlibUrlVersion=2.2.1 -stdlibTaskVersion=2.2.1 -stdlibFileVersion=1.2.1 -stdlibCryptoVersion=2.2.1 -stdlibLogVersion=2.8.1 -stdlibMimeVersion=2.2.1 -stdlibCacheVersion=3.2.1 -stdlibAuthVersion=2.2.1 -stdlibJwtVersion=2.2.1 -stdlibOAuth2Version=2.2.1 -stdlibUuidVersion=1.2.1 - # Test Dependency Versions testngVersion=7.6.1 slf4jVersion=1.7.26 diff --git a/jaeger-extension-ballerina/Dependencies.toml b/jaeger-extension-ballerina/Dependencies.toml deleted file mode 100644 index c4ebd9e7..00000000 --- a/jaeger-extension-ballerina/Dependencies.toml +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright (c) 2021 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -# -# WSO2 Inc. licenses this file to you under the Apache License, -# Version 2.0 (the "License"); you may not use this file except -# in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -[[dependency]] -org = "ballerina" -name = "io" -version = "@stdlib.io.version@" diff --git a/jaeger-extension-native/build.gradle b/native/build.gradle similarity index 89% rename from jaeger-extension-native/build.gradle rename to native/build.gradle index 58e100c5..15f39900 100644 --- a/jaeger-extension-native/build.gradle +++ b/native/build.gradle @@ -22,16 +22,14 @@ description = 'Ballerina - Jaeger Extension - Native Module' dependencies { implementation "org.ballerinalang:ballerina-runtime:${ballerinaLangVersion}" - implementation "io.jaegertracing:jaeger-core:${jaegerVersion}" - implementation "io.jaegertracing:jaeger-thrift:${jaegerVersion}" - implementation "io.opentelemetry:opentelemetry-api:${openTelemetryVersion}" - implementation "io.opentelemetry:opentelemetry-api-metrics:${openTelemetryAlphaVersion}" implementation "io.opentelemetry:opentelemetry-context:${openTelemetryVersion}" - implementation "io.opentelemetry:opentelemetry-sdk-trace:${openTelemetryVersion}" - implementation "io.opentelemetry:opentelemetry-sdk-common:${openTelemetryVersion}" - implementation "io.opentelemetry:opentelemetry-semconv:${openTelemetryAlphaVersion}" - implementation "io.opentelemetry:opentelemetry-exporter-otlp-trace:${openTelemetryVersion}" + implementation "io.opentelemetry:opentelemetry-sdk-trace:${openTelemetrySDKVersion}" + implementation "io.opentelemetry:opentelemetry-sdk-common:${openTelemetrySDKVersion}" + implementation "io.opentelemetry.semconv:opentelemetry-semconv:${openTelemetrySemconvVersion}" + implementation "io.opentelemetry:opentelemetry-exporter-otlp-trace:${openTelemetryExporterVersion}" implementation "io.opentelemetry:opentelemetry-extension-trace-propagators:${openTelemetryVersion}" + implementation "io.opentelemetry:opentelemetry-sdk-extension-jaeger-remote-sampler:${openTelemetrySDKVersion}" + implementation("com.google.guava:guava:${guavaVersion}") { exclude group: 'com.google.code.findbugs', module: 'jsr305' } diff --git a/jaeger-extension-native/src/main/java/io/ballerina/observe/trace/jaeger/JaegerTracerProvider.java b/native/src/main/java/io/ballerina/observe/trace/jaeger/JaegerTracerProvider.java similarity index 97% rename from jaeger-extension-native/src/main/java/io/ballerina/observe/trace/jaeger/JaegerTracerProvider.java rename to native/src/main/java/io/ballerina/observe/trace/jaeger/JaegerTracerProvider.java index f9e3c08f..23345fd9 100644 --- a/jaeger-extension-native/src/main/java/io/ballerina/observe/trace/jaeger/JaegerTracerProvider.java +++ b/native/src/main/java/io/ballerina/observe/trace/jaeger/JaegerTracerProvider.java @@ -37,7 +37,7 @@ import java.io.PrintStream; import java.util.concurrent.TimeUnit; -import static io.opentelemetry.semconv.resource.attributes.ResourceAttributes.SERVICE_NAME; +import static io.opentelemetry.semconv.ResourceAttributes.SERVICE_NAME; /** * This is the Jaeger tracing extension class for {@link TracerProvider}. diff --git a/jaeger-extension-native/src/main/java/io/ballerina/observe/trace/jaeger/sampler/RateLimiter.java b/native/src/main/java/io/ballerina/observe/trace/jaeger/sampler/RateLimiter.java similarity index 100% rename from jaeger-extension-native/src/main/java/io/ballerina/observe/trace/jaeger/sampler/RateLimiter.java rename to native/src/main/java/io/ballerina/observe/trace/jaeger/sampler/RateLimiter.java diff --git a/jaeger-extension-native/src/main/java/io/ballerina/observe/trace/jaeger/sampler/RateLimitingSampler.java b/native/src/main/java/io/ballerina/observe/trace/jaeger/sampler/RateLimitingSampler.java similarity index 61% rename from jaeger-extension-native/src/main/java/io/ballerina/observe/trace/jaeger/sampler/RateLimitingSampler.java rename to native/src/main/java/io/ballerina/observe/trace/jaeger/sampler/RateLimitingSampler.java index 579b3501..c93d2aac 100644 --- a/jaeger-extension-native/src/main/java/io/ballerina/observe/trace/jaeger/sampler/RateLimitingSampler.java +++ b/native/src/main/java/io/ballerina/observe/trace/jaeger/sampler/RateLimitingSampler.java @@ -4,29 +4,38 @@ */ package io.ballerina.observe.trace.jaeger.sampler; +import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.trace.SpanKind; import io.opentelemetry.context.Context; -import io.opentelemetry.sdk.internal.SystemClock; +import io.opentelemetry.sdk.common.Clock; +import io.opentelemetry.sdk.internal.RateLimiter; import io.opentelemetry.sdk.trace.data.LinkData; import io.opentelemetry.sdk.trace.samplers.Sampler; import io.opentelemetry.sdk.trace.samplers.SamplingDecision; import io.opentelemetry.sdk.trace.samplers.SamplingResult; +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; import java.util.List; +import static io.opentelemetry.api.common.AttributeKey.doubleKey; +import static io.opentelemetry.api.common.AttributeKey.stringKey; + /** - * This class is copied from https://github.com/open-telemetry/opentelemetry-java/blob/v1.0.0/sdk-extensions/ + * This class is copied from https://github.com/open-telemetry/opentelemetry-java/blob/v1.32.0/sdk-extensions/ * jaeger-remote-sampler/src/main/java/io/opentelemetry/sdk/extension/trace/jaeger/sampler/RateLimitingSampler.java. * This sampler uses a leaky bucket rate limiter to ensure that traces are sampled with a certain constant rate. */ public class RateLimitingSampler implements Sampler { public static final String TYPE = "ratelimiting"; + static final AttributeKey SAMPLER_TYPE = stringKey("sampler.type"); + static final AttributeKey SAMPLER_PARAM = doubleKey("sampler.param"); - private final double maxTracesPerSecond; private final RateLimiter rateLimiter; private final SamplingResult onSamplingResult; private final SamplingResult offSamplingResult; + private final String description; /** * Creates rate limiting sampler. @@ -34,12 +43,13 @@ public class RateLimitingSampler implements Sampler { * @param maxTracesPerSecond the maximum number of sampled traces per second. */ public RateLimitingSampler(int maxTracesPerSecond) { - this.maxTracesPerSecond = maxTracesPerSecond; double maxBalance = maxTracesPerSecond < 1.0 ? 1.0 : maxTracesPerSecond; - this.rateLimiter = new RateLimiter(maxTracesPerSecond, maxBalance, SystemClock.getInstance()); - Attributes attributes = Attributes.empty(); + this.rateLimiter = new RateLimiter(maxTracesPerSecond, maxBalance, Clock.getDefault()); + Attributes attributes = + Attributes.of(SAMPLER_TYPE, TYPE, SAMPLER_PARAM, (double) maxTracesPerSecond); this.onSamplingResult = SamplingResult.create(SamplingDecision.RECORD_AND_SAMPLE, attributes); this.offSamplingResult = SamplingResult.create(SamplingDecision.DROP, attributes); + description = "RateLimitingSampler{" + decimalFormat(maxTracesPerSecond) + "}"; } @Override @@ -50,12 +60,12 @@ public SamplingResult shouldSample( SpanKind spanKind, Attributes attributes, List parentLinks) { - return this.rateLimiter.checkCredit(1.0) ? onSamplingResult : offSamplingResult; + return this.rateLimiter.trySpend(1.0) ? onSamplingResult : offSamplingResult; } @Override public String getDescription() { - return String.format("RateLimitingSampler{%.2f}", maxTracesPerSecond); + return description; } @Override @@ -63,8 +73,11 @@ public String toString() { return getDescription(); } - // Visible for testing - double getMaxTracesPerSecond() { - return maxTracesPerSecond; + private static String decimalFormat(double value) { + DecimalFormatSymbols decimalFormatSymbols = DecimalFormatSymbols.getInstance(); + decimalFormatSymbols.setDecimalSeparator('.'); + + DecimalFormat decimalFormat = new DecimalFormat("0.00", decimalFormatSymbols); + return decimalFormat.format(value); } } diff --git a/jaeger-extension-native/src/main/java/module-info.java b/native/src/main/java/module-info.java similarity index 89% rename from jaeger-extension-native/src/main/java/module-info.java rename to native/src/main/java/module-info.java index c50e2af5..b2a70c41 100644 --- a/jaeger-extension-native/src/main/java/module-info.java +++ b/native/src/main/java/module-info.java @@ -1,8 +1,6 @@ module io.ballerina.observe.trace.extension.jaeger { requires io.ballerina.runtime; - requires jaeger.core; requires io.opentelemetry.api; - requires io.opentelemetry.api.metrics; requires io.opentelemetry.context; requires io.opentelemetry.sdk.trace; requires io.opentelemetry.sdk.common; diff --git a/jaeger-extension-native/src/main/resources/META-INF/native-image/org.ballerinalang/jaeger-extension-native/native-image.properties b/native/src/main/resources/META-INF/native-image/org.ballerinalang/jaeger-extension-native/native-image.properties similarity index 100% rename from jaeger-extension-native/src/main/resources/META-INF/native-image/org.ballerinalang/jaeger-extension-native/native-image.properties rename to native/src/main/resources/META-INF/native-image/org.ballerinalang/jaeger-extension-native/native-image.properties diff --git a/jaeger-extension-native/src/main/resources/META-INF/native-image/org.ballerinalang/jaeger-extension-native/reflect-config.json b/native/src/main/resources/META-INF/native-image/org.ballerinalang/jaeger-extension-native/reflect-config.json similarity index 100% rename from jaeger-extension-native/src/main/resources/META-INF/native-image/org.ballerinalang/jaeger-extension-native/reflect-config.json rename to native/src/main/resources/META-INF/native-image/org.ballerinalang/jaeger-extension-native/reflect-config.json diff --git a/jaeger-extension-native/src/main/resources/META-INF/native-image/org.ballerinalang/jaeger-extension-native/resource-config.json b/native/src/main/resources/META-INF/native-image/org.ballerinalang/jaeger-extension-native/resource-config.json similarity index 100% rename from jaeger-extension-native/src/main/resources/META-INF/native-image/org.ballerinalang/jaeger-extension-native/resource-config.json rename to native/src/main/resources/META-INF/native-image/org.ballerinalang/jaeger-extension-native/resource-config.json diff --git a/jaeger-extension-native/src/main/resources/META-INF/services/io.ballerina.runtime.observability.tracer.spi.TracerProvider b/native/src/main/resources/META-INF/services/io.ballerina.runtime.observability.tracer.spi.TracerProvider similarity index 100% rename from jaeger-extension-native/src/main/resources/META-INF/services/io.ballerina.runtime.observability.tracer.spi.TracerProvider rename to native/src/main/resources/META-INF/services/io.ballerina.runtime.observability.tracer.spi.TracerProvider diff --git a/settings.gradle b/settings.gradle index 76a78096..1dfe18f2 100644 --- a/settings.gradle +++ b/settings.gradle @@ -26,9 +26,9 @@ include(':jaeger-extension-native') include(':jaeger-extension-tests') project(':build-config:checkstyle').projectDir = file('build-config/checkstyle') -project(':jaeger-extension-ballerina').projectDir = file('jaeger-extension-ballerina') -project(':jaeger-extension-native').projectDir = file('jaeger-extension-native') -project(':jaeger-extension-tests').projectDir = file('jaeger-extension-tests') +project(':jaeger-extension-ballerina').projectDir = file('ballerina') +project(':jaeger-extension-native').projectDir = file('native') +project(':jaeger-extension-tests').projectDir = file('ballerina-tests') gradleEnterprise { buildScan { diff --git a/jaeger-extension-tests/build.gradle b/tests/build.gradle similarity index 100% rename from jaeger-extension-tests/build.gradle rename to tests/build.gradle diff --git a/jaeger-extension-tests/spotbugs-test-exclude.xml b/tests/spotbugs-test-exclude.xml similarity index 100% rename from jaeger-extension-tests/spotbugs-test-exclude.xml rename to tests/spotbugs-test-exclude.xml diff --git a/jaeger-extension-tests/src/test/java/io/ballerina/observe/trace/jaeger/BaseTestCase.java b/tests/src/test/java/io/ballerina/observe/trace/jaeger/BaseTestCase.java similarity index 100% rename from jaeger-extension-tests/src/test/java/io/ballerina/observe/trace/jaeger/BaseTestCase.java rename to tests/src/test/java/io/ballerina/observe/trace/jaeger/BaseTestCase.java diff --git a/jaeger-extension-tests/src/test/java/io/ballerina/observe/trace/jaeger/JaegerTracesTestCase.java b/tests/src/test/java/io/ballerina/observe/trace/jaeger/JaegerTracesTestCase.java similarity index 100% rename from jaeger-extension-tests/src/test/java/io/ballerina/observe/trace/jaeger/JaegerTracesTestCase.java rename to tests/src/test/java/io/ballerina/observe/trace/jaeger/JaegerTracesTestCase.java diff --git a/jaeger-extension-tests/src/test/java/io/ballerina/observe/trace/jaeger/backend/ContainerLogReader.java b/tests/src/test/java/io/ballerina/observe/trace/jaeger/backend/ContainerLogReader.java similarity index 100% rename from jaeger-extension-tests/src/test/java/io/ballerina/observe/trace/jaeger/backend/ContainerLogReader.java rename to tests/src/test/java/io/ballerina/observe/trace/jaeger/backend/ContainerLogReader.java diff --git a/jaeger-extension-tests/src/test/java/io/ballerina/observe/trace/jaeger/backend/ContainerizedJaegerServer.java b/tests/src/test/java/io/ballerina/observe/trace/jaeger/backend/ContainerizedJaegerServer.java similarity index 100% rename from jaeger-extension-tests/src/test/java/io/ballerina/observe/trace/jaeger/backend/ContainerizedJaegerServer.java rename to tests/src/test/java/io/ballerina/observe/trace/jaeger/backend/ContainerizedJaegerServer.java diff --git a/jaeger-extension-tests/src/test/java/io/ballerina/observe/trace/jaeger/backend/JaegerServer.java b/tests/src/test/java/io/ballerina/observe/trace/jaeger/backend/JaegerServer.java similarity index 100% rename from jaeger-extension-tests/src/test/java/io/ballerina/observe/trace/jaeger/backend/JaegerServer.java rename to tests/src/test/java/io/ballerina/observe/trace/jaeger/backend/JaegerServer.java diff --git a/jaeger-extension-tests/src/test/java/io/ballerina/observe/trace/jaeger/backend/JaegerServerProtocol.java b/tests/src/test/java/io/ballerina/observe/trace/jaeger/backend/JaegerServerProtocol.java similarity index 100% rename from jaeger-extension-tests/src/test/java/io/ballerina/observe/trace/jaeger/backend/JaegerServerProtocol.java rename to tests/src/test/java/io/ballerina/observe/trace/jaeger/backend/JaegerServerProtocol.java diff --git a/jaeger-extension-tests/src/test/java/io/ballerina/observe/trace/jaeger/backend/ProcessJaegerServer.java b/tests/src/test/java/io/ballerina/observe/trace/jaeger/backend/ProcessJaegerServer.java similarity index 100% rename from jaeger-extension-tests/src/test/java/io/ballerina/observe/trace/jaeger/backend/ProcessJaegerServer.java rename to tests/src/test/java/io/ballerina/observe/trace/jaeger/backend/ProcessJaegerServer.java diff --git a/jaeger-extension-tests/src/test/java/io/ballerina/observe/trace/jaeger/backend/ProcessLogReader.java b/tests/src/test/java/io/ballerina/observe/trace/jaeger/backend/ProcessLogReader.java similarity index 100% rename from jaeger-extension-tests/src/test/java/io/ballerina/observe/trace/jaeger/backend/ProcessLogReader.java rename to tests/src/test/java/io/ballerina/observe/trace/jaeger/backend/ProcessLogReader.java diff --git a/jaeger-extension-tests/src/test/java/io/ballerina/observe/trace/jaeger/model/JaegerProcess.java b/tests/src/test/java/io/ballerina/observe/trace/jaeger/model/JaegerProcess.java similarity index 100% rename from jaeger-extension-tests/src/test/java/io/ballerina/observe/trace/jaeger/model/JaegerProcess.java rename to tests/src/test/java/io/ballerina/observe/trace/jaeger/model/JaegerProcess.java diff --git a/jaeger-extension-tests/src/test/java/io/ballerina/observe/trace/jaeger/model/JaegerQueryResponse.java b/tests/src/test/java/io/ballerina/observe/trace/jaeger/model/JaegerQueryResponse.java similarity index 100% rename from jaeger-extension-tests/src/test/java/io/ballerina/observe/trace/jaeger/model/JaegerQueryResponse.java rename to tests/src/test/java/io/ballerina/observe/trace/jaeger/model/JaegerQueryResponse.java diff --git a/jaeger-extension-tests/src/test/java/io/ballerina/observe/trace/jaeger/model/JaegerQueryResponseTypeToken.java b/tests/src/test/java/io/ballerina/observe/trace/jaeger/model/JaegerQueryResponseTypeToken.java similarity index 100% rename from jaeger-extension-tests/src/test/java/io/ballerina/observe/trace/jaeger/model/JaegerQueryResponseTypeToken.java rename to tests/src/test/java/io/ballerina/observe/trace/jaeger/model/JaegerQueryResponseTypeToken.java diff --git a/jaeger-extension-tests/src/test/java/io/ballerina/observe/trace/jaeger/model/JaegerSpan.java b/tests/src/test/java/io/ballerina/observe/trace/jaeger/model/JaegerSpan.java similarity index 100% rename from jaeger-extension-tests/src/test/java/io/ballerina/observe/trace/jaeger/model/JaegerSpan.java rename to tests/src/test/java/io/ballerina/observe/trace/jaeger/model/JaegerSpan.java diff --git a/jaeger-extension-tests/src/test/java/io/ballerina/observe/trace/jaeger/model/JaegerSpanReference.java b/tests/src/test/java/io/ballerina/observe/trace/jaeger/model/JaegerSpanReference.java similarity index 100% rename from jaeger-extension-tests/src/test/java/io/ballerina/observe/trace/jaeger/model/JaegerSpanReference.java rename to tests/src/test/java/io/ballerina/observe/trace/jaeger/model/JaegerSpanReference.java diff --git a/jaeger-extension-tests/src/test/java/io/ballerina/observe/trace/jaeger/model/JaegerTag.java b/tests/src/test/java/io/ballerina/observe/trace/jaeger/model/JaegerTag.java similarity index 100% rename from jaeger-extension-tests/src/test/java/io/ballerina/observe/trace/jaeger/model/JaegerTag.java rename to tests/src/test/java/io/ballerina/observe/trace/jaeger/model/JaegerTag.java diff --git a/jaeger-extension-tests/src/test/java/io/ballerina/observe/trace/jaeger/model/JaegerTrace.java b/tests/src/test/java/io/ballerina/observe/trace/jaeger/model/JaegerTrace.java similarity index 100% rename from jaeger-extension-tests/src/test/java/io/ballerina/observe/trace/jaeger/model/JaegerTrace.java rename to tests/src/test/java/io/ballerina/observe/trace/jaeger/model/JaegerTrace.java diff --git a/jaeger-extension-tests/src/test/resources/bal/01_http_svc_test.bal b/tests/src/test/resources/bal/01_http_svc_test.bal similarity index 100% rename from jaeger-extension-tests/src/test/resources/bal/01_http_svc_test.bal rename to tests/src/test/resources/bal/01_http_svc_test.bal diff --git a/jaeger-extension-tests/src/test/resources/bal/ConfigAgent.toml b/tests/src/test/resources/bal/ConfigAgent.toml similarity index 100% rename from jaeger-extension-tests/src/test/resources/bal/ConfigAgent.toml rename to tests/src/test/resources/bal/ConfigAgent.toml diff --git a/jaeger-extension-tests/src/test/resources/bal/ConfigDefault.toml b/tests/src/test/resources/bal/ConfigDefault.toml similarity index 100% rename from jaeger-extension-tests/src/test/resources/bal/ConfigDefault.toml rename to tests/src/test/resources/bal/ConfigDefault.toml diff --git a/jaeger-extension-tests/src/test/resources/bal/ConfigInvalidProvider.toml b/tests/src/test/resources/bal/ConfigInvalidProvider.toml similarity index 100% rename from jaeger-extension-tests/src/test/resources/bal/ConfigInvalidProvider.toml rename to tests/src/test/resources/bal/ConfigInvalidProvider.toml diff --git a/jaeger-extension-tests/src/test/resources/bal/ConfigInvalidSampler.toml b/tests/src/test/resources/bal/ConfigInvalidSampler.toml similarity index 100% rename from jaeger-extension-tests/src/test/resources/bal/ConfigInvalidSampler.toml rename to tests/src/test/resources/bal/ConfigInvalidSampler.toml diff --git a/jaeger-extension-tests/src/test/resources/bal/ConfigSamplerConst.toml b/tests/src/test/resources/bal/ConfigSamplerConst.toml similarity index 100% rename from jaeger-extension-tests/src/test/resources/bal/ConfigSamplerConst.toml rename to tests/src/test/resources/bal/ConfigSamplerConst.toml diff --git a/jaeger-extension-tests/src/test/resources/bal/ConfigSamplerProbabilistic.toml b/tests/src/test/resources/bal/ConfigSamplerProbabilistic.toml similarity index 100% rename from jaeger-extension-tests/src/test/resources/bal/ConfigSamplerProbabilistic.toml rename to tests/src/test/resources/bal/ConfigSamplerProbabilistic.toml diff --git a/jaeger-extension-tests/src/test/resources/bal/ConfigSamplerRatelimiting.toml b/tests/src/test/resources/bal/ConfigSamplerRatelimiting.toml similarity index 100% rename from jaeger-extension-tests/src/test/resources/bal/ConfigSamplerRatelimiting.toml rename to tests/src/test/resources/bal/ConfigSamplerRatelimiting.toml diff --git a/jaeger-extension-tests/src/test/resources/logging.properties b/tests/src/test/resources/logging.properties similarity index 100% rename from jaeger-extension-tests/src/test/resources/logging.properties rename to tests/src/test/resources/logging.properties diff --git a/jaeger-extension-tests/src/test/resources/testng.xml b/tests/src/test/resources/testng.xml similarity index 100% rename from jaeger-extension-tests/src/test/resources/testng.xml rename to tests/src/test/resources/testng.xml