diff --git a/.buildkite/README.md b/.buildkite/README.md index 0a13f51042..409c434e41 100644 --- a/.buildkite/README.md +++ b/.buildkite/README.md @@ -9,7 +9,7 @@ This is the Buildkite pipeline for releasing the APM Agent Java. ### Pipeline Configuration To view the pipeline and its configuration, click [here](https://buildkite.com/elastic/apm-agent-java-release) or -go to the definition in the `elastic/ci` repository. +go to the definition in `release.yml`. ### Credentials @@ -25,7 +25,7 @@ This is the Buildkite pipeline for the APM Agent Java in charge of the snapshots ### Pipeline Configuration To view the pipeline and its configuration, click [here](https://buildkite.com/elastic/apm-agent-java-snapshot) or -go to the definition in the `elastic/ci` repository. +go to the definition in `snapshot.yml`. ## opentelemetry-benchmark pipeline @@ -35,3 +35,15 @@ This is the Buildkite pipeline for the Opentelemetry Benchmark. To view the pipeline and its configuration, click [here](https://buildkite.com/elastic/apm-agent-java-opentelemetry-benchmark) or go to the definition in `opentelemetry-benchmark.yml`. + +## Buildkite VM runners + +A set of Buildkite VM runners has been created for this repository. The VM runners contain +the required software: +* JDK +* GPG +* Maven dependencies + +If a new version of Java is required, update the `.java-version` file with the latest major. When the changes are merged onto `main,` wait for the following day; that's when the automation will be responsible for recreating the VM with the new Java version. + +If you would like to know more about how it works, please go to https://github.com/elastic/ci-agent-images/tree/main/vm-images/apm-agent-java (**NOTE**: only available for Elastic employees) diff --git a/.buildkite/hooks/prepare-common.sh b/.buildkite/hooks/prepare-common.sh index 68cf0d4ad4..f5fc876099 100644 --- a/.buildkite/hooks/prepare-common.sh +++ b/.buildkite/hooks/prepare-common.sh @@ -1,17 +1,27 @@ #!/usr/bin/env bash set -euo pipefail -echo "--- Install JDK17 :java:" -# JDK version is defined in two different locations, here and .github/workflows/maven-goal/action.yml -JAVA_URL=https://jvm-catalog.elastic.co/jdk -JAVA_HOME=$(pwd)/.openjdk17 -JAVA_PKG="$JAVA_URL/latest_openjdk_17_linux.tar.gz" -curl -L --output /tmp/jdk.tar.gz "$JAVA_PKG" -mkdir -p "$JAVA_HOME" -tar --extract --file /tmp/jdk.tar.gz --directory "$JAVA_HOME" --strip-components 1 - +# Configure the java version +JAVA_VERSION=$(cat .java-version | xargs | tr -dc '[:print:]') +JAVA_HOME="${HOME}/.java/openjdk${JAVA_VERSION}" export JAVA_HOME -PATH=$JAVA_HOME/bin:$PATH +PATH="${JAVA_HOME}/bin:${PATH}" export PATH -java -version || true +if [ -d "${JAVA_HOME}" ] ; then + echo "--- Skip installing JDK${JAVA_VERSION} :java:" + echo "already available in the Buildkite runner" +else + # Fallback to install at runtime + # This should not be the case normally untless the .java-version file has been changed + # and the VM Image is not yet available with the latest version. + echo "--- Install JDK${JAVA_VERSION} :java:" + JAVA_URL=https://jvm-catalog.elastic.co/jdk + JAVA_PKG="${JAVA_URL}/latest_openjdk_${JAVA_VERSION}_linux.tar.gz" + curl -L --output /tmp/jdk.tar.gz "${JAVA_PKG}" + mkdir -p "${JAVA_HOME}" + tar --extract --file /tmp/jdk.tar.gz --directory "${JAVA_HOME}" --strip-components 1 +fi + +# Validate java is available in the runner. +java -version diff --git a/.buildkite/release.yml b/.buildkite/release.yml index 1b6a41fae7..347f35358e 100644 --- a/.buildkite/release.yml +++ b/.buildkite/release.yml @@ -1,5 +1,6 @@ agents: provider: "gcp" + image: "family/apm-agent-java-ubuntu-2204" steps: - label: "Run the release" @@ -11,4 +12,5 @@ steps: notify: - slack: "#apm-agent-java" - if: 'build.state != "passed"' + # skip slack messages if no failures and dry-run mode + if: 'build.state != "passed" && build.env("dry_run") == "false"' diff --git a/.buildkite/snapshot.yml b/.buildkite/snapshot.yml index c33406f9f4..c5cf1bcb79 100644 --- a/.buildkite/snapshot.yml +++ b/.buildkite/snapshot.yml @@ -1,5 +1,6 @@ agents: provider: "gcp" + image: "family/apm-agent-java-ubuntu-2204" steps: - label: "Run the snapshot" @@ -11,4 +12,5 @@ steps: notify: - slack: "#apm-agent-java" - if: 'build.state != "passed"' + # skip slack messages if no failures and dry-run mode + if: 'build.state != "passed" && build.env("dry_run") == "false"' diff --git a/.ci/release.sh b/.ci/release.sh index 77a418d863..b05947ce95 100755 --- a/.ci/release.sh +++ b/.ci/release.sh @@ -21,5 +21,14 @@ echo $PATH java -version set +x -echo "--- Deploy the release :package:" -./mvnw -V -s .ci/settings.xml -Pgpg clean deploy -DskipTests --batch-mode | tee release.txt +# Default in dry-run mode +GOAL="install" +DRY_RUN_MSG="(dry-run)" +# Otherwise, a RELEASE +if [[ "$dry_run" == "false" ]] ; then + GOAL="deploy" + DRY_RUN_MSG="" +fi + +echo "--- Deploy the release :package: [./mvnw $GOAL)] $DRY_RUN_MSG" +./mvnw -V -s .ci/settings.xml -Pgpg clean $GOAL -DskipTests --batch-mode | tee release.txt diff --git a/.ci/release/post-release.sh b/.ci/release/post-release.sh new file mode 100755 index 0000000000..e54662cdfe --- /dev/null +++ b/.ci/release/post-release.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +# Bash strict mode +set -euo pipefail + +# Found current script directory +RELATIVE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +# Found project directory +BASE_PROJECT="$(dirname $(dirname "${RELATIVE_DIR}"))" + +# Import dependencies +source "${RELATIVE_DIR}/util.sh" + +# Constants +BASE_URL="https://repo1.maven.org/maven2/co/elastic/apm/elastic-apm-agent" +CF_FILE="${BASE_PROJECT}/cloudfoundry/index.yml" + +# Requirements +check_version "${RELEASE_VERSION}" + +echo "Set next snapshot version" +./mvnw -V versions:set -DprocessAllModules=true -DgenerateBackupPoms=false -DnextSnapshot=true + +# make script idempotent if release is already in CF descriptor +set +e +grep -e "^${RELEASE_VERSION}:" ${CF_FILE} +[[ $? == 0 ]] && exit 0 +set -e +echo "Update cloudfoundry version" +echo "${RELEASE_VERSION}: ${BASE_URL}/${RELEASE_VERSION}/elastic-apm-agent-${RELEASE_VERSION}.jar" >> "${CF_FILE}" diff --git a/.ci/release/pre-release.sh b/.ci/release/pre-release.sh new file mode 100755 index 0000000000..ae981a3dc9 --- /dev/null +++ b/.ci/release/pre-release.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# Bash strict mode +set -euo pipefail + +# Found current script directory +RELATIVE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +# Found project directory +BASE_PROJECT="$(dirname $(dirname "${RELATIVE_DIR}"))" + +# Import dependencies +source "${RELATIVE_DIR}/util.sh" + +# Requirements +check_version "${RELEASE_VERSION}" + +echo "Set release version" +./mvnw -V versions:set -DprocessAllModules=true -DgenerateBackupPoms=false -DnewVersion="${RELEASE_VERSION}" + +echo "Prepare changelog for release" +java "${BASE_PROJECT}/.ci/ReleaseChangelog.java" CHANGELOG.asciidoc "${RELEASE_VERSION}" diff --git a/.ci/release/update_major_branch.sh b/.ci/release/update-major-branch.sh similarity index 85% rename from .ci/release/update_major_branch.sh rename to .ci/release/update-major-branch.sh index 8fa883878b..146364f498 100755 --- a/.ci/release/update_major_branch.sh +++ b/.ci/release/update-major-branch.sh @@ -62,3 +62,10 @@ git checkout --force ${checkout_options} echo -e "\n--- move local branch ${major_branch} to match tag ${tag}" git reset --hard ${tag} + +echo -e "\n--- create new branch with updates" +git checkout -b "update-major-${v}" +git push origin "update-major-${v}" + +echo -e "\n--- create PR to update major branch" +gh pr create --title="post release v${v}: update major branch" --base "${major_branch}" --head "update-major-${v}" -b "post release v${v}" diff --git a/.ci/release/update_cloudfoundry.sh b/.ci/release/update_cloudfoundry.sh deleted file mode 100755 index 436b5b2365..0000000000 --- a/.ci/release/update_cloudfoundry.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail -source "$(dirname "${0}")/util.sh" - -REMOTE_NAME=origin -BRANCH_NAME=main -BASE_URL=https://repo1.maven.org/maven2/co/elastic/apm/elastic-apm-agent -CF_FILE=cloudfoundry/index.yml - -check_version "${1:-}" -v="${1:-}" - -echo -e "\n--- fetch & ensure clean state of ${REMOTE_NAME}/${BRANCH_NAME}" -git fetch ${REMOTE_NAME} ${BRANCH_NAME} -git checkout ${BRANCH_NAME} -git reset --hard ${REMOTE_NAME}/${BRANCH_NAME} - -echo -e "\n--- update ${CF_FILE} if required" - -# make script idempotent if release is already in CF descriptor -set +e -grep -e "^${v}:" ${CF_FILE} -[[ $? == 0 ]] && exit 0 -set -e - -echo "${v}: ${BASE_URL}/${v}/elastic-apm-agent-${v}.jar" >> ${CF_FILE} -git commit ${CF_FILE} -m "Update cloudfoundry for ${v} release" diff --git a/.ci/release/util.sh b/.ci/release/util.sh index 8dd546ad93..f2cbf4a323 100644 --- a/.ci/release/util.sh +++ b/.ci/release/util.sh @@ -3,14 +3,12 @@ check_version() { v=${1:-} - if [[ "${v}" == "" ]]; then - echo "usage $0 " # here $0 will be the calling script - echo "where in format '1.2.3'" + if [ -z "${v}" ]; then + >&2 echo "The environment variable 'RELEASE_VERSION' isn't defined" exit 1 fi - - if [[ ! "$v" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "invalid version format '${v}'" + if [[ ! "${v}" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then + >&2 echo "The environment variable 'RELEASE_VERSION' should respect SemVer format" exit 1 fi } diff --git a/.ci/release/wait_maven_artifact_published.sh b/.ci/release/wait_maven_artifact_published.sh deleted file mode 100755 index 7c12d96c22..0000000000 --- a/.ci/release/wait_maven_artifact_published.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail -source "$(dirname "${0}")/util.sh" - -# returns '0' (zero) status code when artifact exists -# return non-zero status when artifact does not exists or unable to execute request - -check_version "${1:-}" -v="${1:-}" - -full_url="https://repo1.maven.org/maven2/co/elastic/apm/elastic-apm-agent/${v}/elastic-apm-agent-${v}.pom" -curl -fs "${full_url}" 2>&1 > /dev/null diff --git a/.ci/snapshot.sh b/.ci/snapshot.sh index 63ec170778..a11cd4eb9a 100755 --- a/.ci/snapshot.sh +++ b/.ci/snapshot.sh @@ -23,9 +23,14 @@ echo $PATH java -version set +x -echo "--- Deploy the snapshot :package:" -if [[ "$dry_run" == "true" ]] ; then - echo './mvnw -V -s .ci/settings.xml -Pgpg clean deploy -DskipTests --batch-mode' -else - ./mvnw -V -s .ci/settings.xml -Pgpg clean deploy -DskipTests --batch-mode | tee snapshot.txt +# Default in dry-run mode +GOAL="install" +DRY_RUN_MSG="(dry-run)" +# Otherwise, a snapshot +if [[ "$dry_run" == "false" ]] ; then + GOAL="deploy" + DRY_RUN_MSG="" fi + +echo "--- Deploy the snapshot :package: [./mvnw $GOAL)] $DRY_RUN_MSG" +./mvnw -V -s .ci/settings.xml -Pgpg clean $GOAL -DskipTests --batch-mode | tee snapshot.txt diff --git a/.github/workflows/README.md b/.github/workflows/README.md index d2d093d024..cbc0140d24 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -35,8 +35,12 @@ Every time there is a merge to main or any branches the whole workflow will comp ### Release process -This process has been fully automated and it gets triggered manually when running the [release](https://github.com/elastic/apm-agent-java/actions/workflows/release.yml) workflow. It runs then a Buildkite pipeline in charge of generating and publishing the artifacts, +To release a new version of apm-agent-java, you must use the two GitHub Workflows. +Trigger the `Pre Release` workflow targeting the release version. +After merging the PRs created by the first workflow, you can trigger the `Release` workflow targeting the release version. +It runs then a Buildkite pipeline in charge of generating and publishing the artifacts, for further details please go to [the buildkite folder](../../.buildkite/README.md). +Finally, merge the PRs created to bump version for the next iteration. The tag release follows the naming convention: `v...`, where ``, `` and ``. diff --git a/.github/workflows/addToProject.yml b/.github/workflows/addToProject.yml index 7f49a3a657..e7befea26f 100644 --- a/.github/workflows/addToProject.yml +++ b/.github/workflows/addToProject.yml @@ -3,6 +3,9 @@ on: issues: types: - opened, milestoned +permissions: + contents: read + jobs: add_to_project: if: github.event.issue && github.event.issue.milestone diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 36eb42ad80..809b6eda02 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -5,6 +5,11 @@ on: pull_request_target: types: [opened] +permissions: + contents: read + issues: write + pull-requests: write + jobs: triage: runs-on: ubuntu-latest diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0e31fd70f5..419c369cd3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -305,7 +305,7 @@ jobs: distribution: 'temurin' steps: - uses: actions/checkout@v4 - - uses: ./.github/workflows/maven-goal + - uses: ./.github/workflows/maven-goal-jdk with: test-java-version: ${{ matrix.version }} test-java-distribution: ${{ matrix.distribution }} diff --git a/.github/workflows/maven-goal-jdk/action.yml b/.github/workflows/maven-goal-jdk/action.yml new file mode 100644 index 0000000000..43379e2fcf --- /dev/null +++ b/.github/workflows/maven-goal-jdk/action.yml @@ -0,0 +1,44 @@ +--- + +name: common build tasks +description: Install specific JDK and run a command + +inputs: + test-java-version: + description: 'Testing Java version' + required: true + default: '17' + test-java-distribution: + description: 'Testing Java distribution' + required: true + default: 'temurin' + command: + description: 'Command to execute' + required: true + shell: + description: 'Default shell' + default: 'bash' + required: false + +runs: + using: "composite" + steps: + - name: Set up testing JDK + uses: actions/setup-java@v4 + with: + java-version: ${{ inputs.test-java-version}} + distribution: ${{ inputs.test-java-distribution}} + + - name: Set up TEST_JAVA_BINARY environment variable + shell: bash + run: | + major_version="$(echo '${{ inputs.test-java-version }}' | sed 's/\([0-9]*\).*/\1/')" + java_home_var=JAVA_HOME_${major_version}_${{ runner.arch }} + echo "TEST_JAVA_BINARY=${!java_home_var}/bin/java" >> $GITHUB_ENV + + - uses: ./.github/workflows/maven-goal + with: + command: ${{ inputs.command }} + shell: ${{ inputs.shell }} + env: + TEST_JAVA_BINARY: ${{ env.TEST_JAVA_BINARY }} diff --git a/.github/workflows/maven-goal/action.yml b/.github/workflows/maven-goal/action.yml index a2ddbea62b..371934f3a4 100644 --- a/.github/workflows/maven-goal/action.yml +++ b/.github/workflows/maven-goal/action.yml @@ -4,14 +4,6 @@ name: common build tasks description: Install specific JDK and run a command inputs: - test-java-version: - description: 'Testing Java version' - required: true - default: '17' - test-java-distribution: - description: 'Testing Java distribution' - required: true - default: 'temurin' command: description: 'Command to execute' required: true @@ -23,23 +15,11 @@ inputs: runs: using: "composite" steps: - - name: Set up testing JDK - if: ${{ inputs.test-java-version != '17' }} - uses: actions/setup-java@v4 - with: - java-version: ${{ inputs.test-java-version}} - distribution: ${{ inputs.test-java-distribution}} - name: Set up build JDK uses: actions/setup-java@v4 with: - java-version: 17 # NOTE: This version is also defined in .buildkite/hooks/pre-command + java-version-file: .java-version distribution: temurin cache: 'maven' - - name: Set up TEST_JAVA_BINARY environment variable - shell: bash - run: | - major_version="$(echo '${{ inputs.test-java-version }}' | sed 's/\([0-9]*\).*/\1/')" - java_home_var=JAVA_HOME_${major_version}_${{ runner.arch }} - echo "TEST_JAVA_BINARY=${!java_home_var}/bin/java" >> $GITHUB_ENV - run: ${{ inputs.command }} shell: ${{ inputs.shell }} diff --git a/.github/workflows/pre-post-release.yml b/.github/workflows/pre-post-release.yml new file mode 100644 index 0000000000..e34026ebd4 --- /dev/null +++ b/.github/workflows/pre-post-release.yml @@ -0,0 +1,98 @@ +--- + +name: Pre/Post Release + +on: + workflow_call: + inputs: + ref: + description: 'Branch or tag ref to run the workflow on' + type: string + required: true + default: "main" + version: + description: 'The version to release (e.g. 1.2.3). This workflow will automatically perform the required version bumps' + type: string + required: true + phase: + description: 'Pre or post release phase' + type: string # valid values are 'pre' or 'post' + required: true + +env: + RELEASE_VERSION: ${{ inputs.version }} + RELEASE_VERSION_TAG: v${{ inputs.version }} + BRANCH_NAME: ${{ inputs.phase }}-release-v${{ inputs.version }} + +permissions: + contents: read + +jobs: + validate-tag: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Validate release tag does not exist in repo + uses: ./.github/workflows/validate-tag + with: + tag: ${{ env.RELEASE_VERSION_TAG }} + + create-pr: + name: "Bump versions and create PR" + runs-on: ubuntu-latest + needs: + - validate-tag + permissions: + contents: write + steps: + - uses: elastic/apm-pipeline-library/.github/actions/github-token@current + with: + url: ${{ secrets.VAULT_ADDR }} + roleId: ${{ secrets.VAULT_ROLE_ID }} + secretId: ${{ secrets.VAULT_SECRET_ID }} + + - uses: elastic/apm-pipeline-library/.github/actions/setup-git@current + with: + username: ${{ env.GIT_USER }} + email: ${{ env.GIT_EMAIL }} + token: ${{ env.GITHUB_TOKEN }} + + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref }} + token: ${{ env.GITHUB_TOKEN }} + + - name: Create the release tag (post phase) + if: inputs.phase == 'post' + run: | + git tag "${{ env.RELEASE_VERSION_TAG }}" + git push origin "${{ env.RELEASE_VERSION_TAG }}" + + - name: Create a ${{ inputs.phase }} release branch + run: git checkout -b ${{ env.BRANCH_NAME }} + + - name: Perform pre release changes + if: inputs.phase == 'pre' + uses: ./.github/workflows/maven-goal-jdk + with: + command: ./.ci/release/pre-release.sh + + - name: Perform post release changes + if: inputs.phase == 'post' + uses: ./.github/workflows/maven-goal + with: + command: ./.ci/release/post-release.sh + + - name: Push the ${{ inputs.phase }} release branch + run: | + git add --all + git commit -m "${{ inputs.phase }} release: elastic-apm-agent ${{ env.RELEASE_VERSION_TAG }}" + git push origin ${{ env.BRANCH_NAME }} + + - name: Create the ${{ inputs.phase }} release PR + run: gh pr create --title="${{ inputs.phase }} release ${{ env.RELEASE_VERSION_TAG }}" --base main --head ${{ env.BRANCH_NAME }} -b "${{ inputs.phase }} release ${{ env.RELEASE_VERSION_TAG }}" + env: + GH_TOKEN: ${{ env.GITHUB_TOKEN }} diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml new file mode 100644 index 0000000000..3fb0b6f71f --- /dev/null +++ b/.github/workflows/pre-release.yml @@ -0,0 +1,32 @@ +--- + +name: Pre release + +on: + workflow_dispatch: + inputs: + ref: + description: 'Branch or tag ref to run the workflow on' + required: true + default: "main" + version: + description: 'The version to release (e.g. 1.2.3). This workflow will automatically perform the required version bumps' + required: true + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }} + +jobs: + pre-release: + name: "Bump versions and create PR" + uses: ./.github/workflows/pre-post-release.yml + permissions: + contents: write + with: + ref: ${{ inputs.ref }} + version: ${{ inputs.version }} + phase: 'pre' + secrets: inherit diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 04915c1910..d7b05b048f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,20 +5,13 @@ name: release on: workflow_dispatch: inputs: - branch: - description: 'The branch to release' + ref: + description: 'Branch or tag ref to run the workflow on' required: true - default: 'main' + default: "main" version: description: 'The version to release (e.g. 1.2.3). This workflow will automatically perform the required version bumps' required: true - update_changelog: - description: | - If enabled, everything in the changelog from the "Unreleased" section will be automatically moved to a new section for the new release. - If disabled, the changelog needs to be prepared for the release manually before triggering this workflow. - type: boolean - required: true - default: true skip_preparation: description: | If enabled, the version bump, release notes update and tag creation will be skipped. @@ -34,11 +27,10 @@ on: type: boolean required: true default: false - -env: - JAVA_VERSION: 17 - JAVA_DIST: temurin - TAG_NAME: v${{ inputs.version }} + dry_run: + description: If set, run a dry-run release + default: false + type: boolean permissions: contents: read @@ -46,50 +38,42 @@ permissions: concurrency: group: ${{ github.workflow }} +env: + RELEASE_VERSION: ${{ inputs.version }} + RELEASE_VERSION_TAG: v${{ inputs.version }} + jobs: - prepare_release: - permissions: - contents: write - name: "Changelog and Version Bump" - if: ${{ ! inputs.skip_preparation }} + validate-tag: runs-on: ubuntu-latest steps: - - uses: elastic/apm-pipeline-library/.github/actions/github-token@current + - name: Checkout + uses: actions/checkout@v4 with: - url: ${{ secrets.VAULT_ADDR }} - roleId: ${{ secrets.VAULT_ROLE_ID }} - secretId: ${{ secrets.VAULT_SECRET_ID }} - - uses: elastic/apm-pipeline-library/.github/actions/setup-git@current + ref: ${{ inputs.ref }} + fetch-depth: 0 + - name: Validate tag does not exist on current commit + uses: ./.github/workflows/validate-tag with: - username: ${{ env.GIT_USER }} - email: ${{ env.GIT_EMAIL }} - token: ${{ env.GITHUB_TOKEN }} - - uses: actions/checkout@v4 - with: - ref: ${{ inputs.branch }} - token: ${{ env.GITHUB_TOKEN }} - - name: Set up JDK ${{ env.JAVA_VERSION }} - uses: actions/setup-java@v4 - with: - java-version: ${{ env.JAVA_VERSION }} - distribution: ${{ env.JAVA_DIST }} - cache: 'maven' - - name: Prepare changelog for release - if: ${{ inputs.update_changelog }} + tag: ${{ env.RELEASE_VERSION_TAG }} + - name: Validate tag match current version run: | - java .ci/ReleaseChangelog.java CHANGELOG.asciidoc ${{ inputs.version }} - git commit -m "Prepare changelog for release ${{ inputs.version }}" CHANGELOG.asciidoc - - name: Bump version and add git tag - run: ./mvnw release:prepare -B -DpushChanges=false "-Darguments=-DskipTests -Dmaven.javadoc.skip=true" -DreleaseVersion=${{ inputs.version }} - - run: git push --atomic origin ${{ inputs.branch }} ${{ env.TAG_NAME }} - + if [ "$(./mvnw -q help:evaluate -Dexpression=project.version -DforceStdout)" != "${{ env.RELEASE_VERSION }}" ]; then + echo "Tag should match pom.xml project.version" + exit 1 + fi + - name: Validate version is a release version + run: | + if [[ "$(./mvnw -q help:evaluate -Dexpression=project.version -DforceStdout)" =~ "-SNAPSHOT" ]]; then + echo "This is a snapshot version" + exit 1 + fi - maven_central_deploy: + maven-central-deploy: name: "Deploy to Maven Central (Buildkite)" if: ${{ ! inputs.skip_maven_deploy && ( inputs.skip_preparation || success() ) }} runs-on: ubuntu-latest needs: - - prepare_release + - validate-tag steps: - id: buildkite continue-on-error: true @@ -100,61 +84,28 @@ jobs: vaultRoleId: ${{ secrets.VAULT_ROLE_ID }} vaultSecretId: ${{ secrets.VAULT_SECRET_ID }} pipeline: apm-agent-java-release - pipelineCommit: ${{ env.TAG_NAME }} waitFor: true printBuildLogs: false - # The action fails with .github/actions/buildkite/run.sh: line 24: 3: parameter missing. - # Which is an unexpected bug. - # Adding a random buildEnvVar to circumvent the behaviour. buildEnvVars: | - something_something=true - + dry_run=${{ inputs.dry_run || 'false' }} - await_artifact_on_maven_central: + await-maven-central-artifact: name: "Wait for artifacts to be available on maven central" runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Await artifacts published in maven central - shell: bash - timeout-minutes: 120 - run: | - until .ci/release/wait_maven_artifact_published.sh ${{ inputs.version }} - do - echo "Artifacts not found on maven central. Sleeping 30 seconds, retrying afterwards" - sleep 30s - done - - update_major_branch: - name: "Update Major Branch" - runs-on: ubuntu-latest needs: - - await_artifact_on_maven_central - permissions: - contents: write + - validate-tag steps: - - uses: elastic/apm-pipeline-library/.github/actions/github-token@current - with: - url: ${{ secrets.VAULT_ADDR }} - roleId: ${{ secrets.VAULT_ROLE_ID }} - secretId: ${{ secrets.VAULT_SECRET_ID }} - - uses: elastic/apm-pipeline-library/.github/actions/setup-git@current + - uses: elastic/apm-pipeline-library/.github/actions/await-maven-artifact@current with: - username: ${{ env.GIT_USER }} - email: ${{ env.GIT_EMAIL }} - token: ${{ env.GITHUB_TOKEN }} - - uses: actions/checkout@v4 - with: - ref: ${{ env.TAG_NAME }} - token: ${{ env.GITHUB_TOKEN }} - - run: .ci/release/update_major_branch.sh ${{ inputs.version }} - - run: git push -f origin "$(echo '${{ inputs.version }}' | sed -E 's/\..+/.x/')" + groupid: 'co.elastic.apm' + artifactid: 'elastic-apm-agent' + version: ${{ env.RELEASE_VERSION }} - update_cloudfoundry: - name: "Update Cloudfoundry" + update-major-branch: + name: "Update Major Branch" runs-on: ubuntu-latest needs: - - await_artifact_on_maven_central + - await-maven-central-artifact permissions: contents: write steps: @@ -170,25 +121,23 @@ jobs: token: ${{ env.GITHUB_TOKEN }} - uses: actions/checkout@v4 with: - ref: ${{ inputs.branch }} + ref: ${{ inputs.ref }} token: ${{ env.GITHUB_TOKEN }} - - name: "Update Cloudfoundry index.yml file" - shell: bash - run: .ci/release/update_cloudfoundry.sh ${{ inputs.version }} - - run: git push origin ${{ inputs.branch }} + - name: Update major branch + if: ${{ ! inputs.dry_run }} + run: .ci/release/update-major-branch.sh ${{ env.RELEASE_VERSION }} - - build_and_push_docker_images: + build-and-push-docker-images: name: "Build and push docker images" runs-on: ubuntu-latest needs: - - await_artifact_on_maven_central + - await-maven-central-artifact env: SONATYPE_FALLBACK: 1 steps: - uses: actions/checkout@v4 with: - ref: ${{ env.TAG_NAME }} + ref: ${{ inputs.ref }} fetch-depth: 0 # Load entire history as it is required for the push-script - uses: elastic/apm-pipeline-library/.github/actions/docker-login@current with: @@ -199,15 +148,17 @@ jobs: secretId: ${{ secrets.VAULT_SECRET_ID }} - name: "Build docker image" shell: bash - run: | - ./scripts/docker-release/build_docker.sh - ./scripts/docker-release/push_docker.sh + run: ./scripts/docker-release/build_docker.sh + - name: "Push docker image" + if: ${{ ! inputs.dry_run }} + shell: bash + run: ./scripts/docker-release/push_docker.sh - publish_aws_lambda: + publish-aws-lambda: name: "Publish AWS Lambda" runs-on: ubuntu-latest needs: - - await_artifact_on_maven_central + - await-maven-central-artifact outputs: arn_content: ${{ steps.arn_output.outputs.arn_content }} env: @@ -217,15 +168,11 @@ jobs: steps: - uses: actions/checkout@v4 with: - ref: ${{ env.TAG_NAME }} - - name: Set up JDK ${{ env.JAVA_VERSION }} - uses: actions/setup-java@v4 - with: - java-version: ${{ env.JAVA_VERSION }} - distribution: ${{ env.JAVA_DIST }} - cache: 'maven' + ref: ${{ inputs.ref }} - name: Build Lambda-layer zip using agent from maven-central - run: ./mvnw dependency:purge-local-repository package -pl apm-agent-lambda-layer + uses: ./.github/workflows/maven-goal + with: + command: ./mvnw dependency:purge-local-repository package -pl apm-agent-lambda-layer - uses: hashicorp/vault-action@v3.0.0 with: url: ${{ secrets.VAULT_ADDR }} @@ -236,69 +183,85 @@ jobs: secret/observability-team/ci/service-account/apm-aws-lambda access_key_id | AWS_ACCESS_KEY_ID ; secret/observability-team/ci/service-account/apm-aws-lambda secret_access_key | AWS_SECRET_ACCESS_KEY - name: Publish + if: ${{ ! inputs.dry_run }} run: | # Convert v1.2.3 to ver-1-2-3 - VERSION=${TAG_NAME/v/ver-} + VERSION=${RELEASE_VERSION/v/ver-} VERSION=${VERSION//./-} ELASTIC_LAYER_NAME="elastic-apm-java-${VERSION}" .ci/publish-aws.sh - uses: actions/upload-artifact@v4 + if: ${{ ! inputs.dry_run }} with: name: arn-file path: .ci/.arn-file.md - name: Add ARN file to output + if: ${{ ! inputs.dry_run }} id: arn_output run: | echo 'arn_content<> $GITHUB_OUTPUT cat .ci/.arn-file.md >> $GITHUB_OUTPUT echo 'ARN_CONTENT_EOF' >> $GITHUB_OUTPUT + post-release: + name: "Bump versions and create PR" + needs: + - await-maven-central-artifact + uses: ./.github/workflows/pre-post-release.yml + permissions: + contents: write + if: inputs.dry_run == false + with: + ref: ${{ inputs.ref }} + version: ${{ inputs.version }} + phase: 'post' + secrets: inherit - create_github_release: + create-github-release: name: "Create GitHub Release" needs: - - publish_aws_lambda - - update_major_branch + - post-release + - publish-aws-lambda + - update-major-branch runs-on: ubuntu-latest + if: ${{ ! inputs.dry_run }} permissions: contents: write steps: - uses: actions/checkout@v4 with: - ref: ${{ env.TAG_NAME }} + ref: ${{ inputs.ref }} - name: Await release-notes published shell: bash timeout-minutes: 120 run: | - until .ci/release/wait_release_notes_published.sh ${{ inputs.version }} + until .ci/release/wait_release_notes_published.sh ${{ env.RELEASE_VERSION }} do echo "Release notes not published yet. Sleeping 30 seconds, retrying afterwards" sleep 30s done - name: Compute major.x branch id: get_dotx_branch - run: echo "dotx_branch=$(echo '${{ inputs.version }}' | sed -E 's/\..+/.x/')" >> $GITHUB_OUTPUT + run: echo "dotx_branch=$(echo '${{ env.RELEASE_VERSION }}' | sed -E 's/\..+/.x/')" >> $GITHUB_OUTPUT - name: Create GitHub Release env: GH_TOKEN: ${{ github.token }} run: | - gh release create ${{ env.TAG_NAME }} \ - --title="Release ${{ inputs.version }}" \ - --notes="[Release Notes for ${{ inputs.version }}](https://www.elastic.co/guide/en/apm/agent/java/current/release-notes-${{ steps.get_dotx_branch.outputs.dotx_branch }}.html#release-notes-${{ inputs.version }}) - ${{ needs.publish_aws_lambda.outputs.arn_content }}" - + gh release create ${{ env.RELEASE_VERSION }} \ + --title="Release ${{ env.RELEASE_VERSION }}" \ + --notes="[Release Notes for ${{ env.RELEASE_VERSION }}](https://www.elastic.co/guide/en/apm/agent/java/current/release-notes-${{ steps.get_dotx_branch.outputs.dotx_branch }}.html#release-notes-${{ env.RELEASE_VERSION }}) + ${{ needs.publish-aws-lambda.outputs.arn_content }}" notify: - if: always() + if: ${{ always() && ! inputs.dry_run }} needs: - - prepare_release - - maven_central_deploy - - await_artifact_on_maven_central - - update_major_branch - - update_cloudfoundry - - build_and_push_docker_images - - publish_aws_lambda - - create_github_release + - maven-central-deploy + - await-maven-central-artifact + - update-major-branch + - build-and-push-docker-images + - publish-aws-lambda + - post-release + - create-github-release runs-on: ubuntu-latest steps: - id: check diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index 355e919c84..9a50021824 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -12,11 +12,33 @@ on: default: false type: boolean +permissions: + contents: read + jobs: + validate: + runs-on: ubuntu-latest + outputs: + is-snapshot: ${{ steps.validate-step.outputs.is-snapshot }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Validate version is a snapshot version + id: validate-step + run: | + output=false + if [[ "$(./mvnw -q help:evaluate -Dexpression=project.version -DforceStdout)" =~ "-SNAPSHOT" ]]; then + echo "This is a snapshot version" + output=true + fi + echo "is-snapshot=${output}" >> "$GITHUB_OUTPUT" + deploy: name: Deploy runs-on: ubuntu-latest - + needs: + - validate + if: ${{ contains(needs.validate.outputs.is-snapshot, 'true') }} steps: - id: buildkite name: Run Deploy diff --git a/.github/workflows/test-reporter.yml b/.github/workflows/test-reporter.yml index 57c29a50e1..dae96d5e09 100644 --- a/.github/workflows/test-reporter.yml +++ b/.github/workflows/test-reporter.yml @@ -8,6 +8,11 @@ on: types: - completed +permissions: + contents: read + actions: read + checks: write + jobs: report: runs-on: ubuntu-latest diff --git a/.github/workflows/validate-tag/action.yml b/.github/workflows/validate-tag/action.yml new file mode 100644 index 0000000000..1cdb8ef5c3 --- /dev/null +++ b/.github/workflows/validate-tag/action.yml @@ -0,0 +1,25 @@ +--- + +name: validate-tag +description: Validate tag format + +inputs: + tag: + description: 'Tag to validate' + required: true + +runs: + using: "composite" + steps: + - name: Validate tag does not exist on current commit + id: validate-tag + shell: 'bash' + run: | + if ! [ $(echo "${{ inputs.tag }}" | grep -P "(\d{1,2})\.(\d{1,2})\.(\d{1,2})") ]; then + echo "Tag should be a SemVer format" + exit 1 + fi + if [ $(git tag -l "${{ inputs.tag }}") ]; then + echo "The tag ${{ inputs.tag }} already exists" + exit 1 + fi diff --git a/.java-version b/.java-version new file mode 100644 index 0000000000..8e2afd3427 --- /dev/null +++ b/.java-version @@ -0,0 +1 @@ +17 \ No newline at end of file diff --git a/.mvn/maven.config b/.mvn/maven.config index f50bb0f948..7c3456d7e4 100644 --- a/.mvn/maven.config +++ b/.mvn/maven.config @@ -1,4 +1,3 @@ --V -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -Dhttps.protocols=TLSv1.2 diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index a63d81080c..44b9c2f8e5 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -34,12 +34,26 @@ Use subheadings with the "=====" level for adding notes for unreleased changes: [[release-notes-1.x]] === Java Agent version 1.x +[[release-notes-1.49.0]] +==== 1.49.0 - 2024/04/02 + +[float] +===== Bug fixes +* Fixed problems with public API annotation inheritance - {pull}3551[#3551] + +[float] +===== Features +* Differentiate Lambda URLs from API Gateway in AWS Lambda integration - {pull}3417[#3417] +* Added lambda support for ELB triggers {pull}#3411[#3411] +* Add exclusion list option for calling DatabaseMetaData.getUserName - {pull}#3568[#3568] + [[release-notes-1.48.1]] ==== 1.48.1 - 2024/03/06 [float] ===== Bug fixes * Avoid another case where we might touch application exceptions for `safe_exceptions` - {pull}3553[#3553] +* More robust hostname detection on Windows - {pull}3556[#3556] [[release-notes-1.48.0]] ==== 1.48.0 - 2024/03/05 @@ -118,7 +132,7 @@ affect you, if you are using the OpenTelemetry API only and not the SDK. - {pull ===== Features * Added protection against invalid timestamps provided by manual instrumentation - {pull}3363[#3363] * Added support for AWS SDK 2.21 - {pull}3373[#3373] -* Capture bucket and object key to Lambda transaction as OTel attributes - `aws.s3.bueckt`, `aws.s3.key` - {pull}3364[#3364] +* Capture bucket and object key to Lambda transaction as OTel attributes - `aws.s3.bucket`, `aws.s3.key` - {pull}3364[#3364] * Added `context_propagation_only` configuration option - {pull}3358[#3358] * Added attribute[*] for JMX pattern metrics (all metrics can now be generated with `object_name[*:type=*,name=*] attribute[*]`) - {pull}3376[#3376] diff --git a/apm-agent-api/pom.xml b/apm-agent-api/pom.xml index f86c39bf78..7c967db31a 100644 --- a/apm-agent-api/pom.xml +++ b/apm-agent-api/pom.xml @@ -5,7 +5,7 @@ apm-agent-parent co.elastic.apm - 1.48.1 + 1.49.0 apm-agent-api diff --git a/apm-agent-attach-cli/pom.xml b/apm-agent-attach-cli/pom.xml index 3b4027067c..461dbf4dc2 100644 --- a/apm-agent-attach-cli/pom.xml +++ b/apm-agent-attach-cli/pom.xml @@ -3,7 +3,7 @@ apm-agent-parent co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-attach/pom.xml b/apm-agent-attach/pom.xml index 6ea031e268..32da5d5c25 100644 --- a/apm-agent-attach/pom.xml +++ b/apm-agent-attach/pom.xml @@ -5,7 +5,7 @@ apm-agent-parent co.elastic.apm - 1.48.1 + 1.49.0 apm-agent-attach diff --git a/apm-agent-benchmarks/pom.xml b/apm-agent-benchmarks/pom.xml index 53d671c7f9..142bf7c9fb 100644 --- a/apm-agent-benchmarks/pom.xml +++ b/apm-agent-benchmarks/pom.xml @@ -5,7 +5,7 @@ apm-agent-parent co.elastic.apm - 1.48.1 + 1.49.0 apm-agent-benchmarks diff --git a/apm-agent-bootstrap/pom.xml b/apm-agent-bootstrap/pom.xml index 7d213ae3b8..bc2d76aa63 100644 --- a/apm-agent-bootstrap/pom.xml +++ b/apm-agent-bootstrap/pom.xml @@ -5,7 +5,7 @@ apm-agent-parent co.elastic.apm - 1.48.1 + 1.49.0 apm-agent-bootstrap diff --git a/apm-agent-builds/apm-agent-java8/pom.xml b/apm-agent-builds/apm-agent-java8/pom.xml index bca962e66a..47dccec352 100644 --- a/apm-agent-builds/apm-agent-java8/pom.xml +++ b/apm-agent-builds/apm-agent-java8/pom.xml @@ -5,7 +5,7 @@ co.elastic.apm apm-agent-builds - 1.48.1 + 1.49.0 apm-agent-java8 diff --git a/apm-agent-builds/apm-agent/pom.xml b/apm-agent-builds/apm-agent/pom.xml index 2c44c9feb7..f04515c0a2 100644 --- a/apm-agent-builds/apm-agent/pom.xml +++ b/apm-agent-builds/apm-agent/pom.xml @@ -5,7 +5,7 @@ co.elastic.apm apm-agent-builds - 1.48.1 + 1.49.0 apm-agent diff --git a/apm-agent-builds/pom.xml b/apm-agent-builds/pom.xml index f02d688dc2..bda0b824cd 100644 --- a/apm-agent-builds/pom.xml +++ b/apm-agent-builds/pom.xml @@ -3,7 +3,7 @@ apm-agent-parent co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-cached-lookup-key/pom.xml b/apm-agent-cached-lookup-key/pom.xml index d5bc35061a..3f910cf4f6 100644 --- a/apm-agent-cached-lookup-key/pom.xml +++ b/apm-agent-cached-lookup-key/pom.xml @@ -3,7 +3,7 @@ apm-agent-parent co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-common/pom.xml b/apm-agent-common/pom.xml index 1b7611f1aa..6842b66afc 100644 --- a/apm-agent-common/pom.xml +++ b/apm-agent-common/pom.xml @@ -3,7 +3,7 @@ apm-agent-parent co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-core/pom.xml b/apm-agent-core/pom.xml index afd5e43512..61dec83244 100644 --- a/apm-agent-core/pom.xml +++ b/apm-agent-core/pom.xml @@ -5,7 +5,7 @@ apm-agent-parent co.elastic.apm - 1.48.1 + 1.49.0 apm-agent-core @@ -149,11 +149,6 @@ ${version.jetty-server} test - - com.dslplatform - dsl-json - 1.9.3 - commons-math diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/bci/InstrumentationStatsLifecycleListener.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/bci/InstrumentationStatsLifecycleListener.java index a7f096ad59..c16d18c80d 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/bci/InstrumentationStatsLifecycleListener.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/bci/InstrumentationStatsLifecycleListener.java @@ -19,10 +19,10 @@ package co.elastic.apm.agent.bci; import co.elastic.apm.agent.bci.bytebuddy.MatcherTimer; -import co.elastic.apm.agent.context.AbstractLifecycleListener; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.tracer.AbstractLifecycleListener; import co.elastic.apm.agent.sdk.logging.Logger; import co.elastic.apm.agent.sdk.logging.LoggerFactory; +import co.elastic.apm.agent.tracer.Tracer; import java.util.ArrayList; import java.util.Collections; @@ -31,7 +31,7 @@ public class InstrumentationStatsLifecycleListener extends AbstractLifecycleList private static final Logger logger = LoggerFactory.getLogger(InstrumentationStatsLifecycleListener.class); @Override - public void init(ElasticApmTracer tracer) { + public void init(Tracer tracer) { InstrumentationStats instrumentationStats = ElasticApmAgent.getInstrumentationStats(); instrumentationStats.reset(); instrumentationStats.setMeasureMatching(logger.isDebugEnabled()); diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/collections/WeakMapCleaner.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/collections/WeakMapCleaner.java index 3755d8b26b..be6ea5fd98 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/collections/WeakMapCleaner.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/collections/WeakMapCleaner.java @@ -18,8 +18,8 @@ */ package co.elastic.apm.agent.collections; -import co.elastic.apm.agent.context.AbstractLifecycleListener; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.tracer.AbstractLifecycleListener; +import co.elastic.apm.agent.tracer.Tracer; import co.elastic.apm.agent.util.ExecutorUtils; import co.elastic.apm.agent.sdk.logging.Logger; import co.elastic.apm.agent.sdk.logging.LoggerFactory; @@ -41,7 +41,7 @@ public WeakMapCleaner() { } @Override - public void start(ElasticApmTracer tracer) { + public void start(Tracer tracer) { scheduler.scheduleWithFixedDelay(this, 1, 1, TimeUnit.SECONDS); } diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/configuration/ApmServerConfigurationSource.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/configuration/ApmServerConfigurationSource.java index 662810e4b7..0f63ac2d0c 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/configuration/ApmServerConfigurationSource.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/configuration/ApmServerConfigurationSource.java @@ -18,12 +18,13 @@ */ package co.elastic.apm.agent.configuration; -import co.elastic.apm.agent.context.LifecycleListener; +import co.elastic.apm.agent.tracer.LifecycleListener; import co.elastic.apm.agent.impl.ElasticApmTracer; import co.elastic.apm.agent.report.ApmServerClient; import co.elastic.apm.agent.report.serialize.DslJsonSerializer; import co.elastic.apm.agent.sdk.logging.Logger; import co.elastic.apm.agent.sdk.logging.LoggerFactory; +import co.elastic.apm.agent.tracer.Tracer; import co.elastic.apm.agent.util.ExecutorUtils; import com.dslplatform.json.DslJson; import com.dslplatform.json.JsonReader; @@ -111,17 +112,17 @@ public void reload() { } @Override - public void init(ElasticApmTracer tracer) throws Exception { + public void init(Tracer tracer) throws Exception { // noop } @Override - public void start(final ElasticApmTracer tracer) { + public void start(final Tracer tracer) { threadPool = ExecutorUtils.createSingleThreadDaemonPool("remote-config-poller", 1); threadPool.execute(new Runnable() { @Override public void run() { - pollConfig(tracer.getConfigurationRegistry()); + pollConfig(tracer.require(ElasticApmTracer.class).getConfigurationRegistry()); } }); } diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/configuration/StartupInfo.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/configuration/StartupInfo.java index f75d4807ab..4de8761af2 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/configuration/StartupInfo.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/configuration/StartupInfo.java @@ -18,8 +18,9 @@ */ package co.elastic.apm.agent.configuration; +import co.elastic.apm.agent.tracer.Tracer; import co.elastic.apm.agent.tracer.configuration.TimeDuration; -import co.elastic.apm.agent.context.AbstractLifecycleListener; +import co.elastic.apm.agent.tracer.AbstractLifecycleListener; import co.elastic.apm.agent.impl.ElasticApmTracer; import co.elastic.apm.agent.impl.stacktrace.StacktraceConfiguration; import co.elastic.apm.agent.util.VersionUtils; @@ -56,8 +57,8 @@ private static String getJvmAndOsVersionString() { } @Override - public void init(ElasticApmTracer tracer) { - ConfigurationRegistry configurationRegistry = tracer.getConfigurationRegistry(); + public void init(Tracer tracer) { + ConfigurationRegistry configurationRegistry = tracer.require(ElasticApmTracer.class).getConfigurationRegistry(); logConfiguration(configurationRegistry, logger); } diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/context/ClosableLifecycleListenerAdapter.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/context/ClosableLifecycleListenerAdapter.java index 10ba08a7ed..d784743219 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/context/ClosableLifecycleListenerAdapter.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/context/ClosableLifecycleListenerAdapter.java @@ -18,17 +18,18 @@ */ package co.elastic.apm.agent.context; -import java.io.Closeable; +import co.elastic.apm.agent.tracer.AbstractLifecycleListener; +import co.elastic.apm.agent.tracer.LifecycleListener; public class ClosableLifecycleListenerAdapter extends AbstractLifecycleListener { - private final Closeable closeable; + private final AutoCloseable closeable; - public static LifecycleListener of(Closeable closeable) { + public static LifecycleListener of(AutoCloseable closeable) { return new ClosableLifecycleListenerAdapter(closeable); } - private ClosableLifecycleListenerAdapter(Closeable closeable) { + private ClosableLifecycleListenerAdapter(AutoCloseable closeable) { this.closeable = closeable; } diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/ElasticApmTracer.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/ElasticApmTracer.java index 6980d1812e..711601c319 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/ElasticApmTracer.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/ElasticApmTracer.java @@ -18,7 +18,9 @@ */ package co.elastic.apm.agent.impl; +import co.elastic.apm.agent.bci.ElasticApmAgent; import co.elastic.apm.agent.bci.IndyBootstrap; +import co.elastic.apm.agent.bci.InstrumentationStats; import co.elastic.apm.agent.collections.WeakReferenceCountedMap; import co.elastic.apm.agent.common.JvmRuntimeInfo; import co.elastic.apm.agent.common.util.WildcardMatcher; @@ -27,16 +29,22 @@ import co.elastic.apm.agent.configuration.MetricsConfiguration; import co.elastic.apm.agent.configuration.ServerlessConfiguration; import co.elastic.apm.agent.impl.error.RedactedException; +import co.elastic.apm.agent.impl.metadata.FaaSMetaDataExtension; +import co.elastic.apm.agent.impl.metadata.Framework; +import co.elastic.apm.agent.impl.metadata.MetaDataFuture; +import co.elastic.apm.agent.impl.metadata.NameAndIdField; import co.elastic.apm.agent.impl.metadata.ServiceFactory; +import co.elastic.apm.agent.sdk.internal.util.LoggerUtils; +import co.elastic.apm.agent.tracer.metrics.DoubleSupplier; +import co.elastic.apm.agent.tracer.metrics.Labels; import co.elastic.apm.agent.tracer.service.Service; import co.elastic.apm.agent.tracer.service.ServiceInfo; import co.elastic.apm.agent.configuration.SpanConfiguration; import co.elastic.apm.agent.context.ClosableLifecycleListenerAdapter; -import co.elastic.apm.agent.context.LifecycleListener; +import co.elastic.apm.agent.tracer.LifecycleListener; import co.elastic.apm.agent.impl.baggage.Baggage; import co.elastic.apm.agent.impl.baggage.W3CBaggagePropagation; import co.elastic.apm.agent.impl.error.ErrorCapture; -import co.elastic.apm.agent.impl.metadata.MetaDataFuture; import co.elastic.apm.agent.impl.sampling.ProbabilitySampler; import co.elastic.apm.agent.impl.sampling.Sampler; import co.elastic.apm.agent.impl.stacktrace.StacktraceConfiguration; @@ -65,12 +73,12 @@ import co.elastic.apm.agent.tracer.reference.ReferenceCountedMap; import co.elastic.apm.agent.util.DependencyInjectingServiceLoader; import co.elastic.apm.agent.util.ExecutorUtils; +import com.dslplatform.json.JsonWriter; import org.stagemonitor.configuration.ConfigurationOption; import org.stagemonitor.configuration.ConfigurationOptionProvider; import org.stagemonitor.configuration.ConfigurationRegistry; import javax.annotation.Nullable; -import java.io.Closeable; import java.io.File; import java.util.ArrayList; import java.util.Collections; @@ -83,6 +91,7 @@ import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; /** @@ -93,6 +102,7 @@ */ public class ElasticApmTracer implements Tracer { private static final Logger logger = LoggerFactory.getLogger(ElasticApmTracer.class); + private static final Logger enabledInstrumentationsLogger = LoggerUtils.logOnce(logger); private static final WeakMap serviceInfoByClassLoader = WeakConcurrent.buildMap(); @@ -946,7 +956,8 @@ public ScheduledThreadPoolExecutor getSharedSingleThreadedPool() { return sharedPool; } - public void addShutdownHook(Closeable closeable) { + @Override + public void addShutdownHook(AutoCloseable closeable) { lifecycleListeners.add(ClosableLifecycleListenerAdapter.of(closeable)); } @@ -1007,4 +1018,59 @@ public Throwable redactExceptionIfRequired(@Nullable Throwable original) { } return original; } + + @Override + public void flush() { + long flushTimeout = configurationRegistry.getConfig(ServerlessConfiguration.class).getDataFlushTimeout(); + try { + if (!reporter.flush(flushTimeout, TimeUnit.MILLISECONDS, true)) { + logger.error("APM data flush haven't completed within {} milliseconds.", flushTimeout); + } + } catch (Exception e) { + logger.error("An error occurred on flushing APM data.", e); + } + logEnabledInstrumentations(); + } + + private void logEnabledInstrumentations() { + if (enabledInstrumentationsLogger.isInfoEnabled()) { + InstrumentationStats instrumentationStats = ElasticApmAgent.getInstrumentationStats(); + enabledInstrumentationsLogger.info("Used instrumentation groups: {}", instrumentationStats.getUsedInstrumentationGroups()); + } + } + + @Override + public void completeMetaData(String name, String version, String id, String region) { + metaDataFuture.getFaaSMetaDataExtensionFuture().complete(new FaaSMetaDataExtension( + new Framework(name, version), + new NameAndIdField(null, id), + region + )); + } + + @Override + public void removeGauge(String name, Labels.Immutable labels) { + metricRegistry.removeGauge(name, labels); + } + + @Override + public void addGauge(String name, Labels.Immutable labels, DoubleSupplier supplier) { + metricRegistry.add(name, labels, supplier); + } + + @Override + public void submit(Runnable job) { + sharedPool.submit(job); + } + + @Override + public void schedule(Runnable job, long interval, TimeUnit timeUnit) { + sharedPool.scheduleAtFixedRate(job, 0, interval, timeUnit); + } + + @Override + public void reportMetric(JsonWriter metrics) { + reporter.reportMetrics(metrics); + } + } diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/ElasticApmTracerBuilder.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/ElasticApmTracerBuilder.java index 86c93a3353..b68faae5dd 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/ElasticApmTracerBuilder.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/ElasticApmTracerBuilder.java @@ -26,7 +26,7 @@ import co.elastic.apm.agent.configuration.source.ConfigSources; import co.elastic.apm.agent.configuration.source.SystemPropertyConfigurationSource; import co.elastic.apm.agent.context.ClosableLifecycleListenerAdapter; -import co.elastic.apm.agent.context.LifecycleListener; +import co.elastic.apm.agent.tracer.LifecycleListener; import co.elastic.apm.agent.impl.metadata.MetaData; import co.elastic.apm.agent.impl.metadata.MetaDataFuture; import co.elastic.apm.agent.impl.stacktrace.StacktraceConfiguration; diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/circuitbreaker/CircuitBreaker.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/circuitbreaker/CircuitBreaker.java index f17e20876c..b90c539011 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/circuitbreaker/CircuitBreaker.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/circuitbreaker/CircuitBreaker.java @@ -18,8 +18,9 @@ */ package co.elastic.apm.agent.impl.circuitbreaker; -import co.elastic.apm.agent.context.AbstractLifecycleListener; +import co.elastic.apm.agent.tracer.AbstractLifecycleListener; import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.tracer.Tracer; import co.elastic.apm.agent.util.ExecutorUtils; import co.elastic.apm.agent.sdk.logging.Logger; import co.elastic.apm.agent.sdk.logging.LoggerFactory; @@ -50,7 +51,7 @@ public CircuitBreaker(ElasticApmTracer tracer) { } @Override - public void start(ElasticApmTracer tracer) { + public void start(Tracer tracer) { // failsafe loading of stress monitors in isolation loadGCStressMonitor(tracer); loadSystemCpuStressMonitor(tracer); @@ -63,7 +64,7 @@ public void run() { }); } - private void loadGCStressMonitor(ElasticApmTracer tracer) { + private void loadGCStressMonitor(Tracer tracer) { try { stressMonitors.add(new GCStressMonitor(tracer)); } catch (Throwable throwable) { @@ -71,7 +72,7 @@ private void loadGCStressMonitor(ElasticApmTracer tracer) { } } - private void loadSystemCpuStressMonitor(ElasticApmTracer tracer) { + private void loadSystemCpuStressMonitor(Tracer tracer) { try { stressMonitors.add(new SystemCpuStressMonitor(tracer)); } catch (Throwable throwable) { diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/circuitbreaker/GCStressMonitor.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/circuitbreaker/GCStressMonitor.java index 62405dadd6..a325e2632b 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/circuitbreaker/GCStressMonitor.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/circuitbreaker/GCStressMonitor.java @@ -21,6 +21,7 @@ import co.elastic.apm.agent.impl.ElasticApmTracer; import co.elastic.apm.agent.sdk.logging.Logger; import co.elastic.apm.agent.sdk.logging.LoggerFactory; +import co.elastic.apm.agent.tracer.Tracer; import java.lang.management.ManagementFactory; import java.lang.management.MemoryPoolMXBean; @@ -35,7 +36,7 @@ class GCStressMonitor extends StressMonitor { private final List heapMBeans = new ArrayList<>(); private final StringBuilder latestStressDetectionInfo = new StringBuilder("No stress has been detected so far."); - GCStressMonitor(ElasticApmTracer tracer) { + GCStressMonitor(Tracer tracer) { super(tracer); discoverMBeans(); } diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/circuitbreaker/StressMonitor.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/circuitbreaker/StressMonitor.java index 992bb89344..a6db804364 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/circuitbreaker/StressMonitor.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/circuitbreaker/StressMonitor.java @@ -18,13 +18,13 @@ */ package co.elastic.apm.agent.impl.circuitbreaker; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.tracer.Tracer; abstract class StressMonitor { protected final CircuitBreakerConfiguration circuitBreakerConfiguration; - public StressMonitor(ElasticApmTracer tracer) { + public StressMonitor(Tracer tracer) { circuitBreakerConfiguration = tracer.getConfig(CircuitBreakerConfiguration.class); } diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/circuitbreaker/SystemCpuStressMonitor.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/circuitbreaker/SystemCpuStressMonitor.java index cb0b6536aa..fd0d5e8fe6 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/circuitbreaker/SystemCpuStressMonitor.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/circuitbreaker/SystemCpuStressMonitor.java @@ -18,7 +18,7 @@ */ package co.elastic.apm.agent.impl.circuitbreaker; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.tracer.Tracer; import co.elastic.apm.agent.util.JmxUtils; import co.elastic.apm.agent.sdk.logging.Logger; import co.elastic.apm.agent.sdk.logging.LoggerFactory; @@ -45,7 +45,7 @@ public class SystemCpuStressMonitor extends StressMonitor { @Nullable private final Method systemCpuUsageMethod; - SystemCpuStressMonitor(ElasticApmTracer tracer) { + SystemCpuStressMonitor(Tracer tracer) { super(tracer); operatingSystemBean = ManagementFactory.getOperatingSystemMXBean(); systemCpuUsageMethod = JmxUtils.getOperatingSystemMBeanMethod(operatingSystemBean, "getSystemCpuLoad"); diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Request.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Request.java index 028882f4e6..a6d2694b4e 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Request.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Request.java @@ -175,13 +175,7 @@ public PotentiallyMultiValuedMap getFormUrlEncodedParameters() { return postParams; } - /** - * Adds a request header. - * - * @param headerName The name of the header. - * @param headerValue The value of the header. - * @return {@code this}, for fluent method chaining - */ + @Override public Request addHeader(String headerName, @Nullable String headerValue) { if (headerValue != null) { headers.add(headerName, headerValue); diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Response.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Response.java index 811f89293a..4a6ef90b99 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Response.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Response.java @@ -60,8 +60,11 @@ public Response withFinished(boolean finished) { * @param headerValue The value of the header. * @return {@code this}, for fluent method chaining */ - public Response addHeader(String headerName, String headerValue) { - headers.add(headerName, headerValue); + @Override + public Response addHeader(String headerName, @Nullable String headerValue) { + if (headerValue != null) { + headers.add(headerName, headerValue); + } return this; } diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/ServiceOrigin.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/ServiceOrigin.java index 9927f7b66e..5cdf69b407 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/ServiceOrigin.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/ServiceOrigin.java @@ -28,7 +28,7 @@ * If a request originated from another service, * the service origin interface can be used to collect information about the origin service. */ -public class ServiceOrigin implements Recyclable { +public class ServiceOrigin implements co.elastic.apm.agent.tracer.ServiceOrigin, Recyclable { @Nullable private String id; @@ -43,6 +43,7 @@ public String getId() { return id; } + @Override public ServiceOrigin withId(@Nullable String id) { this.id = id; return this; @@ -52,6 +53,7 @@ public StringBuilder getName() { return name; } + @Override public ServiceOrigin withName(@Nullable CharSequence name) { this.name.setLength(0); if (name != null) { @@ -72,6 +74,7 @@ public String getVersion() { return version; } + @Override public ServiceOrigin withVersion(@Nullable String version) { this.version = version; return this; diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/TransactionContext.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/TransactionContext.java index c4c9ea756b..05df0e1015 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/TransactionContext.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/TransactionContext.java @@ -118,6 +118,7 @@ public CloudOrigin getCloudOrigin() { return cloudOrigin; } + @Override public ServiceOrigin getServiceOrigin() { return serviceOrigin; } diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/metadata/SystemInfo.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/metadata/SystemInfo.java index baf8820d1b..68624213ef 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/metadata/SystemInfo.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/metadata/SystemInfo.java @@ -188,7 +188,10 @@ static String fallbackHostnameDiscovery(boolean isWindows) { static String discoverHostnameThroughCommand(boolean isWindows, long timeoutMillis) { String hostname; if (isWindows) { - hostname = executeHostnameDiscoveryCommand(Arrays.asList("powershell.exe", "[System.Net.Dns]::GetHostEntry($env:computerName).HostName"), timeoutMillis); + List powershellCmd = Arrays.asList("powershell.exe", + "-NoLogo", "-NonInteractive", "-NoProfile", "-ExecutionPolicy", "Bypass", + "-Command", "[System.Net.Dns]::GetHostEntry($env:computerName).HostName"); + hostname = executeHostnameDiscoveryCommand(powershellCmd, timeoutMillis); if (hostname == null || hostname.isEmpty()) { hostname = executeHostnameDiscoveryCommand(Arrays.asList("cmd.exe", "/c", "hostname"), timeoutMillis); } diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Faas.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Faas.java index 9d7e73b5f8..1299184003 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Faas.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Faas.java @@ -22,7 +22,7 @@ import javax.annotation.Nullable; -public class Faas implements Recyclable { +public class Faas implements co.elastic.apm.agent.tracer.Faas, Recyclable { @Nullable private String execution; @@ -68,26 +68,31 @@ public String getVersion() { return version; } + @Override public Faas withExecution(@Nullable String execution) { this.execution = execution; return this; } + @Override public Faas withColdStart(boolean coldStart) { this.coldStart = coldStart; return this; } + @Override public Faas withId(@Nullable String id) { this.id = id; return this; } + @Override public Faas withName(@Nullable String name) { this.name = name; return this; } + @Override public Faas withVersion(@Nullable String version) { this.version = version; return this; diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/FaasTrigger.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/FaasTrigger.java index 6d80601634..d3d3fb3775 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/FaasTrigger.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/FaasTrigger.java @@ -22,7 +22,7 @@ import javax.annotation.Nullable; -public class FaasTrigger implements Recyclable { +public class FaasTrigger implements co.elastic.apm.agent.tracer.FaasTrigger, Recyclable { @Nullable private String type; @@ -40,11 +40,13 @@ public String getRequestId() { return requestId; } + @Override public FaasTrigger withType(@Nullable String type) { this.type = type; return this; } + @Override public FaasTrigger withRequestId(@Nullable String requestId) { this.requestId = requestId; return this; diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Transaction.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Transaction.java index aab38dddd2..ff3ca395c7 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Transaction.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Transaction.java @@ -27,7 +27,7 @@ import co.elastic.apm.agent.impl.context.Response; import co.elastic.apm.agent.impl.context.TransactionContext; import co.elastic.apm.agent.impl.sampling.Sampler; -import co.elastic.apm.agent.metrics.Labels; +import co.elastic.apm.agent.tracer.metrics.Labels; import co.elastic.apm.agent.metrics.MetricRegistry; import co.elastic.apm.agent.metrics.Timer; import co.elastic.apm.agent.tracer.Outcome; diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/logging/ApmServerLogAppender.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/logging/ApmServerLogAppender.java index 59328be609..97074fe210 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/logging/ApmServerLogAppender.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/logging/ApmServerLogAppender.java @@ -18,10 +18,11 @@ */ package co.elastic.apm.agent.logging; -import co.elastic.apm.agent.context.AbstractLifecycleListener; -import co.elastic.apm.agent.context.LifecycleListener; +import co.elastic.apm.agent.tracer.AbstractLifecycleListener; +import co.elastic.apm.agent.tracer.LifecycleListener; import co.elastic.apm.agent.impl.ElasticApmTracer; import co.elastic.apm.agent.report.Reporter; +import co.elastic.apm.agent.tracer.Tracer; import co.elastic.logging.log4j2.EcsLayout; import org.apache.logging.log4j.core.Appender; import org.apache.logging.log4j.core.Core; @@ -103,8 +104,8 @@ public void append(LogEvent event) { public LifecycleListener getInitListener() { return new AbstractLifecycleListener() { @Override - public void init(ElasticApmTracer tracer) throws Exception { - initStreaming(tracer.getConfig(LoggingConfiguration.class), tracer.getReporter()); + public void init(Tracer tracer) throws Exception { + initStreaming(tracer.getConfig(LoggingConfiguration.class), tracer.require(ElasticApmTracer.class).getReporter()); } }; } diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/MetricCollector.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/MetricCollector.java index b8ccd561f4..199899b787 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/MetricCollector.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/MetricCollector.java @@ -18,6 +18,8 @@ */ package co.elastic.apm.agent.metrics; +import co.elastic.apm.agent.tracer.metrics.Labels; + public interface MetricCollector { void addMetricValue(String metric, Labels labels, double value); diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/MetricRegistry.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/MetricRegistry.java index 2df93faa7f..9c1cdeb285 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/MetricRegistry.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/MetricRegistry.java @@ -23,6 +23,8 @@ import co.elastic.apm.agent.report.ReporterConfiguration; import co.elastic.apm.agent.sdk.logging.Logger; import co.elastic.apm.agent.sdk.logging.LoggerFactory; +import co.elastic.apm.agent.tracer.metrics.DoubleSupplier; +import co.elastic.apm.agent.tracer.metrics.Labels; import org.HdrHistogram.WriterReaderPhaser; import javax.annotation.Nonnull; diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/MetricSet.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/MetricSet.java index 474a3827be..8bb1bc6f85 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/MetricSet.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/MetricSet.java @@ -18,6 +18,8 @@ */ package co.elastic.apm.agent.metrics; +import co.elastic.apm.agent.tracer.metrics.DoubleSupplier; +import co.elastic.apm.agent.tracer.metrics.Labels; import co.elastic.apm.agent.tracer.pooling.Recyclable; import javax.annotation.Nullable; diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/builtin/AgentOverheadMetrics.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/builtin/AgentOverheadMetrics.java index c0a06ab921..3413f95f8a 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/builtin/AgentOverheadMetrics.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/builtin/AgentOverheadMetrics.java @@ -19,9 +19,10 @@ package co.elastic.apm.agent.metrics.builtin; import co.elastic.apm.agent.configuration.MetricsConfiguration; -import co.elastic.apm.agent.context.AbstractLifecycleListener; +import co.elastic.apm.agent.tracer.AbstractLifecycleListener; import co.elastic.apm.agent.impl.ElasticApmTracer; -import co.elastic.apm.agent.metrics.Labels; +import co.elastic.apm.agent.tracer.Tracer; +import co.elastic.apm.agent.tracer.metrics.Labels; import co.elastic.apm.agent.metrics.MetricCollector; import co.elastic.apm.agent.metrics.MetricRegistry; import co.elastic.apm.agent.metrics.MetricsProvider; @@ -113,8 +114,8 @@ public AgentOverheadMetrics() { } @Override - public void start(ElasticApmTracer tracer) throws Exception { - MetricRegistry metricRegistry = tracer.getMetricRegistry(); + public void start(Tracer tracer) throws Exception { + MetricRegistry metricRegistry = tracer.require(ElasticApmTracer.class).getMetricRegistry(); MetricsConfiguration config = tracer.getConfig(MetricsConfiguration.class); bindTo(metricRegistry, config); } diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/builtin/AgentReporterMetrics.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/builtin/AgentReporterMetrics.java index 6970d114ae..e946bb90e1 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/builtin/AgentReporterMetrics.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/builtin/AgentReporterMetrics.java @@ -19,7 +19,7 @@ package co.elastic.apm.agent.metrics.builtin; import co.elastic.apm.agent.configuration.MetricsConfiguration; -import co.elastic.apm.agent.metrics.Labels; +import co.elastic.apm.agent.tracer.metrics.Labels; import co.elastic.apm.agent.metrics.MetricCollector; import co.elastic.apm.agent.metrics.MetricRegistry; import co.elastic.apm.agent.metrics.MetricsProvider; diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/builtin/CGroupMetrics.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/builtin/CGroupMetrics.java index 9f64ed14cc..e89ee39ef5 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/builtin/CGroupMetrics.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/builtin/CGroupMetrics.java @@ -18,10 +18,11 @@ */ package co.elastic.apm.agent.metrics.builtin; -import co.elastic.apm.agent.context.AbstractLifecycleListener; +import co.elastic.apm.agent.tracer.AbstractLifecycleListener; import co.elastic.apm.agent.impl.ElasticApmTracer; -import co.elastic.apm.agent.metrics.DoubleSupplier; -import co.elastic.apm.agent.metrics.Labels; +import co.elastic.apm.agent.tracer.metrics.DoubleSupplier; +import co.elastic.apm.agent.tracer.Tracer; +import co.elastic.apm.agent.tracer.metrics.Labels; import co.elastic.apm.agent.metrics.MetricRegistry; import co.elastic.apm.agent.sdk.logging.Logger; import co.elastic.apm.agent.sdk.logging.LoggerFactory; @@ -213,8 +214,8 @@ private File getMaxMemoryFile(File maxMemoryFile, String cgroupUnlimitedConstant } @Override - public void start(ElasticApmTracer tracer) { - bindTo(tracer.getMetricRegistry()); + public void start(Tracer tracer) { + bindTo(tracer.require(ElasticApmTracer.class).getMetricRegistry()); } void bindTo(MetricRegistry metricRegistry) { diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/builtin/JvmFdMetrics.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/builtin/JvmFdMetrics.java index 4a0764fe35..08d95586bf 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/builtin/JvmFdMetrics.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/builtin/JvmFdMetrics.java @@ -18,10 +18,11 @@ */ package co.elastic.apm.agent.metrics.builtin; -import co.elastic.apm.agent.context.AbstractLifecycleListener; +import co.elastic.apm.agent.tracer.AbstractLifecycleListener; import co.elastic.apm.agent.impl.ElasticApmTracer; -import co.elastic.apm.agent.metrics.DoubleSupplier; -import co.elastic.apm.agent.metrics.Labels; +import co.elastic.apm.agent.tracer.metrics.DoubleSupplier; +import co.elastic.apm.agent.tracer.Tracer; +import co.elastic.apm.agent.tracer.metrics.Labels; import co.elastic.apm.agent.metrics.MetricRegistry; import javax.annotation.Nullable; @@ -40,8 +41,8 @@ public class JvmFdMetrics extends AbstractLifecycleListener { private static final MethodHandle getMaxFileDescriptorCount = getMethodHandle("getMaxFileDescriptorCount"); @Override - public void start(ElasticApmTracer tracer) { - bindTo(tracer.getMetricRegistry()); + public void start(Tracer tracer) { + bindTo(tracer.require(ElasticApmTracer.class).getMetricRegistry()); } void bindTo(final MetricRegistry registry) { diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/builtin/JvmGcMetrics.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/builtin/JvmGcMetrics.java index 4cd140aced..089c2df2d0 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/builtin/JvmGcMetrics.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/builtin/JvmGcMetrics.java @@ -18,10 +18,11 @@ */ package co.elastic.apm.agent.metrics.builtin; -import co.elastic.apm.agent.context.AbstractLifecycleListener; +import co.elastic.apm.agent.tracer.AbstractLifecycleListener; import co.elastic.apm.agent.impl.ElasticApmTracer; -import co.elastic.apm.agent.metrics.DoubleSupplier; -import co.elastic.apm.agent.metrics.Labels; +import co.elastic.apm.agent.tracer.metrics.DoubleSupplier; +import co.elastic.apm.agent.tracer.Tracer; +import co.elastic.apm.agent.tracer.metrics.Labels; import co.elastic.apm.agent.metrics.MetricRegistry; import com.sun.management.ThreadMXBean; import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement; @@ -35,8 +36,8 @@ public class JvmGcMetrics extends AbstractLifecycleListener { private final List garbageCollectorMXBeans = ManagementFactory.getGarbageCollectorMXBeans(); @Override - public void start(ElasticApmTracer tracer) { - bindTo(tracer.getMetricRegistry()); + public void start(Tracer tracer) { + bindTo(tracer.require(ElasticApmTracer.class).getMetricRegistry()); } void bindTo(final MetricRegistry registry) { diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/builtin/JvmMemoryMetrics.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/builtin/JvmMemoryMetrics.java index b83fbf2eff..272c1e7a31 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/builtin/JvmMemoryMetrics.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/builtin/JvmMemoryMetrics.java @@ -18,10 +18,11 @@ */ package co.elastic.apm.agent.metrics.builtin; -import co.elastic.apm.agent.context.AbstractLifecycleListener; +import co.elastic.apm.agent.tracer.AbstractLifecycleListener; import co.elastic.apm.agent.impl.ElasticApmTracer; -import co.elastic.apm.agent.metrics.DoubleSupplier; -import co.elastic.apm.agent.metrics.Labels; +import co.elastic.apm.agent.tracer.metrics.DoubleSupplier; +import co.elastic.apm.agent.tracer.Tracer; +import co.elastic.apm.agent.tracer.metrics.Labels; import co.elastic.apm.agent.metrics.MetricRegistry; import co.elastic.apm.agent.sdk.logging.Logger; import co.elastic.apm.agent.sdk.logging.LoggerFactory; @@ -36,8 +37,8 @@ public class JvmMemoryMetrics extends AbstractLifecycleListener { private static final Logger logger = LoggerFactory.getLogger(JvmMemoryMetrics.class); @Override - public void start(ElasticApmTracer tracer) { - bindTo(tracer.getMetricRegistry()); + public void start(Tracer tracer) { + bindTo(tracer.require(ElasticApmTracer.class).getMetricRegistry()); } void bindTo(final MetricRegistry registry) { diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/builtin/SystemMetrics.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/builtin/SystemMetrics.java index 3659938a5f..a6e79439d8 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/builtin/SystemMetrics.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/builtin/SystemMetrics.java @@ -18,11 +18,12 @@ */ package co.elastic.apm.agent.metrics.builtin; -import co.elastic.apm.agent.context.AbstractLifecycleListener; +import co.elastic.apm.agent.tracer.AbstractLifecycleListener; import co.elastic.apm.agent.impl.ElasticApmTracer; import co.elastic.apm.agent.common.util.WildcardMatcher; -import co.elastic.apm.agent.metrics.DoubleSupplier; -import co.elastic.apm.agent.metrics.Labels; +import co.elastic.apm.agent.tracer.metrics.DoubleSupplier; +import co.elastic.apm.agent.tracer.Tracer; +import co.elastic.apm.agent.tracer.metrics.Labels; import co.elastic.apm.agent.metrics.MetricRegistry; import co.elastic.apm.agent.util.JmxUtils; import org.stagemonitor.util.StringUtils; @@ -88,8 +89,8 @@ public SystemMetrics() { } @Override - public void start(ElasticApmTracer tracer) { - bindTo(tracer.getMetricRegistry()); + public void start(Tracer tracer) { + bindTo(tracer.require(ElasticApmTracer.class).getMetricRegistry()); } void bindTo(MetricRegistry metricRegistry) { diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/builtin/ThreadMetrics.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/builtin/ThreadMetrics.java index 52c5203555..cf3314c0ea 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/builtin/ThreadMetrics.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/builtin/ThreadMetrics.java @@ -18,10 +18,11 @@ */ package co.elastic.apm.agent.metrics.builtin; -import co.elastic.apm.agent.context.AbstractLifecycleListener; +import co.elastic.apm.agent.tracer.AbstractLifecycleListener; import co.elastic.apm.agent.impl.ElasticApmTracer; -import co.elastic.apm.agent.metrics.DoubleSupplier; -import co.elastic.apm.agent.metrics.Labels; +import co.elastic.apm.agent.tracer.metrics.DoubleSupplier; +import co.elastic.apm.agent.tracer.Tracer; +import co.elastic.apm.agent.tracer.metrics.Labels; import co.elastic.apm.agent.metrics.MetricRegistry; import java.lang.management.ManagementFactory; @@ -30,8 +31,8 @@ public class ThreadMetrics extends AbstractLifecycleListener { @Override - public void start(ElasticApmTracer tracer) { - bindTo(tracer.getMetricRegistry()); + public void start(Tracer tracer) { + bindTo(tracer.require(ElasticApmTracer.class).getMetricRegistry()); } void bindTo(final MetricRegistry registry) { diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/report/serialize/DslJsonSerializer.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/report/serialize/DslJsonSerializer.java index 6ec3676c4b..e56bb1b1e3 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/report/serialize/DslJsonSerializer.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/report/serialize/DslJsonSerializer.java @@ -59,13 +59,14 @@ import co.elastic.apm.agent.impl.transaction.StackFrame; import co.elastic.apm.agent.impl.transaction.TraceContext; import co.elastic.apm.agent.impl.transaction.Transaction; -import co.elastic.apm.agent.metrics.Labels; +import co.elastic.apm.agent.tracer.metrics.Labels; import co.elastic.apm.agent.report.ApmServerClient; import co.elastic.apm.agent.sdk.internal.collections.LongList; import co.elastic.apm.agent.sdk.logging.Logger; import co.elastic.apm.agent.sdk.logging.LoggerFactory; import co.elastic.apm.agent.tracer.metadata.PotentiallyMultiValuedMap; import co.elastic.apm.agent.tracer.pooling.Recyclable; +import co.elastic.apm.agent.tracer.metrics.DslJsonUtil; import com.dslplatform.json.BoolConverter; import com.dslplatform.json.DslJson; import com.dslplatform.json.JsonWriter; @@ -98,7 +99,6 @@ public class DslJsonSerializer { private static final byte NEW_LINE = (byte) '\n'; private static final Logger logger = LoggerFactory.getLogger(DslJsonSerializer.class); - private static final String[] DISALLOWED_IN_PROPERTY_NAME = new String[]{".", "*", "\""}; private static final List excludedStackFramesPrefixes = Arrays.asList("java.lang.reflect.", "com.sun.", "sun.", "jdk.internal."); @@ -165,16 +165,16 @@ static void serializeMetadata(MetaData metaData, private static void serializeGlobalLabels(ArrayList globalLabelKeys, ArrayList globalLabelValues, final StringBuilder replaceBuilder, JsonWriter jw) { if (!globalLabelKeys.isEmpty()) { - writeFieldName("labels", jw); + DslJsonUtil.writeFieldName("labels", jw); jw.writeByte(OBJECT_START); - writeStringValue(sanitizePropertyName(globalLabelKeys.get(0), replaceBuilder), replaceBuilder, jw); + DslJsonUtil.writeStringValue(DslJsonUtil.sanitizePropertyName(globalLabelKeys.get(0), replaceBuilder), replaceBuilder, jw); jw.writeByte(JsonWriter.SEMI); - writeStringValue(globalLabelValues.get(0), replaceBuilder, jw); + DslJsonUtil.writeStringValue(globalLabelValues.get(0), replaceBuilder, jw); for (int i = 1; i < globalLabelKeys.size(); i++) { jw.writeByte(COMMA); - writeStringValue(sanitizePropertyName(globalLabelKeys.get(i), replaceBuilder), replaceBuilder, jw); + DslJsonUtil.writeStringValue(DslJsonUtil.sanitizePropertyName(globalLabelKeys.get(i), replaceBuilder), replaceBuilder, jw); jw.writeByte(JsonWriter.SEMI); - writeStringValue(globalLabelValues.get(i), replaceBuilder, jw); + DslJsonUtil.writeStringValue(globalLabelValues.get(i), replaceBuilder, jw); } jw.writeByte(OBJECT_END); jw.writeByte(COMMA); @@ -182,7 +182,7 @@ private static void serializeGlobalLabels(ArrayList globalLabelKeys, Arr } private static void serializeService(final Service service, final StringBuilder replaceBuilder, final JsonWriter jw, boolean supportsAgentActivationMethod) { - writeFieldName("service", jw); + DslJsonUtil.writeFieldName("service", jw); jw.writeByte(JsonWriter.OBJECT_START); writeField("name", service.getName(), replaceBuilder, jw); @@ -224,17 +224,17 @@ private static void serializeService(@Nullable final CharSequence serviceName, @ return; } - writeFieldName("service", jw); + DslJsonUtil.writeFieldName("service", jw); jw.writeByte(OBJECT_START); if (serviceName != null) { - writeFieldName("name", jw); - writeStringValue(serviceName, replaceBuilder, jw); + DslJsonUtil.writeFieldName("name", jw); + DslJsonUtil.writeStringValue(serviceName, replaceBuilder, jw); if (serviceVersion != null) { jw.writeByte(COMMA); - writeFieldName("version", jw); - writeStringValue(serviceVersion, replaceBuilder, jw); + DslJsonUtil.writeFieldName("version", jw); + DslJsonUtil.writeStringValue(serviceVersion, replaceBuilder, jw); } } @@ -242,22 +242,22 @@ private static void serializeService(@Nullable final CharSequence serviceName, @ if (serviceName != null) { jw.writeByte(COMMA); } - writeFieldName("target", jw); + DslJsonUtil.writeFieldName("target", jw); jw.writeByte(OBJECT_START); CharSequence targetType = serviceTarget.getType(); CharSequence targetName = serviceTarget.getName(); if (targetType != null) { - writeFieldName("type", jw); - writeStringValue(targetType, replaceBuilder, jw); + DslJsonUtil.writeFieldName("type", jw); + DslJsonUtil.writeStringValue(targetType, replaceBuilder, jw); } if (targetName != null) { if (targetType != null) { jw.writeByte(COMMA); } - writeFieldName("name", jw); - writeStringValue(targetName, replaceBuilder, jw); + DslJsonUtil.writeFieldName("name", jw); + DslJsonUtil.writeStringValue(targetName, replaceBuilder, jw); } jw.writeByte(OBJECT_END); @@ -271,7 +271,7 @@ private static void serializeService(@Nullable String name, @Nullable String ver } private static void serializeAgent(final Agent agent, final StringBuilder replaceBuilder, final JsonWriter jw, boolean supportsAgentActivationMethod) { - writeFieldName("agent", jw); + DslJsonUtil.writeFieldName("agent", jw); jw.writeByte(JsonWriter.OBJECT_START); if (supportsAgentActivationMethod) { writeField("activation_method", agent.getActivationMethod(), replaceBuilder, jw); @@ -284,7 +284,7 @@ private static void serializeAgent(final Agent agent, final StringBuilder replac } private static void serializeLanguage(final Language language, final StringBuilder replaceBuilder, final JsonWriter jw) { - writeFieldName("language", jw); + DslJsonUtil.writeFieldName("language", jw); jw.writeByte(JsonWriter.OBJECT_START); writeField("name", language.getName(), replaceBuilder, jw); writeLastField("version", language.getVersion(), replaceBuilder, jw); @@ -293,7 +293,7 @@ private static void serializeLanguage(final Language language, final StringBuild } private static void serializeFramework(final Framework framework, final StringBuilder replaceBuilder, final JsonWriter jw) { - writeFieldName("framework", jw); + DslJsonUtil.writeFieldName("framework", jw); jw.writeByte(JsonWriter.OBJECT_START); writeField("name", framework.getName(), replaceBuilder, jw); writeLastField("version", framework.getVersion(), replaceBuilder, jw); @@ -302,7 +302,7 @@ private static void serializeFramework(final Framework framework, final StringBu } private static void serializeNode(final Node node, final StringBuilder replaceBuilder, final JsonWriter jw) { - writeFieldName("node", jw); + DslJsonUtil.writeFieldName("node", jw); jw.writeByte(JsonWriter.OBJECT_START); writeLastField("configured_name", node.getName(), replaceBuilder, jw); jw.writeByte(JsonWriter.OBJECT_END); @@ -310,7 +310,7 @@ private static void serializeNode(final Node node, final StringBuilder replaceBu } private static void serializeRuntime(final RuntimeInfo runtime, final StringBuilder replaceBuilder, final JsonWriter jw) { - writeFieldName("runtime", jw); + DslJsonUtil.writeFieldName("runtime", jw); jw.writeByte(JsonWriter.OBJECT_START); writeField("name", runtime.getName(), replaceBuilder, jw); writeLastField("version", runtime.getVersion(), replaceBuilder, jw); @@ -319,7 +319,7 @@ private static void serializeRuntime(final RuntimeInfo runtime, final StringBuil } private static void serializeProcess(final ProcessInfo process, final StringBuilder replaceBuilder, final JsonWriter jw) { - writeFieldName("process", jw); + DslJsonUtil.writeFieldName("process", jw); jw.writeByte(JsonWriter.OBJECT_START); writeField("pid", process.getPid(), jw); if (process.getPpid() != null) { @@ -337,7 +337,7 @@ private static void serializeSystem(SystemInfo system, JsonWriter jw, boolean supportsConfiguredAndDetectedHostname) { - writeFieldName("system", jw); + DslJsonUtil.writeFieldName("system", jw); jw.writeByte(JsonWriter.OBJECT_START); serializeContainerInfo(system.getContainerInfo(), replaceBuilder, jw); serializeKubernetesInfo(system.getKubernetesInfo(), replaceBuilder, jw); @@ -360,13 +360,13 @@ private static void serializeSystem(SystemInfo system, } private static void serializeCloudProvider(final CloudProviderInfo cloudProviderInfo, final StringBuilder replaceBuilder, final JsonWriter jw) { - writeFieldName("cloud", jw); + DslJsonUtil.writeFieldName("cloud", jw); jw.writeByte(OBJECT_START); serializeNameAndIdField(cloudProviderInfo.getAccount(), "account", replaceBuilder, jw); serializeNameAndIdField(cloudProviderInfo.getInstance(), "instance", replaceBuilder, jw); serializeNameAndIdField(cloudProviderInfo.getProject(), "project", replaceBuilder, jw); if (cloudProviderInfo.getMachine() != null) { - writeFieldName("machine", jw); + DslJsonUtil.writeFieldName("machine", jw); jw.writeByte(JsonWriter.OBJECT_START); writeLastField("type", cloudProviderInfo.getMachine().getType(), replaceBuilder, jw); jw.writeByte(JsonWriter.OBJECT_END); @@ -375,7 +375,7 @@ private static void serializeCloudProvider(final CloudProviderInfo cloudProvider writeField("availability_zone", cloudProviderInfo.getAvailabilityZone(), replaceBuilder, jw); writeField("region", cloudProviderInfo.getRegion(), replaceBuilder, jw); if (null != cloudProviderInfo.getService()) { - writeFieldName("service", jw); + DslJsonUtil.writeFieldName("service", jw); jw.writeByte(JsonWriter.OBJECT_START); writeLastField("name", cloudProviderInfo.getService().getName(), replaceBuilder, jw); jw.writeByte(JsonWriter.OBJECT_END); @@ -388,13 +388,13 @@ private static void serializeCloudProvider(final CloudProviderInfo cloudProvider private static void serializeNameAndIdField(@Nullable NameAndIdField nameAndIdField, String fieldName, StringBuilder replaceBuilder, JsonWriter jw) { if (nameAndIdField != null && !nameAndIdField.isEmpty()) { - writeFieldName(fieldName, jw); + DslJsonUtil.writeFieldName(fieldName, jw); jw.writeByte(JsonWriter.OBJECT_START); boolean idWritten = false; String id = nameAndIdField.getId(); if (id != null) { - writeFieldName("id", jw); - writeStringValue(id, replaceBuilder, jw); + DslJsonUtil.writeFieldName("id", jw); + DslJsonUtil.writeStringValue(id, replaceBuilder, jw); idWritten = true; } String name = nameAndIdField.getName(); @@ -402,8 +402,8 @@ private static void serializeNameAndIdField(@Nullable NameAndIdField nameAndIdFi if (idWritten) { jw.writeByte(COMMA); } - writeFieldName("name", jw); - writeStringValue(name, replaceBuilder, jw); + DslJsonUtil.writeFieldName("name", jw); + DslJsonUtil.writeStringValue(name, replaceBuilder, jw); } jw.writeByte(JsonWriter.OBJECT_END); jw.writeByte(COMMA); @@ -412,7 +412,7 @@ private static void serializeNameAndIdField(@Nullable NameAndIdField nameAndIdFi private static void serializeContainerInfo(@Nullable SystemInfo.Container container, final StringBuilder replaceBuilder, final JsonWriter jw) { if (container != null) { - writeFieldName("container", jw); + DslJsonUtil.writeFieldName("container", jw); jw.writeByte(JsonWriter.OBJECT_START); writeLastField("id", container.getId(), replaceBuilder, jw); jw.writeByte(JsonWriter.OBJECT_END); @@ -422,7 +422,7 @@ private static void serializeContainerInfo(@Nullable SystemInfo.Container contai private static void serializeKubernetesInfo(@Nullable SystemInfo.Kubernetes kubernetes, final StringBuilder replaceBuilder, final JsonWriter jw) { if (kubernetes != null && kubernetes.hasContent()) { - writeFieldName("kubernetes", jw); + DslJsonUtil.writeFieldName("kubernetes", jw); jw.writeByte(JsonWriter.OBJECT_START); serializeKubeNodeInfo(kubernetes.getNode(), replaceBuilder, jw); serializeKubePodInfo(kubernetes.getPod(), replaceBuilder, jw); @@ -434,7 +434,7 @@ private static void serializeKubernetesInfo(@Nullable SystemInfo.Kubernetes kube private static void serializeKubePodInfo(@Nullable SystemInfo.Kubernetes.Pod pod, final StringBuilder replaceBuilder, final JsonWriter jw) { if (pod != null) { - writeFieldName("pod", jw); + DslJsonUtil.writeFieldName("pod", jw); jw.writeByte(JsonWriter.OBJECT_START); String podName = pod.getName(); if (podName != null) { @@ -448,7 +448,7 @@ private static void serializeKubePodInfo(@Nullable SystemInfo.Kubernetes.Pod pod private static void serializeKubeNodeInfo(@Nullable SystemInfo.Kubernetes.Node node, final StringBuilder replaceBuilder, final JsonWriter jw) { if (node != null) { - writeFieldName("node", jw); + DslJsonUtil.writeFieldName("node", jw); jw.writeByte(JsonWriter.OBJECT_START); writeLastField("name", node.getName(), replaceBuilder, jw); jw.writeByte(JsonWriter.OBJECT_END); @@ -476,13 +476,13 @@ private static void serializeStringKeyScalarValueMap(Iterator kv = it.next(); - writeStringValue(sanitizePropertyName(kv.getKey(), replaceBuilder), replaceBuilder, jw); + DslJsonUtil.writeStringValue(DslJsonUtil.sanitizePropertyName(kv.getKey(), replaceBuilder), replaceBuilder, jw); jw.writeByte(JsonWriter.SEMI); serializeScalarValue(replaceBuilder, jw, kv.getValue(), extendedStringLimit, supportsNonStringValues); while (it.hasNext()) { jw.writeByte(COMMA); kv = it.next(); - writeStringValue(sanitizePropertyName(kv.getKey(), replaceBuilder), replaceBuilder, jw); + DslJsonUtil.writeStringValue(DslJsonUtil.sanitizePropertyName(kv.getKey(), replaceBuilder), replaceBuilder, jw); jw.writeByte(JsonWriter.SEMI); serializeScalarValue(replaceBuilder, jw, kv.getValue(), extendedStringLimit, supportsNonStringValues); } @@ -498,7 +498,7 @@ static void serializeLabels(Labels labels, final String serviceName, final Strin } if (!labels.isEmpty()) { if (labels.getTransactionName() != null || labels.getTransactionType() != null) { - writeFieldName("transaction", jw); + DslJsonUtil.writeFieldName("transaction", jw); jw.writeByte(OBJECT_START); writeField("name", labels.getTransactionName(), replaceBuilder, jw); writeLastField("type", labels.getTransactionType(), replaceBuilder, jw); @@ -507,7 +507,7 @@ static void serializeLabels(Labels labels, final String serviceName, final Strin } if (labels.getSpanType() != null || labels.getSpanSubType() != null) { - writeFieldName("span", jw); + DslJsonUtil.writeFieldName("span", jw); jw.writeByte(OBJECT_START); writeField("type", labels.getSpanType(), replaceBuilder, jw); writeLastField("subtype", labels.getSpanSubType(), replaceBuilder, jw); @@ -515,7 +515,7 @@ static void serializeLabels(Labels labels, final String serviceName, final Strin jw.writeByte(COMMA); } - writeFieldName("tags", jw); + DslJsonUtil.writeFieldName("tags", jw); jw.writeByte(OBJECT_START); serialize(labels, replaceBuilder, jw); jw.writeByte(OBJECT_END); @@ -528,7 +528,7 @@ private static void serialize(Labels labels, final StringBuilder replaceBuilder, if (i > 0) { jw.writeByte(COMMA); } - writeStringValue(sanitizePropertyName(labels.getKey(i), replaceBuilder), replaceBuilder, jw); + DslJsonUtil.writeStringValue(DslJsonUtil.sanitizePropertyName(labels.getKey(i), replaceBuilder), replaceBuilder, jw); jw.writeByte(JsonWriter.SEMI); serializeScalarValue(replaceBuilder, jw, labels.getValue(i), false, false); } @@ -539,7 +539,7 @@ private static void serializeScalarValue(final StringBuilder replaceBuilder, fin if (extendedStringLimit) { writeLongStringValue((String) value, replaceBuilder, jw); } else { - writeStringValue((String) value, replaceBuilder, jw); + DslJsonUtil.writeStringValue((String) value, replaceBuilder, jw); } } else if (value instanceof Number) { if (supportsNonStringValues) { @@ -559,25 +559,6 @@ private static void serializeScalarValue(final StringBuilder replaceBuilder, fin } } - public static CharSequence sanitizePropertyName(String key, StringBuilder replaceBuilder) { - for (int i = 0; i < DISALLOWED_IN_PROPERTY_NAME.length; i++) { - if (key.contains(DISALLOWED_IN_PROPERTY_NAME[i])) { - return replaceAll(key, DISALLOWED_IN_PROPERTY_NAME, "_", replaceBuilder); - } - } - return key; - } - - private static CharSequence replaceAll(String s, String[] stringsToReplace, String replacement, StringBuilder replaceBuilder) { - // uses a instance variable StringBuilder to avoid allocations - replaceBuilder.setLength(0); - replaceBuilder.append(s); - for (String toReplace : stringsToReplace) { - replace(replaceBuilder, toReplace, replacement, 0); - } - return replaceBuilder; - } - static void replace(StringBuilder replaceBuilder, String toReplace, String replacement, int fromIndex) { for (int i = replaceBuilder.indexOf(toReplace, fromIndex); i != -1; i = replaceBuilder.indexOf(toReplace, fromIndex)) { replaceBuilder.replace(i, i + toReplace.length(), replacement); @@ -601,13 +582,13 @@ static void writeField(final String fieldName, if (value == null) { if (writeNull) { - writeFieldName(fieldName, jw); + DslJsonUtil.writeFieldName(fieldName, jw); jw.writeNull(); jw.writeByte(COMMA); } } else { - writeFieldName(fieldName, jw); - writeStringValue(value, replaceBuilder, jw); + DslJsonUtil.writeFieldName(fieldName, jw); + DslJsonUtil.writeStringValue(value, replaceBuilder, jw); jw.writeByte(COMMA); } } @@ -620,16 +601,6 @@ private static void writeStringBuilderValue(StringBuilder value, JsonWriter jw) jw.writeString(value); } - public static void writeStringValue(CharSequence value, final StringBuilder replaceBuilder, final JsonWriter jw) { - if (value.length() > SerializationConstants.MAX_VALUE_LENGTH) { - replaceBuilder.setLength(0); - replaceBuilder.append(value, 0, Math.min(value.length(), SerializationConstants.MAX_VALUE_LENGTH + 1)); - writeStringBuilderValue(replaceBuilder, jw); - } else { - jw.writeString(value); - } - } - private static void writeLongStringBuilderValue(StringBuilder value, JsonWriter jw) { if (value.length() > SerializationConstants.getMaxLongStringValueLength()) { value.setLength(SerializationConstants.getMaxLongStringValueLength() - 1); @@ -649,30 +620,23 @@ private static void writeLongStringValue(CharSequence value, final StringBuilder } static void writeField(final String fieldName, final long value, final JsonWriter jw) { - writeFieldName(fieldName, jw); + DslJsonUtil.writeFieldName(fieldName, jw); NumberConverter.serialize(value, jw); jw.writeByte(COMMA); } public static void writeLastField(final String fieldName, @Nullable final CharSequence value, StringBuilder replaceBuilder, final JsonWriter jw) { - writeFieldName(fieldName, jw); + DslJsonUtil.writeFieldName(fieldName, jw); if (value != null && value.length() > 0) { - writeStringValue(value, replaceBuilder, jw); + DslJsonUtil.writeStringValue(value, replaceBuilder, jw); } else { jw.writeNull(); } } - public static void writeFieldName(final String fieldName, final JsonWriter jw) { - jw.writeByte(JsonWriter.QUOTE); - jw.writeAscii(fieldName); - jw.writeByte(JsonWriter.QUOTE); - jw.writeByte(JsonWriter.SEMI); - } - static void writeField(final String fieldName, final List values, final JsonWriter jw) { if (values.size() > 0) { - writeFieldName(fieldName, jw); + DslJsonUtil.writeFieldName(fieldName, jw); jw.writeByte(ARRAY_START); jw.writeString(values.get(0)); for (int i = 1; i < values.size(); i++) { @@ -1142,7 +1106,7 @@ private void serializeNumber(Number n, JsonWriter jw) { } private void serializeComposite(Composite composite) { - DslJsonSerializer.writeFieldName("composite", jw); + DslJsonUtil.writeFieldName("composite", jw); jw.writeByte(OBJECT_START); writeField("count", composite.getCount()); writeField("sum", composite.getSumMs()); @@ -1342,7 +1306,7 @@ private void serializeStackTraceElement(StackFrame frame, StringBuilder replaceB frame.appendFileName(replaceBuilder); writeField("filename", replaceBuilder); writeField("function", frame.getMethodName()); - writeField("library_frame", isLibraryFrame(frame.getClassName())); + writeField("library_frame", frame.getClassName() != null && isLibraryFrame(frame.getClassName())); writeLastField("lineno", -1); jw.writeByte(OBJECT_END); } @@ -1675,7 +1639,7 @@ void serializeUrl(final Url url) { } else { // serialize as a string for compatibility // doing it in low-level to avoid allocation - DslJsonSerializer.writeFieldName("port", jw); + DslJsonUtil.writeFieldName("port", jw); jw.writeByte(QUOTE); NumberConverter.serialize(port, jw); jw.writeByte(QUOTE); @@ -1787,7 +1751,7 @@ private void writeStringBuilderValue(StringBuilder value) { } private void writeStringValue(CharSequence value) { - DslJsonSerializer.writeStringValue(value, replaceBuilder, jw); + DslJsonUtil.writeStringValue(value, replaceBuilder, jw); } private void writeLongStringValue(CharSequence value) { @@ -1836,7 +1800,7 @@ void writeLastField(final String fieldName, @Nullable final CharSequence value) } private void writeFieldName(final String fieldName) { - DslJsonSerializer.writeFieldName(fieldName, jw); + DslJsonUtil.writeFieldName(fieldName, jw); } private void writeNonLastIdField(String fieldName, Id id) { diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/report/serialize/MetricRegistryReporter.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/report/serialize/MetricRegistryReporter.java index aa1a9347a9..04327f4f0f 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/report/serialize/MetricRegistryReporter.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/report/serialize/MetricRegistryReporter.java @@ -18,10 +18,11 @@ */ package co.elastic.apm.agent.report.serialize; +import co.elastic.apm.agent.tracer.Tracer; import co.elastic.apm.agent.tracer.service.ServiceInfo; -import co.elastic.apm.agent.context.AbstractLifecycleListener; +import co.elastic.apm.agent.tracer.AbstractLifecycleListener; import co.elastic.apm.agent.impl.ElasticApmTracer; -import co.elastic.apm.agent.metrics.Labels; +import co.elastic.apm.agent.tracer.metrics.Labels; import co.elastic.apm.agent.metrics.MetricRegistry; import co.elastic.apm.agent.metrics.MetricSet; import co.elastic.apm.agent.report.Reporter; @@ -47,10 +48,12 @@ public MetricRegistryReporter(ElasticApmTracer tracer) { } @Override - public void start(ElasticApmTracer tracer) { + public void start(Tracer tracer) { long intervalMs = tracer.getConfig(ReporterConfiguration.class).getMetricsIntervalMs(); if (intervalMs > 0) { - tracer.getSharedSingleThreadedPool().scheduleAtFixedRate(this, intervalMs, intervalMs, TimeUnit.MILLISECONDS); + tracer.require(ElasticApmTracer.class) + .getSharedSingleThreadedPool() + .scheduleAtFixedRate(this, intervalMs, intervalMs, TimeUnit.MILLISECONDS); } } diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/report/serialize/MetricRegistrySerializer.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/report/serialize/MetricRegistrySerializer.java index e5b3700f39..afcf9133e1 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/report/serialize/MetricRegistrySerializer.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/report/serialize/MetricRegistrySerializer.java @@ -19,9 +19,10 @@ package co.elastic.apm.agent.report.serialize; import co.elastic.apm.agent.tracer.service.ServiceInfo; -import co.elastic.apm.agent.metrics.DoubleSupplier; +import co.elastic.apm.agent.tracer.metrics.DoubleSupplier; import co.elastic.apm.agent.metrics.MetricSet; import co.elastic.apm.agent.metrics.Timer; +import co.elastic.apm.agent.tracer.metrics.DslJsonUtil; import com.dslplatform.json.DslJson; import com.dslplatform.json.JsonWriter; import com.dslplatform.json.NumberConverter; @@ -80,14 +81,14 @@ private static boolean serialize(MetricSet metricSet, long epochMicros, String s boolean hasSamples; jw.writeByte(JsonWriter.OBJECT_START); { - DslJsonSerializer.writeFieldName("metricset", jw); + DslJsonUtil.writeFieldName("metricset", jw); jw.writeByte(JsonWriter.OBJECT_START); { - DslJsonSerializer.writeFieldName("timestamp", jw); + DslJsonUtil.writeFieldName("timestamp", jw); NumberConverter.serialize(epochMicros, jw); jw.writeByte(JsonWriter.COMMA); DslJsonSerializer.serializeLabels(metricSet.getLabels(), serviceName, serviceVersion, replaceBuilder, jw); - DslJsonSerializer.writeFieldName("samples", jw); + DslJsonUtil.writeFieldName("samples", jw); jw.writeByte(JsonWriter.OBJECT_START); hasSamples = serializeGauges(metricSet.getGauges(), jw); hasSamples |= serializeTimers(metricSet.getTimers(), hasSamples, jw); diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/report/serialize/SerializationConstants.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/report/serialize/SerializationConstants.java index 8f5e4d2db0..bd927d1b8f 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/report/serialize/SerializationConstants.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/report/serialize/SerializationConstants.java @@ -19,6 +19,7 @@ package co.elastic.apm.agent.report.serialize; import co.elastic.apm.agent.configuration.CoreConfiguration; +import co.elastic.apm.agent.tracer.metrics.DslJsonUtil; import javax.annotation.Nullable; @@ -31,7 +32,7 @@ public class SerializationConstants { */ public static final int BUFFER_SIZE = 16384; - public static final int MAX_VALUE_LENGTH = 1024; + public static final int MAX_VALUE_LENGTH = DslJsonUtil.MAX_VALUE_LENGTH; @Nullable private static volatile SerializationConstants INSTANCE; diff --git a/apm-agent-core/src/main/resources/META-INF/services/co.elastic.apm.agent.context.LifecycleListener b/apm-agent-core/src/main/resources/META-INF/services/co.elastic.apm.agent.tracer.LifecycleListener similarity index 100% rename from apm-agent-core/src/main/resources/META-INF/services/co.elastic.apm.agent.context.LifecycleListener rename to apm-agent-core/src/main/resources/META-INF/services/co.elastic.apm.agent.tracer.LifecycleListener diff --git a/apm-agent-core/src/test/java/co/elastic/apm/agent/MockReporter.java b/apm-agent-core/src/test/java/co/elastic/apm/agent/MockReporter.java index 1d927c4dce..6fe269b495 100644 --- a/apm-agent-core/src/test/java/co/elastic/apm/agent/MockReporter.java +++ b/apm-agent-core/src/test/java/co/elastic/apm/agent/MockReporter.java @@ -40,6 +40,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.networknt.schema.JsonSchema; import com.networknt.schema.JsonSchemaFactory; +import com.networknt.schema.SpecVersion; import com.networknt.schema.ValidationMessage; import org.awaitility.core.ThrowingRunnable; import org.stagemonitor.configuration.ConfigurationRegistry; @@ -810,7 +811,7 @@ private enum SchemaInstance { private static JsonSchema getSchema(String resource) { InputStream input = Objects.requireNonNull(MockReporter.class.getResourceAsStream(resource), "missing resource " + resource); - return JsonSchemaFactory.getInstance().getSchema(input); + return JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4).getSchema(input); } } diff --git a/apm-agent-core/src/test/java/co/elastic/apm/agent/impl/ElasticApmTracerTest.java b/apm-agent-core/src/test/java/co/elastic/apm/agent/impl/ElasticApmTracerTest.java index b2771cfd8a..b365039737 100644 --- a/apm-agent-core/src/test/java/co/elastic/apm/agent/impl/ElasticApmTracerTest.java +++ b/apm-agent-core/src/test/java/co/elastic/apm/agent/impl/ElasticApmTracerTest.java @@ -34,7 +34,7 @@ import co.elastic.apm.agent.impl.transaction.Span; import co.elastic.apm.agent.impl.transaction.TraceContext; import co.elastic.apm.agent.impl.transaction.Transaction; -import co.elastic.apm.agent.metrics.Labels; +import co.elastic.apm.agent.tracer.metrics.Labels; import co.elastic.apm.agent.objectpool.TestObjectPoolFactory; import co.elastic.apm.agent.report.ApmServerClient; import co.elastic.apm.agent.tracer.Outcome; diff --git a/apm-agent-core/src/test/java/co/elastic/apm/agent/impl/LifecycleTest.java b/apm-agent-core/src/test/java/co/elastic/apm/agent/impl/LifecycleTest.java index 9ba0dbc469..ddf693bd5e 100644 --- a/apm-agent-core/src/test/java/co/elastic/apm/agent/impl/LifecycleTest.java +++ b/apm-agent-core/src/test/java/co/elastic/apm/agent/impl/LifecycleTest.java @@ -21,7 +21,7 @@ import co.elastic.apm.agent.MockReporter; import co.elastic.apm.agent.bci.ElasticApmAgent; import co.elastic.apm.agent.configuration.SpyConfiguration; -import co.elastic.apm.agent.context.AbstractLifecycleListener; +import co.elastic.apm.agent.tracer.AbstractLifecycleListener; import co.elastic.apm.agent.objectpool.TestObjectPoolFactory; import net.bytebuddy.agent.ByteBuddyAgent; import org.junit.jupiter.api.AfterEach; @@ -145,12 +145,12 @@ void testStartDisabled() throws Exception { .reporter(new MockReporter()) .withLifecycleListener(new AbstractLifecycleListener() { @Override - public void init(ElasticApmTracer tracer) { + public void init(co.elastic.apm.agent.tracer.Tracer tracer) { initialized.set(true); } @Override - public void start(ElasticApmTracer tracer) throws Exception { + public void start(co.elastic.apm.agent.tracer.Tracer tracer) throws Exception { started.set(true); } }) @@ -163,7 +163,7 @@ public void start(ElasticApmTracer tracer) throws Exception { /* * Has an entry in - * src/test/resources/META-INF/services/co.elastic.apm.agent.context.LifecycleListener + * src/test/resources/META-INF/services/co.elastic.apm.agent.tracer.LifecycleListener */ public static class TestLifecycleListener extends AbstractLifecycleListener { @@ -178,7 +178,7 @@ public TestLifecycleListener() { } @Override - public void start(ElasticApmTracer tracer) { + public void start(co.elastic.apm.agent.tracer.Tracer tracer) { start.incrementAndGet(); } diff --git a/apm-agent-core/src/test/java/co/elastic/apm/agent/impl/SpanTypeBreakdownTest.java b/apm-agent-core/src/test/java/co/elastic/apm/agent/impl/SpanTypeBreakdownTest.java index a090c71566..d8147bdf33 100644 --- a/apm-agent-core/src/test/java/co/elastic/apm/agent/impl/SpanTypeBreakdownTest.java +++ b/apm-agent-core/src/test/java/co/elastic/apm/agent/impl/SpanTypeBreakdownTest.java @@ -26,7 +26,7 @@ import co.elastic.apm.agent.impl.transaction.AbstractSpan; import co.elastic.apm.agent.impl.transaction.Span; import co.elastic.apm.agent.impl.transaction.Transaction; -import co.elastic.apm.agent.metrics.Labels; +import co.elastic.apm.agent.tracer.metrics.Labels; import co.elastic.apm.agent.metrics.MetricSet; import co.elastic.apm.agent.metrics.Timer; import org.junit.jupiter.api.AfterEach; diff --git a/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/MetricRegistryTest.java b/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/MetricRegistryTest.java index 2b445c9e54..5590fea3cc 100644 --- a/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/MetricRegistryTest.java +++ b/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/MetricRegistryTest.java @@ -21,6 +21,8 @@ import co.elastic.apm.agent.configuration.MetricsConfiguration; import co.elastic.apm.agent.common.util.WildcardMatcher; import co.elastic.apm.agent.report.ReporterConfiguration; +import co.elastic.apm.agent.tracer.metrics.DoubleSupplier; +import co.elastic.apm.agent.tracer.metrics.Labels; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/builtin/AgentOverheadMetricsTest.java b/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/builtin/AgentOverheadMetricsTest.java index 814bc84cfc..093782f979 100644 --- a/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/builtin/AgentOverheadMetricsTest.java +++ b/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/builtin/AgentOverheadMetricsTest.java @@ -20,7 +20,7 @@ import co.elastic.apm.agent.configuration.MetricsConfiguration; import co.elastic.apm.agent.common.util.WildcardMatcher; -import co.elastic.apm.agent.metrics.Labels; +import co.elastic.apm.agent.tracer.metrics.Labels; import co.elastic.apm.agent.metrics.MetricRegistry; import co.elastic.apm.agent.metrics.MetricSet; import co.elastic.apm.agent.report.ReporterConfiguration; diff --git a/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/builtin/AgentReporterMetricsTest.java b/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/builtin/AgentReporterMetricsTest.java index bc86fd0cda..83527ffe6b 100644 --- a/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/builtin/AgentReporterMetricsTest.java +++ b/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/builtin/AgentReporterMetricsTest.java @@ -20,7 +20,7 @@ import co.elastic.apm.agent.configuration.MetricsConfiguration; import co.elastic.apm.agent.common.util.WildcardMatcher; -import co.elastic.apm.agent.metrics.Labels; +import co.elastic.apm.agent.tracer.metrics.Labels; import co.elastic.apm.agent.metrics.MetricRegistry; import co.elastic.apm.agent.metrics.MetricSet; import co.elastic.apm.agent.report.ReporterConfiguration; diff --git a/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/builtin/CGroupMetricsTest.java b/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/builtin/CGroupMetricsTest.java index a8d80db1e0..5dd24ae174 100644 --- a/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/builtin/CGroupMetricsTest.java +++ b/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/builtin/CGroupMetricsTest.java @@ -19,7 +19,7 @@ package co.elastic.apm.agent.metrics.builtin; import co.elastic.apm.agent.configuration.MetricsConfiguration; -import co.elastic.apm.agent.metrics.Labels; +import co.elastic.apm.agent.tracer.metrics.Labels; import co.elastic.apm.agent.metrics.MetricRegistry; import co.elastic.apm.agent.report.ReporterConfiguration; import org.junit.jupiter.api.Test; diff --git a/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/builtin/JvmFdMetricsTest.java b/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/builtin/JvmFdMetricsTest.java index dc15f3874c..3f87b5c70c 100644 --- a/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/builtin/JvmFdMetricsTest.java +++ b/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/builtin/JvmFdMetricsTest.java @@ -19,7 +19,7 @@ package co.elastic.apm.agent.metrics.builtin; import co.elastic.apm.agent.configuration.MetricsConfiguration; -import co.elastic.apm.agent.metrics.Labels; +import co.elastic.apm.agent.tracer.metrics.Labels; import co.elastic.apm.agent.metrics.MetricRegistry; import co.elastic.apm.agent.report.ReporterConfiguration; import org.junit.jupiter.api.condition.DisabledOnOs; diff --git a/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/builtin/JvmMemoryMetricsTest.java b/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/builtin/JvmMemoryMetricsTest.java index 05c4fe4348..413b148d5c 100644 --- a/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/builtin/JvmMemoryMetricsTest.java +++ b/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/builtin/JvmMemoryMetricsTest.java @@ -19,7 +19,7 @@ package co.elastic.apm.agent.metrics.builtin; import co.elastic.apm.agent.configuration.MetricsConfiguration; -import co.elastic.apm.agent.metrics.Labels; +import co.elastic.apm.agent.tracer.metrics.Labels; import co.elastic.apm.agent.metrics.MetricRegistry; import co.elastic.apm.agent.report.ReporterConfiguration; import org.assertj.core.api.AbstractDoubleAssert; diff --git a/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/builtin/SystemMetricsTest.java b/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/builtin/SystemMetricsTest.java index dea7de26c2..3226241264 100644 --- a/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/builtin/SystemMetricsTest.java +++ b/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/builtin/SystemMetricsTest.java @@ -19,7 +19,7 @@ package co.elastic.apm.agent.metrics.builtin; import co.elastic.apm.agent.configuration.MetricsConfiguration; -import co.elastic.apm.agent.metrics.Labels; +import co.elastic.apm.agent.tracer.metrics.Labels; import co.elastic.apm.agent.metrics.MetricRegistry; import co.elastic.apm.agent.report.ReporterConfiguration; import org.junit.jupiter.api.Test; diff --git a/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/builtin/ThreadMetricsTest.java b/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/builtin/ThreadMetricsTest.java index 287047b2ea..4fec12cf1a 100644 --- a/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/builtin/ThreadMetricsTest.java +++ b/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/builtin/ThreadMetricsTest.java @@ -19,7 +19,7 @@ package co.elastic.apm.agent.metrics.builtin; import co.elastic.apm.agent.configuration.MetricsConfiguration; -import co.elastic.apm.agent.metrics.Labels; +import co.elastic.apm.agent.tracer.metrics.Labels; import co.elastic.apm.agent.metrics.MetricRegistry; import co.elastic.apm.agent.report.ReporterConfiguration; import org.junit.jupiter.api.Test; diff --git a/apm-agent-core/src/test/java/co/elastic/apm/agent/report/serialize/MetricSetSerializationTest.java b/apm-agent-core/src/test/java/co/elastic/apm/agent/report/serialize/MetricSetSerializationTest.java index 7f696af5f1..1abc82a114 100644 --- a/apm-agent-core/src/test/java/co/elastic/apm/agent/report/serialize/MetricSetSerializationTest.java +++ b/apm-agent-core/src/test/java/co/elastic/apm/agent/report/serialize/MetricSetSerializationTest.java @@ -20,7 +20,7 @@ import co.elastic.apm.agent.configuration.MetricsConfiguration; import co.elastic.apm.agent.tracer.service.ServiceInfo; -import co.elastic.apm.agent.metrics.Labels; +import co.elastic.apm.agent.tracer.metrics.Labels; import co.elastic.apm.agent.metrics.MetricCollector; import co.elastic.apm.agent.metrics.MetricRegistry; import co.elastic.apm.agent.metrics.MetricsProvider; diff --git a/apm-agent-core/src/test/resources/META-INF/services/co.elastic.apm.agent.context.LifecycleListener b/apm-agent-core/src/test/resources/META-INF/services/co.elastic.apm.agent.tracer.LifecycleListener similarity index 100% rename from apm-agent-core/src/test/resources/META-INF/services/co.elastic.apm.agent.context.LifecycleListener rename to apm-agent-core/src/test/resources/META-INF/services/co.elastic.apm.agent.tracer.LifecycleListener diff --git a/apm-agent-lambda-layer/pom.xml b/apm-agent-lambda-layer/pom.xml index 7acb09a53e..2632f74b45 100644 --- a/apm-agent-lambda-layer/pom.xml +++ b/apm-agent-lambda-layer/pom.xml @@ -3,7 +3,7 @@ apm-agent-parent co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugin-sdk/pom.xml b/apm-agent-plugin-sdk/pom.xml index 2adaf7fd88..88840de213 100644 --- a/apm-agent-plugin-sdk/pom.xml +++ b/apm-agent-plugin-sdk/pom.xml @@ -3,7 +3,7 @@ apm-agent-parent co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugin-sdk/src/main/java/co/elastic/apm/agent/sdk/bytebuddy/AnnotationValueOffsetMappingFactory.java b/apm-agent-plugin-sdk/src/main/java/co/elastic/apm/agent/sdk/bytebuddy/AnnotationValueOffsetMappingFactory.java index 98e1d433c8..de58b9602b 100644 --- a/apm-agent-plugin-sdk/src/main/java/co/elastic/apm/agent/sdk/bytebuddy/AnnotationValueOffsetMappingFactory.java +++ b/apm-agent-plugin-sdk/src/main/java/co/elastic/apm/agent/sdk/bytebuddy/AnnotationValueOffsetMappingFactory.java @@ -22,6 +22,7 @@ import co.elastic.apm.agent.sdk.logging.LoggerFactory; import net.bytebuddy.asm.Advice; import net.bytebuddy.description.annotation.AnnotationDescription; +import net.bytebuddy.description.annotation.AnnotationValue; import net.bytebuddy.description.method.MethodDescription; import net.bytebuddy.description.method.ParameterDescription; import net.bytebuddy.description.type.TypeDescription; @@ -32,6 +33,11 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import java.util.ArrayDeque; +import java.util.Collections; +import java.util.IdentityHashMap; +import java.util.Queue; +import java.util.Set; import static net.bytebuddy.matcher.ElementMatchers.named; @@ -58,20 +64,31 @@ public Target resolve(TypeDescription instrumentedType, MethodDescription instru @Nullable private Object getAnnotationValue(MethodDescription instrumentedMethod, AnnotationValueExtractor annotationValueExtractor) { - MethodDescription methodDescription = instrumentedMethod; - do { - for (TypeDescription typeDescription : methodDescription.getDeclaredAnnotations().asTypeList()) { - if (named(annotationValueExtractor.annotationClassName()).matches(typeDescription)) { - for (MethodDescription.InDefinedShape annotationMethod : typeDescription.getDeclaredMethods()) { - if (annotationMethod.getName().equals(annotationValueExtractor.method())) { - return methodDescription.getDeclaredAnnotations().ofType(typeDescription).getValue(annotationMethod).resolve(); - } + Queue typesToCheck = new ArrayDeque<>(); + typesToCheck.add(instrumentedMethod.getDeclaringType().asErasure()); + Set alreadyCheckedTypes = Collections.newSetFromMap(new IdentityHashMap()); + + while (!typesToCheck.isEmpty()) { + TypeDescription type = typesToCheck.poll(); + if (alreadyCheckedTypes.add(type)) { + MethodDescription method = findMethodWithSameSignature(type, instrumentedMethod); + if (method != null) { + AnnotationValue value = findValueOnMethod(method, annotationValueExtractor); + if (value != null) { + return value.resolve(); } } + + TypeDescription.Generic superClass = type.getSuperClass(); + if (superClass != null) { + typesToCheck.add(superClass.asErasure()); + } + for (TypeDescription.Generic interfaceType : type.getInterfaces()) { + typesToCheck.add(interfaceType.asErasure()); + } } + } - methodDescription = findInstrumentedMethodInSuperClass(methodDescription.getDeclaringType().getSuperClass(), instrumentedMethod); - } while (methodDescription != null); Class defaultValueProvider = annotationValueExtractor.defaultValueProvider(); try { return defaultValueProvider.getDeclaredConstructor().newInstance().getDefaultValue(); @@ -89,12 +106,8 @@ private Object getAnnotationValue(MethodDescription instrumentedMethod, Annotati } @Nullable - private MethodDescription findInstrumentedMethodInSuperClass(@Nullable TypeDescription.Generic superClass, MethodDescription instrumentedMethod) { - if (superClass == null) { - return null; - - } - for (MethodDescription declaredMethod : superClass.getDeclaredMethods()) { + private MethodDescription findMethodWithSameSignature(TypeDescription declaringType, MethodDescription instrumentedMethod) { + for (MethodDescription declaredMethod : declaringType.getDeclaredMethods()) { if (instrumentedMethod.getInternalName().equals(declaredMethod.getInternalName()) && instrumentedMethod.getParameters().asTypeList().asErasures().equals(declaredMethod.getParameters().asTypeList().asErasures())) { return declaredMethod; @@ -103,6 +116,21 @@ private MethodDescription findInstrumentedMethodInSuperClass(@Nullable TypeDescr return null; } + @Nullable + private static AnnotationValue findValueOnMethod(MethodDescription method, AnnotationValueExtractor valueExtractor) { + for (TypeDescription typeDescription : method.getDeclaredAnnotations().asTypeList()) { + if (named(valueExtractor.annotationClassName()).matches(typeDescription)) { + for (MethodDescription.InDefinedShape annotationMethod : typeDescription.getDeclaredMethods()) { + if (annotationMethod.getName().equals(valueExtractor.method())) { + return method.getDeclaredAnnotations().ofType(typeDescription).getValue(annotationMethod); + } + } + } + } + return null; + } + + @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.PARAMETER) public @interface AnnotationValueExtractor { @@ -114,7 +142,8 @@ private MethodDescription findInstrumentedMethodInSuperClass(@Nullable TypeDescr } public interface DefaultValueProvider { - @Nullable Object getDefaultValue(); + @Nullable + Object getDefaultValue(); } public static class NullDefaultValueProvider implements DefaultValueProvider { diff --git a/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient-common/pom.xml b/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient-common/pom.xml index 01d85b23d1..70a1c86efa 100644 --- a/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient-common/pom.xml +++ b/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient-common/pom.xml @@ -5,7 +5,7 @@ apm-apache-httpclient co.elastic.apm - 1.48.1 + 1.49.0 apm-apache-httpclient-common diff --git a/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient3-plugin/pom.xml b/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient3-plugin/pom.xml index 3c9413eefb..e200ba4293 100644 --- a/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient3-plugin/pom.xml +++ b/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient3-plugin/pom.xml @@ -5,7 +5,7 @@ apm-apache-httpclient co.elastic.apm - 1.48.1 + 1.49.0 apm-apache-httpclient3-plugin diff --git a/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/pom.xml b/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/pom.xml index 1f8b78b0ca..ad7f1b9375 100644 --- a/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/pom.xml +++ b/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/pom.xml @@ -5,7 +5,7 @@ apm-apache-httpclient co.elastic.apm - 1.48.1 + 1.49.0 apm-apache-httpclient4-plugin diff --git a/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient5-plugin/pom.xml b/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient5-plugin/pom.xml index 6780638bac..53c1f0445d 100644 --- a/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient5-plugin/pom.xml +++ b/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient5-plugin/pom.xml @@ -4,7 +4,7 @@ co.elastic.apm apm-apache-httpclient - 1.48.1 + 1.49.0 apm-apache-httpclient5-plugin diff --git a/apm-agent-plugins/apm-apache-httpclient/pom.xml b/apm-agent-plugins/apm-apache-httpclient/pom.xml index cc2a7466ab..db5fea7c42 100644 --- a/apm-agent-plugins/apm-apache-httpclient/pom.xml +++ b/apm-agent-plugins/apm-apache-httpclient/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-apache-httpclient diff --git a/apm-agent-plugins/apm-api-plugin/pom.xml b/apm-agent-plugins/apm-api-plugin/pom.xml index 8245bf49f8..2fa06b2262 100644 --- a/apm-agent-plugins/apm-api-plugin/pom.xml +++ b/apm-agent-plugins/apm-api-plugin/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 diff --git a/apm-agent-plugins/apm-api-plugin/src/test/java/co/elastic/apm/api/AnnotationInheritanceTest.java b/apm-agent-plugins/apm-api-plugin/src/test/java/co/elastic/apm/api/AnnotationInheritanceTest.java index 902fea1c74..3ad2468ab7 100644 --- a/apm-agent-plugins/apm-api-plugin/src/test/java/co/elastic/apm/api/AnnotationInheritanceTest.java +++ b/apm-agent-plugins/apm-api-plugin/src/test/java/co/elastic/apm/api/AnnotationInheritanceTest.java @@ -31,6 +31,11 @@ import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.doReturn; @@ -94,6 +99,7 @@ void testClassWithoutAnnotations() { @TestInstance(TestInstance.Lifecycle.PER_CLASS) class EnabledPublicApiAnnotationInheritance { + @BeforeAll void beforeAll() { init(true); @@ -104,6 +110,13 @@ void afterAll() { reset(); } + private TestClassBase createTestClassInstance(Class testClass) + throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { + Constructor declaredConstructor = testClass.getDeclaredConstructor(); + declaredConstructor.setAccessible(true); + return declaredConstructor.newInstance(); + } + @Test void testClassWithAnnotations() { invokeApiMethods(new ClassWithAnnotations()); @@ -111,36 +124,43 @@ void testClassWithAnnotations() { assertThat(reporter.getSpans()).hasSize(1); } - @Test - void testInheritedCaptureTransaction() { - new ClassWithoutAnnotations().captureTransaction(); - checkTransaction("ClassWithoutAnnotations#captureTransaction"); + @ParameterizedTest + @ValueSource(classes = {ClassWithoutAnnotations.class, TransitiveClassWithoutAnnotations.class, InterfaceImplementor.class}) + void testInheritedCaptureTransaction(Class testClass) throws Exception { + TestClassBase instance = createTestClassInstance(testClass); + instance.captureTransaction(); + checkTransaction(testClass.getSimpleName() + "#captureTransaction"); } - @Test - void testInheritedCaptureSpan() { + + @ParameterizedTest + @ValueSource(classes = {ClassWithoutAnnotations.class, TransitiveClassWithoutAnnotations.class, InterfaceImplementor.class}) + void testInheritedCaptureSpan(Class testClass) throws Exception { + TestClassBase instance = createTestClassInstance(testClass); Transaction transaction = ElasticApm.startTransaction(); try (Scope scope = transaction.activate()) { - new ClassWithoutAnnotations().captureSpan(); + instance.captureSpan(); } transaction.end(); - checkSpan("ClassWithoutAnnotations#captureSpan"); + checkSpan(testClass.getSimpleName() + "#captureSpan"); } - @Test - void testInheritedTracedWithoutActiveTransaction() { - new ClassWithoutAnnotations().traced(); - checkTransaction("ClassWithoutAnnotations#traced"); + @ParameterizedTest + @ValueSource(classes = {ClassWithoutAnnotations.class, TransitiveClassWithoutAnnotations.class, InterfaceImplementor.class}) + void testInheritedTracedWithoutActiveTransaction(Class testClass) throws Exception { + createTestClassInstance(testClass).traced(); + checkTransaction(testClass.getSimpleName() + "#traced"); } - @Test - void testInheritedTracedWithActiveTransaction() { + @ParameterizedTest + @ValueSource(classes = {ClassWithoutAnnotations.class, TransitiveClassWithoutAnnotations.class, InterfaceImplementor.class}) + void testInheritedTracedWithActiveTransaction(Class testClass) throws Exception { Transaction transaction = ElasticApm.startTransaction(); try (Scope scope = transaction.activate()) { - new ClassWithoutAnnotations().traced(); + createTestClassInstance(testClass).traced(); } transaction.end(); - checkSpan("ClassWithoutAnnotations#traced"); + checkSpan(testClass.getSimpleName() + "#traced"); } private void checkTransaction(String name) { @@ -166,7 +186,16 @@ private void invokeApiMethods(ClassWithAnnotations classWithAnnotations) { classWithAnnotations.traced(); } - static class ClassWithAnnotations { + + abstract static class TestClassBase { + abstract void captureTransaction(); + + abstract void captureSpan(); + + abstract void traced(); + } + + static class ClassWithAnnotations extends TestClassBase { @CaptureTransaction void captureTransaction() { } @@ -193,4 +222,46 @@ void captureSpan() { void traced() { } } + + static class EmptyClass extends ClassWithAnnotations { + } + + static class TransitiveClassWithoutAnnotations extends EmptyClass { + @Override + void captureTransaction() { + } + + @Override + void captureSpan() { + } + + @Override + void traced() { + } + } + + interface InterfaceWithAnnotations { + @CaptureTransaction + void captureTransaction(); + + @CaptureSpan + void captureSpan(); + + @Traced + void traced(); + } + + static class InterfaceImplementor extends TestClassBase implements InterfaceWithAnnotations { + + public void captureTransaction() { + } + + public void captureSpan() { + } + + @Override + public void traced() { + } + } + } diff --git a/apm-agent-plugins/apm-asynchttpclient-plugin/pom.xml b/apm-agent-plugins/apm-asynchttpclient-plugin/pom.xml index 0817cb480e..963d44ac35 100644 --- a/apm-agent-plugins/apm-asynchttpclient-plugin/pom.xml +++ b/apm-agent-plugins/apm-asynchttpclient-plugin/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-asynchttpclient-plugin diff --git a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/pom.xml b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/pom.xml index 5e65f9695d..2befe6bdad 100644 --- a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/pom.xml +++ b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/pom.xml @@ -3,7 +3,7 @@ apm-aws-sdk co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/pom.xml b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/pom.xml index 4c5bd4cadd..6297842308 100644 --- a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/pom.xml +++ b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/pom.xml @@ -3,7 +3,7 @@ apm-aws-sdk co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 @@ -13,7 +13,7 @@ ${project.basedir}/../../.. - 2.25.0 + 2.25.21 2.0.0 8 diff --git a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-common/pom.xml b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-common/pom.xml index 62ecad9a73..a48a31ae96 100644 --- a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-common/pom.xml +++ b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-common/pom.xml @@ -3,7 +3,7 @@ apm-aws-sdk co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugins/apm-aws-sdk/pom.xml b/apm-agent-plugins/apm-aws-sdk/pom.xml index 9acd6ab199..6196ff5d40 100644 --- a/apm-agent-plugins/apm-aws-sdk/pom.xml +++ b/apm-agent-plugins/apm-aws-sdk/pom.xml @@ -3,7 +3,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugins/apm-awslambda-plugin/pom.xml b/apm-agent-plugins/apm-awslambda-plugin/pom.xml index 6ecc7e3cf0..405bb4a42b 100644 --- a/apm-agent-plugins/apm-awslambda-plugin/pom.xml +++ b/apm-agent-plugins/apm-awslambda-plugin/pom.xml @@ -3,7 +3,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 @@ -17,12 +17,6 @@ - - - ${project.groupId} - apm-agent-core - ${project.version} - com.amazonaws aws-lambda-java-core diff --git a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/AbstractAwsLambdaHandlerInstrumentation.java b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/AbstractAwsLambdaHandlerInstrumentation.java index d447a53d40..a79ee7c37c 100644 --- a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/AbstractAwsLambdaHandlerInstrumentation.java +++ b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/AbstractAwsLambdaHandlerInstrumentation.java @@ -18,8 +18,8 @@ */ package co.elastic.apm.agent.awslambda; -import co.elastic.apm.agent.impl.ElasticApmTracer; import co.elastic.apm.agent.sdk.ElasticApmInstrumentation; +import co.elastic.apm.agent.tracer.Tracer; import co.elastic.apm.agent.tracer.configuration.ServerlessConfiguration; import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.matcher.ElementMatcher; @@ -41,7 +41,7 @@ public abstract class AbstractAwsLambdaHandlerInstrumentation extends ElasticApm @Nullable protected String handlerMethodName; - public AbstractAwsLambdaHandlerInstrumentation(ElasticApmTracer tracer) { + public AbstractAwsLambdaHandlerInstrumentation(Tracer tracer) { serverlessConfiguration = tracer.getConfig(ServerlessConfiguration.class); String awsLambdaHandler = serverlessConfiguration.getAwsLambdaHandler(); //noinspection ConstantConditions diff --git a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/RequestHandlerInstrumentation.java b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/RequestHandlerInstrumentation.java index 0d443b1316..a709840e7e 100644 --- a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/RequestHandlerInstrumentation.java +++ b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/RequestHandlerInstrumentation.java @@ -20,8 +20,8 @@ import co.elastic.apm.agent.awslambda.helper.AWSEventsHelper; import co.elastic.apm.agent.awslambda.helper.PlainTransactionHelper; -import co.elastic.apm.agent.impl.ElasticApmTracer; -import co.elastic.apm.agent.impl.transaction.Transaction; +import co.elastic.apm.agent.tracer.Tracer; +import co.elastic.apm.agent.tracer.Transaction; import com.amazonaws.services.lambda.runtime.Context; import net.bytebuddy.asm.Advice; import net.bytebuddy.description.method.MethodDescription; @@ -35,7 +35,7 @@ public class RequestHandlerInstrumentation extends AbstractAwsLambdaHandlerInstrumentation { - public RequestHandlerInstrumentation(ElasticApmTracer tracer) { + public RequestHandlerInstrumentation(Tracer tracer) { super(tracer); } @@ -70,8 +70,8 @@ public static Object handlerEnter(@Nullable @Advice.Argument(value = 0) Object i public static void handlerExit(@Nullable @Advice.Enter Object transactionObj, @Nullable @Advice.Thrown Throwable thrown, @Nullable @Advice.Return Object output) { - if (transactionObj instanceof Transaction) { - Transaction transaction = (Transaction) transactionObj; + if (transactionObj instanceof Transaction) { + Transaction transaction = (Transaction) transactionObj; if (output != null && output.getClass().getName().startsWith("com.amazonaws.services.lambda.runtime.events")) { // handler uses aws events, it's safe to assume that the AWS events classes are available diff --git a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/RequestStreamHandlerInstrumentation.java b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/RequestStreamHandlerInstrumentation.java index a32e9a5246..e97fe84d19 100644 --- a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/RequestStreamHandlerInstrumentation.java +++ b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/RequestStreamHandlerInstrumentation.java @@ -19,8 +19,8 @@ package co.elastic.apm.agent.awslambda; import co.elastic.apm.agent.awslambda.helper.PlainTransactionHelper; -import co.elastic.apm.agent.impl.ElasticApmTracer; -import co.elastic.apm.agent.impl.transaction.Transaction; +import co.elastic.apm.agent.tracer.Tracer; +import co.elastic.apm.agent.tracer.Transaction; import com.amazonaws.services.lambda.runtime.Context; import net.bytebuddy.asm.Advice; import net.bytebuddy.description.method.MethodDescription; @@ -35,7 +35,7 @@ public class RequestStreamHandlerInstrumentation extends AbstractAwsLambdaHandlerInstrumentation { - public RequestStreamHandlerInstrumentation(ElasticApmTracer tracer) { + public RequestStreamHandlerInstrumentation(Tracer tracer) { super(tracer); } @@ -65,8 +65,8 @@ public static Object handlerEnter(@Advice.Argument(value = 0) InputStream inputS @Advice.OnMethodExit(suppress = Throwable.class, inline = false, onThrowable = Throwable.class) public static void handlerExit(@Nullable @Advice.Enter Object transactionObj, @Nullable @Advice.Thrown Throwable thrown) { - if (transactionObj instanceof Transaction) { - Transaction transaction = (Transaction) transactionObj; + if (transactionObj instanceof Transaction) { + Transaction transaction = (Transaction) transactionObj; PlainTransactionHelper.getInstance().finalizeTransaction(transaction, null, thrown); } } diff --git a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/APIGatewayProxyV1TransactionHelper.java b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/APIGatewayProxyV1TransactionHelper.java index d2d4589d9c..a923707937 100644 --- a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/APIGatewayProxyV1TransactionHelper.java +++ b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/APIGatewayProxyV1TransactionHelper.java @@ -19,80 +19,48 @@ package co.elastic.apm.agent.awslambda.helper; import co.elastic.apm.agent.awslambda.MapTextHeaderGetter; -import co.elastic.apm.agent.impl.ElasticApmTracer; -import co.elastic.apm.agent.tracer.GlobalTracer; -import co.elastic.apm.agent.impl.transaction.Transaction; import co.elastic.apm.agent.sdk.internal.util.PrivilegedActionUtils; +import co.elastic.apm.agent.tracer.GlobalTracer; +import co.elastic.apm.agent.tracer.Tracer; +import co.elastic.apm.agent.tracer.Transaction; import com.amazonaws.services.lambda.runtime.Context; import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent; import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent; import javax.annotation.Nullable; -import java.util.Map; public class APIGatewayProxyV1TransactionHelper extends AbstractAPIGatewayTransactionHelper { @Nullable private static APIGatewayProxyV1TransactionHelper INSTANCE; - private APIGatewayProxyV1TransactionHelper(ElasticApmTracer tracer) { + private APIGatewayProxyV1TransactionHelper(Tracer tracer) { super(tracer); } public static APIGatewayProxyV1TransactionHelper getInstance() { if (INSTANCE == null) { - INSTANCE = new APIGatewayProxyV1TransactionHelper(GlobalTracer.get().require(ElasticApmTracer.class)); + INSTANCE = new APIGatewayProxyV1TransactionHelper(GlobalTracer.get()); } return INSTANCE; } @Override - protected Transaction doStartTransaction(APIGatewayProxyRequestEvent apiGatewayEvent, Context lambdaContext) { - Transaction transaction = tracer.startChildTransaction(apiGatewayEvent.getHeaders(), MapTextHeaderGetter.INSTANCE, PrivilegedActionUtils.getClassLoader(apiGatewayEvent.getClass())); - String host = getHost(apiGatewayEvent); + protected Transaction doStartTransaction(APIGatewayProxyRequestEvent apiGatewayEvent, Context lambdaContext) { + Transaction transaction = tracer.startChildTransaction(apiGatewayEvent.getHeaders(), MapTextHeaderGetter.INSTANCE, PrivilegedActionUtils.getClassLoader(apiGatewayEvent.getClass())); if (null != transaction) { + String host = getHost(apiGatewayEvent.getHeaders()); + fillHttpRequestData(transaction, getHttpMethod(apiGatewayEvent), apiGatewayEvent.getHeaders(), host, - apiGatewayEvent.getRequestContext().getPath(), getQueryString(apiGatewayEvent), apiGatewayEvent.getBody()); + apiGatewayEvent.getRequestContext().getPath(), getQueryString(apiGatewayEvent.getQueryStringParameters()), apiGatewayEvent.getBody()); } return transaction; } - @Nullable - private String getHost(APIGatewayProxyRequestEvent apiGatewayEvent) { - String host = null; - if (null != apiGatewayEvent.getHeaders()) { - host = apiGatewayEvent.getHeaders().get("host"); - if (null == host) { - host = apiGatewayEvent.getHeaders().get("Host"); - } - } - return host; - } - - @Nullable - private String getQueryString(APIGatewayProxyRequestEvent apiGatewayEvent) { - Map queryParameters = apiGatewayEvent.getQueryStringParameters(); - if (null != queryParameters && !queryParameters.isEmpty()) { - StringBuilder queryString = new StringBuilder(); - int i = 0; - for (Map.Entry entry : apiGatewayEvent.getQueryStringParameters().entrySet()) { - if (i > 0) { - queryString.append('&'); - } - queryString.append(entry.getKey()); - queryString.append('='); - queryString.append(entry.getValue()); - i++; - } - return queryString.toString(); - } - return null; - } - @Override - public void captureOutputForTransaction(Transaction transaction, APIGatewayProxyResponseEvent responseEvent) { + public void captureOutputForTransaction(Transaction transaction, APIGatewayProxyResponseEvent responseEvent) { Integer statusCode = responseEvent.getStatusCode(); if (statusCode == null) { statusCode = 0; @@ -101,14 +69,23 @@ public void captureOutputForTransaction(Transaction transaction, APIGatewayProxy } @Override - protected void setTransactionTriggerData(Transaction transaction, APIGatewayProxyRequestEvent apiGatewayRequest) { + protected void setTransactionTriggerData(Transaction transaction, APIGatewayProxyRequestEvent apiGatewayRequest) { super.setTransactionTriggerData(transaction, apiGatewayRequest); APIGatewayProxyRequestEvent.ProxyRequestContext rContext = apiGatewayRequest.getRequestContext(); if (null != rContext) { setApiGatewayContextData(transaction, rContext.getRequestId(), rContext.getApiId(), - getHost(apiGatewayRequest), rContext.getAccountId()); + getHost(apiGatewayRequest.getHeaders()), rContext.getAccountId()); + } + } + + @Override + public String getDomainName(APIGatewayProxyRequestEvent apiGatewayRequest) { + APIGatewayProxyRequestEvent.ProxyRequestContext rContext = apiGatewayRequest.getRequestContext(); + if (null == rContext) { + return null; } + return rContext.getDomainName(); } @Override @@ -140,4 +117,5 @@ protected String getStage(APIGatewayProxyRequestEvent event) { protected String getResourcePath(APIGatewayProxyRequestEvent event) { return event.getRequestContext().getResourcePath(); } + } diff --git a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/APIGatewayProxyV2TransactionHelper.java b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/APIGatewayProxyV2TransactionHelper.java index ec7ed0db69..0ba8476c22 100644 --- a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/APIGatewayProxyV2TransactionHelper.java +++ b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/APIGatewayProxyV2TransactionHelper.java @@ -19,9 +19,9 @@ package co.elastic.apm.agent.awslambda.helper; import co.elastic.apm.agent.awslambda.MapTextHeaderGetter; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.tracer.Tracer; import co.elastic.apm.agent.tracer.GlobalTracer; -import co.elastic.apm.agent.impl.transaction.Transaction; +import co.elastic.apm.agent.tracer.Transaction; import co.elastic.apm.agent.sdk.internal.util.PrivilegedActionUtils; import com.amazonaws.services.lambda.runtime.Context; import com.amazonaws.services.lambda.runtime.events.APIGatewayV2HTTPEvent; @@ -33,20 +33,20 @@ public class APIGatewayProxyV2TransactionHelper extends AbstractAPIGatewayTransa @Nullable private static APIGatewayProxyV2TransactionHelper INSTANCE; - private APIGatewayProxyV2TransactionHelper(ElasticApmTracer tracer) { + private APIGatewayProxyV2TransactionHelper(Tracer tracer) { super(tracer); } public static APIGatewayProxyV2TransactionHelper getInstance() { if (INSTANCE == null) { - INSTANCE = new APIGatewayProxyV2TransactionHelper(GlobalTracer.get().require(ElasticApmTracer.class)); + INSTANCE = new APIGatewayProxyV2TransactionHelper(GlobalTracer.get()); } return INSTANCE; } @Override - protected Transaction doStartTransaction(APIGatewayV2HTTPEvent apiGatewayEvent, Context lambdaContext) { - Transaction transaction = tracer.startChildTransaction(apiGatewayEvent.getHeaders(), MapTextHeaderGetter.INSTANCE, PrivilegedActionUtils.getClassLoader(apiGatewayEvent.getClass())); + protected Transaction doStartTransaction(APIGatewayV2HTTPEvent apiGatewayEvent, Context lambdaContext) { + Transaction transaction = tracer.startChildTransaction(apiGatewayEvent.getHeaders(), MapTextHeaderGetter.INSTANCE, PrivilegedActionUtils.getClassLoader(apiGatewayEvent.getClass())); APIGatewayV2HTTPEvent.RequestContext requestContext = apiGatewayEvent.getRequestContext(); if (transaction != null) { @@ -60,12 +60,12 @@ protected Transaction doStartTransaction(APIGatewayV2HTTPEvent apiGatewayEvent, } @Override - public void captureOutputForTransaction(Transaction transaction, APIGatewayV2HTTPResponse responseEvent) { + public void captureOutputForTransaction(Transaction transaction, APIGatewayV2HTTPResponse responseEvent) { fillHttpResponseData(transaction, responseEvent.getHeaders(), responseEvent.getStatusCode()); } @Override - protected void setTransactionTriggerData(Transaction transaction, APIGatewayV2HTTPEvent apiGatewayRequest) { + protected void setTransactionTriggerData(Transaction transaction, APIGatewayV2HTTPEvent apiGatewayRequest) { super.setTransactionTriggerData(transaction, apiGatewayRequest); APIGatewayV2HTTPEvent.RequestContext rContext = apiGatewayRequest.getRequestContext(); setApiGatewayContextData(transaction, rContext.getRequestId(), rContext.getApiId(), @@ -112,4 +112,11 @@ protected String getResourcePath(APIGatewayV2HTTPEvent event) { } return routeKey; } + + @Nullable + @Override + String getDomainName(APIGatewayV2HTTPEvent apiGatewayRequest) { + APIGatewayV2HTTPEvent.RequestContext requestContext = apiGatewayRequest.getRequestContext(); + return requestContext != null ? requestContext.getDomainName() : null; + } } diff --git a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/AWSEventsHelper.java b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/AWSEventsHelper.java index 9ec285ad99..ae4f268ac8 100644 --- a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/AWSEventsHelper.java +++ b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/AWSEventsHelper.java @@ -18,12 +18,14 @@ */ package co.elastic.apm.agent.awslambda.helper; -import co.elastic.apm.agent.impl.transaction.Transaction; +import co.elastic.apm.agent.tracer.Transaction; import com.amazonaws.services.lambda.runtime.Context; import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent; import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent; import com.amazonaws.services.lambda.runtime.events.APIGatewayV2HTTPEvent; import com.amazonaws.services.lambda.runtime.events.APIGatewayV2HTTPResponse; +import com.amazonaws.services.lambda.runtime.events.ApplicationLoadBalancerRequestEvent; +import com.amazonaws.services.lambda.runtime.events.ApplicationLoadBalancerResponseEvent; import com.amazonaws.services.lambda.runtime.events.S3Event; import com.amazonaws.services.lambda.runtime.events.SNSEvent; import com.amazonaws.services.lambda.runtime.events.SQSEvent; @@ -33,7 +35,7 @@ public class AWSEventsHelper { @Nullable - public static Transaction startTransaction(Object input, Context lambdaContext) { + public static Transaction startTransaction(Object input, Context lambdaContext) { if (input instanceof APIGatewayV2HTTPEvent && ((APIGatewayV2HTTPEvent) input).getRequestContext() != null && ((APIGatewayV2HTTPEvent) input).getRequestContext().getHttp() != null) { // API Gateway V2 trigger @@ -50,15 +52,20 @@ public static Transaction startTransaction(Object input, Context lambdaContext) } else if (input instanceof S3Event) { // S3 event trigger return S3TransactionHelper.getInstance().startTransaction((S3Event) input, lambdaContext); + } else if (input instanceof ApplicationLoadBalancerRequestEvent) { + // Load Balancer Request event trigger + return ApplicationLoadBalancerRequestTransactionHelper.getInstance().startTransaction((ApplicationLoadBalancerRequestEvent) input, lambdaContext); } return PlainTransactionHelper.getInstance().startTransaction(input, lambdaContext); } - public static void finalizeTransaction(Transaction transaction, Object output, @Nullable Throwable thrown) { + public static void finalizeTransaction(Transaction transaction, Object output, @Nullable Throwable thrown) { if (output instanceof APIGatewayV2HTTPResponse) { APIGatewayProxyV2TransactionHelper.getInstance().finalizeTransaction(transaction, (APIGatewayV2HTTPResponse) output, thrown); } else if (output instanceof APIGatewayProxyResponseEvent) { APIGatewayProxyV1TransactionHelper.getInstance().finalizeTransaction(transaction, (APIGatewayProxyResponseEvent) output, thrown); + } else if (output instanceof ApplicationLoadBalancerResponseEvent) { + ApplicationLoadBalancerRequestTransactionHelper.getInstance().finalizeTransaction(transaction, (ApplicationLoadBalancerResponseEvent) output, thrown); } else { // use PlainTransactionHelper for all triggers that do not expect an output PlainTransactionHelper.getInstance().finalizeTransaction(transaction, output, thrown); diff --git a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/AbstractAPIGatewayTransactionHelper.java b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/AbstractAPIGatewayTransactionHelper.java index 72c1d0eecb..b8e2f30e0c 100644 --- a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/AbstractAPIGatewayTransactionHelper.java +++ b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/AbstractAPIGatewayTransactionHelper.java @@ -18,17 +18,17 @@ */ package co.elastic.apm.agent.awslambda.helper; -import co.elastic.apm.agent.impl.ElasticApmTracer; -import co.elastic.apm.agent.impl.context.CloudOrigin; -import co.elastic.apm.agent.impl.context.Request; -import co.elastic.apm.agent.impl.context.Response; -import co.elastic.apm.agent.impl.context.ServiceOrigin; -import co.elastic.apm.agent.tracer.util.ResultUtil; -import co.elastic.apm.agent.impl.transaction.Transaction; import co.elastic.apm.agent.common.util.WildcardMatcher; import co.elastic.apm.agent.sdk.logging.Logger; import co.elastic.apm.agent.sdk.logging.LoggerFactory; import co.elastic.apm.agent.tracer.AbstractSpan; +import co.elastic.apm.agent.tracer.ServiceOrigin; +import co.elastic.apm.agent.tracer.Tracer; +import co.elastic.apm.agent.tracer.Transaction; +import co.elastic.apm.agent.tracer.metadata.CloudOrigin; +import co.elastic.apm.agent.tracer.metadata.Request; +import co.elastic.apm.agent.tracer.metadata.Response; +import co.elastic.apm.agent.tracer.util.ResultUtil; import com.amazonaws.services.lambda.runtime.Context; import javax.annotation.Nullable; @@ -47,13 +47,13 @@ public abstract class AbstractAPIGatewayTransactionHelper extends Abstract private static final Set METHODS_WITH_BODY = new HashSet<>(Arrays.asList("POST", "PUT", "PATCH", "DELETE")); private static final String CONTENT_TYPE_FROM_URLENCODED = "application/x-www-form-urlencoded"; - protected AbstractAPIGatewayTransactionHelper(ElasticApmTracer tracer) { + protected AbstractAPIGatewayTransactionHelper(Tracer tracer) { super(tracer); } protected abstract String getApiGatewayVersion(); - protected void fillHttpRequestData(Transaction transaction, @Nullable String httpMethod, @Nullable Map headers, @Nullable String serverName, @Nullable String path, @Nullable String queryString, @Nullable String body) { + protected void fillHttpRequestData(Transaction transaction, @Nullable String httpMethod, @Nullable Map headers, @Nullable String serverName, @Nullable String path, @Nullable String queryString, @Nullable String body) { Request request = transaction.getContext().getRequest(); request.withMethod(httpMethod); fillUrlRelatedFields(request, serverName, path, queryString); @@ -67,7 +67,39 @@ protected void fillHttpRequestData(Transaction transaction, @Nullable String htt } } - protected void fillHttpResponseData(Transaction transaction, @Nullable Map headers, int statusCode) { + @Nullable + protected String getHost(@Nullable Map headers) { + if (null == headers) { + return null; + } + String host = headers.get("host"); + if (null == host) { + host = headers.get("Host"); + } + return host; + } + + @Nullable + protected String getQueryString(@Nullable Map queryParameters) { + if (null == queryParameters || queryParameters.isEmpty()) { + return null; + } + StringBuilder queryString = new StringBuilder(); + int i = 0; + for (Map.Entry entry : queryParameters.entrySet()) { + if (i > 0) { + queryString.append('&'); + } + queryString.append(entry.getKey()); + queryString.append('='); + queryString.append(entry.getValue()); + i++; + } + return queryString.toString(); + } + + + protected void fillHttpResponseData(Transaction transaction, @Nullable Map headers, int statusCode) { Response response = transaction.getContext().getResponse(); response.withFinished(true); if (transaction.isSampled() && null != headers && isCaptureHeaders()) { @@ -81,18 +113,12 @@ protected void fillHttpResponseData(Transaction transaction, @Nullable Map transaction, @Nullable String method, @Nullable String contentTypeHeader) { Request request = transaction.getContext().getRequest(); if (hasBody(contentTypeHeader, method)) { if (coreConfiguration.getCaptureBody() != OFF @@ -127,16 +153,31 @@ private boolean hasBody(@Nullable String contentTypeHeader, @Nullable String met } @Override - protected void setTransactionTriggerData(Transaction transaction, I apiGatewayRequest) { + protected void setTransactionTriggerData(Transaction transaction, I apiGatewayRequest) { transaction.withType(TRANSACTION_TYPE); CloudOrigin cloudOrigin = transaction.getContext().getCloudOrigin(); - cloudOrigin.withServiceName("api gateway"); + if (isLambdaUrl(apiGatewayRequest)) { + cloudOrigin.withServiceName("lambda url"); + } else { + cloudOrigin.withServiceName("api gateway"); + } cloudOrigin.withProvider("aws"); transaction.getFaas().getTrigger().withType("http"); transaction.getContext().getServiceOrigin().withVersion(getApiGatewayVersion()); } - protected void setApiGatewayContextData(Transaction transaction, @Nullable String requestId, @Nullable String apiId, + private boolean isLambdaUrl(I apiGatewayRequest) { + String domainName = getDomainName(apiGatewayRequest); + if (null == domainName) { + return false; + } + return domainName.contains(".lambda-url."); + } + + @Nullable + abstract String getDomainName(I apiGatewayRequest); + + protected void setApiGatewayContextData(Transaction transaction, @Nullable String requestId, @Nullable String apiId, @Nullable String domainName, @Nullable String accountId) { transaction.getFaas().getTrigger().withRequestId(requestId); ServiceOrigin serviceOrigin = transaction.getContext().getServiceOrigin(); @@ -146,7 +187,7 @@ protected void setApiGatewayContextData(Transaction transaction, @Nullable Strin transaction.getContext().getCloudOrigin().withAccountId(accountId); } - private void setRequestHeaders(Transaction transaction, Map headers) { + private void setRequestHeaders(Transaction transaction, Map headers) { final Request req = transaction.getContext().getRequest(); if (transaction.isSampled() && isCaptureHeaders()) { for (Map.Entry headerEntry : headers.entrySet()) { @@ -156,7 +197,7 @@ private void setRequestHeaders(Transaction transaction, Map head } @Override - protected void setTransactionName(Transaction transaction, I event, Context lambdaContext) { + protected void setTransactionName(Transaction transaction, I event, Context lambdaContext) { StringBuilder transactionName = transaction.getAndOverrideName(AbstractSpan.PRIORITY_HIGH_LEVEL_FRAMEWORK); if (transactionName != null) { String httpMethod = getHttpMethod(event); diff --git a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/AbstractLambdaTransactionHelper.java b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/AbstractLambdaTransactionHelper.java index 8c61317ce1..2763e7423b 100644 --- a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/AbstractLambdaTransactionHelper.java +++ b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/AbstractLambdaTransactionHelper.java @@ -18,50 +18,42 @@ */ package co.elastic.apm.agent.awslambda.helper; -import co.elastic.apm.agent.bci.ElasticApmAgent; -import co.elastic.apm.agent.bci.InstrumentationStats; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.tracer.Tracer; +import co.elastic.apm.agent.tracer.Transaction; import co.elastic.apm.agent.tracer.configuration.CoreConfiguration; import co.elastic.apm.agent.tracer.configuration.ServerlessConfiguration; import co.elastic.apm.agent.tracer.configuration.WebConfiguration; -import co.elastic.apm.agent.impl.metadata.FaaSMetaDataExtension; -import co.elastic.apm.agent.impl.metadata.Framework; -import co.elastic.apm.agent.impl.metadata.NameAndIdField; -import co.elastic.apm.agent.impl.transaction.Transaction; import co.elastic.apm.agent.sdk.logging.Logger; import co.elastic.apm.agent.sdk.logging.LoggerFactory; import co.elastic.apm.agent.tracer.AbstractSpan; -import co.elastic.apm.agent.sdk.internal.util.LoggerUtils; import co.elastic.apm.agent.sdk.internal.util.VersionUtils; import com.amazonaws.services.lambda.runtime.Context; import com.amazonaws.services.lambda.runtime.RequestHandler; import javax.annotation.Nullable; -import java.util.concurrent.TimeUnit; public abstract class AbstractLambdaTransactionHelper { private static final Logger logger = LoggerFactory.getLogger(AbstractLambdaTransactionHelper.class); - private static final Logger enabledInstrumentationsLogger = LoggerUtils.logOnce(logger); - protected final ElasticApmTracer tracer; + protected final Tracer tracer; protected final ServerlessConfiguration serverlessConfiguration; protected final CoreConfiguration coreConfiguration; protected final WebConfiguration webConfiguration; - protected AbstractLambdaTransactionHelper(ElasticApmTracer tracer) { + protected AbstractLambdaTransactionHelper(Tracer tracer) { this.tracer = tracer; this.coreConfiguration = tracer.getConfig(CoreConfiguration.class); this.webConfiguration = tracer.getConfig(WebConfiguration.class); this.serverlessConfiguration = tracer.getConfig(ServerlessConfiguration.class); } - protected abstract void setTransactionTriggerData(Transaction transaction, I input); + protected abstract void setTransactionTriggerData(Transaction transaction, I input); @Nullable - protected abstract Transaction doStartTransaction(I input, Context lambdaContext); + protected abstract Transaction doStartTransaction(I input, Context lambdaContext); - protected abstract void captureOutputForTransaction(Transaction transaction, O output); + protected abstract void captureOutputForTransaction(Transaction transaction, O output); private static boolean coldStart = true; @@ -69,13 +61,13 @@ protected AbstractLambdaTransactionHelper(ElasticApmTracer tracer) { private String functionArn; @Nullable - public Transaction startTransaction(I input, Context lambdaContext) { + public Transaction startTransaction(I input, Context lambdaContext) { boolean isColdStart = coldStart; if (isColdStart) { completeMetaData(lambdaContext); coldStart = false; } - Transaction transaction = doStartTransaction(input, lambdaContext); + Transaction transaction = doStartTransaction(input, lambdaContext); if (null != transaction) { transaction.getFaas() .withId(getFaasId(lambdaContext)) @@ -104,7 +96,7 @@ private String getFaasId(Context lambdaContext) { return functionArn; } - public void finalizeTransaction(Transaction transaction, @Nullable O output, @Nullable Throwable thrown) { + public void finalizeTransaction(Transaction transaction, @Nullable O output, @Nullable Throwable thrown) { try { if (null != output) { captureOutputForTransaction(transaction, output); @@ -118,23 +110,7 @@ public void finalizeTransaction(Transaction transaction, @Nullable O output, @Nu } finally { transaction.deactivate().end(); } - long flushTimeout = serverlessConfiguration.getDataFlushTimeout(); - try { - if (!tracer.getReporter().flush(flushTimeout, TimeUnit.MILLISECONDS, true)) { - logger.error("APM data flush haven't completed within {} milliseconds.", flushTimeout); - } - } catch (Exception e) { - logger.error("An error occurred on flushing APM data.", e); - } - - logEnabledInstrumentations(); - } - - private void logEnabledInstrumentations() { - if (enabledInstrumentationsLogger.isInfoEnabled()) { - InstrumentationStats instrumentationStats = ElasticApmAgent.getInstrumentationStats(); - enabledInstrumentationsLogger.info("Used instrumentation groups: {}", instrumentationStats.getUsedInstrumentationGroups()); - } + tracer.flush(); } private void completeMetaData(Context lambdaContext) { @@ -149,17 +125,13 @@ private void completeMetaData(Context lambdaContext) { lambdaLibVersion = "unknown"; } - tracer.getMetaDataFuture().getFaaSMetaDataExtensionFuture().complete(new FaaSMetaDataExtension( - new Framework("AWS Lambda", lambdaLibVersion), - new NameAndIdField(null, accountId), - region - )); + tracer.completeMetaData("AWS Lambda", lambdaLibVersion, accountId, region); } catch (Exception e) { logger.error("Failed updating metadata for first lambda execution!", e); } } - protected void setTransactionName(Transaction transaction, I event, Context lambdaContext) { + protected void setTransactionName(Transaction transaction, I event, Context lambdaContext) { StringBuilder transactionName = transaction.getAndOverrideName(AbstractSpan.PRIORITY_HIGH_LEVEL_FRAMEWORK); if (transactionName != null) { transactionName.append(lambdaContext.getFunctionName()); diff --git a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/AbstractMessageBasedTransactionHelper.java b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/AbstractMessageBasedTransactionHelper.java index 328d88febf..68071da7bc 100644 --- a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/AbstractMessageBasedTransactionHelper.java +++ b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/AbstractMessageBasedTransactionHelper.java @@ -18,12 +18,12 @@ */ package co.elastic.apm.agent.awslambda.helper; -import co.elastic.apm.agent.impl.ElasticApmTracer; -import co.elastic.apm.agent.impl.context.CloudOrigin; -import co.elastic.apm.agent.impl.context.ServiceOrigin; -import co.elastic.apm.agent.impl.transaction.Transaction; import co.elastic.apm.agent.tracer.AbstractSpan; import co.elastic.apm.agent.sdk.internal.util.PrivilegedActionUtils; +import co.elastic.apm.agent.tracer.ServiceOrigin; +import co.elastic.apm.agent.tracer.Tracer; +import co.elastic.apm.agent.tracer.Transaction; +import co.elastic.apm.agent.tracer.metadata.CloudOrigin; import com.amazonaws.services.lambda.runtime.Context; import javax.annotation.Nullable; @@ -31,7 +31,7 @@ public abstract class AbstractMessageBasedTransactionHelper extends AbstractLambdaTransactionHelper { protected static final String TRANSACTION_TYPE = "messaging"; - protected AbstractMessageBasedTransactionHelper(ElasticApmTracer tracer) { + protected AbstractMessageBasedTransactionHelper(Tracer tracer) { super(tracer); } @@ -50,23 +50,23 @@ protected AbstractMessageBasedTransactionHelper(ElasticApmTracer tracer) { @Nullable @Override - protected Transaction doStartTransaction(I event, Context lambdaContext) { - Transaction transaction = tracer.startRootTransaction(PrivilegedActionUtils.getClassLoader(lambdaContext.getClass())); + protected Transaction doStartTransaction(I event, Context lambdaContext) { + Transaction transaction = tracer.startRootTransaction(PrivilegedActionUtils.getClassLoader(lambdaContext.getClass())); if (null != transaction) { addSpanLinks(transaction, event); } return transaction; } - protected abstract void addSpanLinks(Transaction transaction, I event); + protected abstract void addSpanLinks(Transaction transaction, I event); @Override - public void captureOutputForTransaction(Transaction transaction, O output) { + public void captureOutputForTransaction(Transaction transaction, O output) { // Nothing to do here } @Override - protected void setTransactionTriggerData(Transaction transaction, I event) { + protected void setTransactionTriggerData(Transaction transaction, I event) { R record = getFirstRecord(event); transaction.withType(TRANSACTION_TYPE); diff --git a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/ApplicationLoadBalancerRequestTransactionHelper.java b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/ApplicationLoadBalancerRequestTransactionHelper.java new file mode 100644 index 0000000000..9d1cf9b474 --- /dev/null +++ b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/ApplicationLoadBalancerRequestTransactionHelper.java @@ -0,0 +1,164 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. 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. + */ +package co.elastic.apm.agent.awslambda.helper; + +import co.elastic.apm.agent.awslambda.MapTextHeaderGetter; +import co.elastic.apm.agent.sdk.internal.util.PrivilegedActionUtils; +import co.elastic.apm.agent.tracer.*; +import co.elastic.apm.agent.tracer.metadata.CloudOrigin; +import com.amazonaws.services.lambda.runtime.Context; +import com.amazonaws.services.lambda.runtime.events.ApplicationLoadBalancerRequestEvent; +import com.amazonaws.services.lambda.runtime.events.ApplicationLoadBalancerResponseEvent; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.util.Map; + +public class ApplicationLoadBalancerRequestTransactionHelper extends AbstractAPIGatewayTransactionHelper { + @Nullable + private static ApplicationLoadBalancerRequestTransactionHelper INSTANCE; + + private ApplicationLoadBalancerRequestTransactionHelper(Tracer tracer) { + super(tracer); + } + + public static ApplicationLoadBalancerRequestTransactionHelper getInstance() { + if (INSTANCE == null) { + INSTANCE = new ApplicationLoadBalancerRequestTransactionHelper(GlobalTracer.get()); + } + return INSTANCE; + } + + @Override + protected Transaction doStartTransaction(ApplicationLoadBalancerRequestEvent loadBalancerRequestEvent, Context lambdaContext) { + Transaction transaction = tracer.startChildTransaction(loadBalancerRequestEvent.getHeaders(), MapTextHeaderGetter.INSTANCE, PrivilegedActionUtils.getClassLoader(loadBalancerRequestEvent.getClass())); + + if (transaction != null) { + String host = getHost(loadBalancerRequestEvent.getHeaders()); + super.fillHttpRequestData(transaction, loadBalancerRequestEvent.getHttpMethod(), loadBalancerRequestEvent.getHeaders(), host, + loadBalancerRequestEvent.getPath(), getQueryString(loadBalancerRequestEvent.getQueryStringParameters()), loadBalancerRequestEvent.getBody()); + } + + return transaction; + } + + @Override + public void captureOutputForTransaction(Transaction transaction, ApplicationLoadBalancerResponseEvent responseEvent) { + fillHttpResponseData(transaction, responseEvent.getHeaders(), responseEvent.getStatusCode()); + } + + @Override + protected void setTransactionTriggerData(Transaction transaction, ApplicationLoadBalancerRequestEvent loadBalancerRequestEvent) { + transaction.withType(TRANSACTION_TYPE); + CloudOrigin cloudOrigin = transaction.getContext().getCloudOrigin(); + cloudOrigin.withServiceName("elb"); + cloudOrigin.withProvider("aws"); + FaasTrigger faasTrigger = transaction.getFaas().getTrigger(); + faasTrigger.withType("http"); + faasTrigger.withRequestId(getHeader(loadBalancerRequestEvent, "x-amzn-trace-id")); + LoadBalancerElbTargetGroupArnMetadata metadata = parseMetadata(loadBalancerRequestEvent); + if (null != metadata) { + ServiceOrigin serviceOrigin = transaction.getContext().getServiceOrigin(); + serviceOrigin.withName(metadata.getTargetGroupName()); + serviceOrigin.withId(metadata.getTargetGroupArn()); + cloudOrigin.withAccountId(metadata.getAccountId()); + cloudOrigin.withRegion(metadata.getCloudRegion()); + } + } + + @Nullable + private String getHeader(@Nonnull ApplicationLoadBalancerRequestEvent loadBalancerRequestEvent, + @Nonnull String headerName) { + Map headers = loadBalancerRequestEvent.getHeaders(); + if (null == headers) { + return null; + } + return headers.get(headerName); + } + + @Nullable + private LoadBalancerElbTargetGroupArnMetadata parseMetadata(ApplicationLoadBalancerRequestEvent event) { + if (null == event.getRequestContext()) { + return null; + } + ApplicationLoadBalancerRequestEvent.Elb elb = event.getRequestContext().getElb(); + if (null == elb) { + return null; + } + String targetGroupArn = elb.getTargetGroupArn(); + if (null == targetGroupArn) { + return null; + } + LoadBalancerElbTargetGroupArnMetadata metadata = new LoadBalancerElbTargetGroupArnMetadata(targetGroupArn); + String[] arnParts = targetGroupArn.split(":"); + int arnPartsLength = arnParts.length; + if (arnPartsLength < 4) { + return metadata; + } + metadata.withCloudRegion(arnParts[3]); + if (arnPartsLength < 5) { + return metadata; + } + metadata.withAccountId(arnParts[4]); + if (arnPartsLength < 6) { + return metadata; + } + String targetGroup = arnParts[5]; + String[] targetGroupParts = targetGroup.split("/"); + if (targetGroupParts.length < 2) { + return metadata; + } + return metadata.withTargetGroupName(targetGroupParts[2]); + } + + @Override + protected String getApiGatewayVersion() { + throw new UnsupportedOperationException("Not supported by ELB"); + } + + @Nullable + @Override + protected String getHttpMethod(ApplicationLoadBalancerRequestEvent event) { + return event.getHttpMethod(); + } + + @Nullable + @Override + protected String getRequestContextPath(ApplicationLoadBalancerRequestEvent event) { + return event.getPath(); + } + + @Nullable + @Override + protected String getStage(ApplicationLoadBalancerRequestEvent event) { + throw new UnsupportedOperationException("Not supported by ELB"); + } + + @Nullable + @Override + protected String getResourcePath(ApplicationLoadBalancerRequestEvent event) { + return null; + } + + @Nullable + @Override + String getDomainName(ApplicationLoadBalancerRequestEvent apiGatewayRequest) { + return null; + } +} diff --git a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/LoadBalancerElbTargetGroupArnMetadata.java b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/LoadBalancerElbTargetGroupArnMetadata.java new file mode 100644 index 0000000000..a87af8e85c --- /dev/null +++ b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/LoadBalancerElbTargetGroupArnMetadata.java @@ -0,0 +1,70 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. 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. + */ +package co.elastic.apm.agent.awslambda.helper; + + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public class LoadBalancerElbTargetGroupArnMetadata { + + private LoadBalancerElbTargetGroupArnMetadata() {} + public LoadBalancerElbTargetGroupArnMetadata(String targetGroupArn) { + this.targetGroupArn = targetGroupArn; + } + private String targetGroupArn; + private String cloudRegion; + private String accountId; + private String targetGroupName; + + public LoadBalancerElbTargetGroupArnMetadata withCloudRegion(String cloudRegion) { + this.cloudRegion = cloudRegion; + return this; + } + + @Nullable + public String getCloudRegion() { + return cloudRegion; + } + + public LoadBalancerElbTargetGroupArnMetadata withAccountId(String accountId) { + this.accountId = accountId; + return this; + } + + public LoadBalancerElbTargetGroupArnMetadata withTargetGroupName(String targetGroupName) { + this.targetGroupName = targetGroupName; + return this; + } + + @Nonnull + public String getTargetGroupArn() { + return targetGroupArn; + } + + @Nullable + public String getAccountId() { + return accountId; + } + + @Nullable + public String getTargetGroupName() { + return targetGroupName; + } +} diff --git a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/PlainTransactionHelper.java b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/PlainTransactionHelper.java index d86880d0f4..a0453ad866 100644 --- a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/PlainTransactionHelper.java +++ b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/PlainTransactionHelper.java @@ -18,10 +18,10 @@ */ package co.elastic.apm.agent.awslambda.helper; -import co.elastic.apm.agent.impl.ElasticApmTracer; import co.elastic.apm.agent.tracer.GlobalTracer; -import co.elastic.apm.agent.impl.transaction.Transaction; import co.elastic.apm.agent.sdk.internal.util.PrivilegedActionUtils; +import co.elastic.apm.agent.tracer.Tracer; +import co.elastic.apm.agent.tracer.Transaction; import com.amazonaws.services.lambda.runtime.Context; import javax.annotation.Nullable; @@ -33,29 +33,29 @@ public class PlainTransactionHelper extends AbstractLambdaTransactionHelper doStartTransaction(Object input, Context lambdaContext) { return tracer.startRootTransaction(PrivilegedActionUtils.getClassLoader(lambdaContext.getClass())); } @Override - public void captureOutputForTransaction(Transaction transaction, Object output) { + public void captureOutputForTransaction(Transaction transaction, Object output) { // Nothing to do here } @Override - protected void setTransactionTriggerData(Transaction transaction, Object input) { + protected void setTransactionTriggerData(Transaction transaction, Object input) { transaction.getFaas().getTrigger().withType("other"); transaction.withType(TRANSACTION_TYPE); } diff --git a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/S3TransactionHelper.java b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/S3TransactionHelper.java index e2203a665d..ac00d9ef54 100644 --- a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/S3TransactionHelper.java +++ b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/S3TransactionHelper.java @@ -18,14 +18,14 @@ */ package co.elastic.apm.agent.awslambda.helper; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.sdk.internal.util.PrivilegedActionUtils; import co.elastic.apm.agent.tracer.AbstractSpan; +import co.elastic.apm.agent.tracer.FaasTrigger; import co.elastic.apm.agent.tracer.GlobalTracer; -import co.elastic.apm.agent.impl.context.CloudOrigin; -import co.elastic.apm.agent.impl.context.ServiceOrigin; -import co.elastic.apm.agent.impl.transaction.FaasTrigger; -import co.elastic.apm.agent.impl.transaction.Transaction; -import co.elastic.apm.agent.sdk.internal.util.PrivilegedActionUtils; +import co.elastic.apm.agent.tracer.ServiceOrigin; +import co.elastic.apm.agent.tracer.Tracer; +import co.elastic.apm.agent.tracer.Transaction; +import co.elastic.apm.agent.tracer.metadata.CloudOrigin; import com.amazonaws.services.lambda.runtime.Context; import com.amazonaws.services.lambda.runtime.events.S3Event; import com.amazonaws.services.lambda.runtime.events.models.s3.S3EventNotification; @@ -38,13 +38,13 @@ public class S3TransactionHelper extends AbstractLambdaTransactionHelper doStartTransaction(S3Event s3Event, Context lambdaContext) { return tracer.startRootTransaction(PrivilegedActionUtils.getClassLoader(lambdaContext.getClass())); } @Override - public void captureOutputForTransaction(Transaction transaction, Void output) { + public void captureOutputForTransaction(Transaction transaction, Void output) { // Nothing to do here } @Override - protected void setTransactionTriggerData(Transaction transaction, S3Event s3Event) { + protected void setTransactionTriggerData(Transaction transaction, S3Event s3Event) { transaction.withType(TRANSACTION_TYPE); FaasTrigger faasTrigger = transaction.getFaas().getTrigger(); @@ -97,7 +97,7 @@ protected void setTransactionTriggerData(Transaction transaction, S3Event s3Even } @Override - protected void setTransactionName(Transaction transaction, S3Event s3Event, Context lambdaContext) { + protected void setTransactionName(Transaction transaction, S3Event s3Event, Context lambdaContext) { S3EventNotification.S3EventNotificationRecord s3NotificationRecord = getS3NotificationRecord(s3Event); StringBuilder transactionName = transaction.getAndOverrideName(AbstractSpan.PRIORITY_HIGH_LEVEL_FRAMEWORK); if (transactionName != null && null != s3NotificationRecord && null != s3NotificationRecord.getS3() && null != s3NotificationRecord.getS3().getBucket()) { diff --git a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/SNSTransactionHelper.java b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/SNSTransactionHelper.java index ed635f00e4..9e3425837b 100644 --- a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/SNSTransactionHelper.java +++ b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/SNSTransactionHelper.java @@ -19,9 +19,9 @@ package co.elastic.apm.agent.awslambda.helper; import co.elastic.apm.agent.awslambda.SNSMessageAttributesGetter; -import co.elastic.apm.agent.impl.ElasticApmTracer; import co.elastic.apm.agent.tracer.GlobalTracer; -import co.elastic.apm.agent.impl.transaction.Transaction; +import co.elastic.apm.agent.tracer.Tracer; +import co.elastic.apm.agent.tracer.Transaction; import com.amazonaws.services.lambda.runtime.events.SNSEvent; import javax.annotation.Nullable; @@ -33,13 +33,13 @@ public class SNSTransactionHelper extends AbstractMessageBasedTransactionHelper< private final SNSEvent.SNSRecord placeholderRecord = new SNSEvent.SNSRecord(); - private SNSTransactionHelper(ElasticApmTracer tracer) { + private SNSTransactionHelper(Tracer tracer) { super(tracer); } public static SNSTransactionHelper getInstance() { if (INSTANCE == null) { - INSTANCE = new SNSTransactionHelper(GlobalTracer.get().require(ElasticApmTracer.class)); + INSTANCE = new SNSTransactionHelper(GlobalTracer.get()); } return INSTANCE; } @@ -78,7 +78,7 @@ record = event.getRecords().get(0); } @Override - protected void addSpanLinks(Transaction transaction, SNSEvent event) { + protected void addSpanLinks(Transaction transaction, SNSEvent event) { List records = event.getRecords(); if (records != null && !records.isEmpty()) { for (SNSEvent.SNSRecord record : records) { diff --git a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/SQSTransactionHelper.java b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/SQSTransactionHelper.java index 218506a463..6f6ba9e807 100644 --- a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/SQSTransactionHelper.java +++ b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/SQSTransactionHelper.java @@ -19,9 +19,9 @@ package co.elastic.apm.agent.awslambda.helper; import co.elastic.apm.agent.awslambda.SQSMessageAttributesGetter; -import co.elastic.apm.agent.impl.ElasticApmTracer; import co.elastic.apm.agent.tracer.GlobalTracer; -import co.elastic.apm.agent.impl.transaction.Transaction; +import co.elastic.apm.agent.tracer.Tracer; +import co.elastic.apm.agent.tracer.Transaction; import com.amazonaws.services.lambda.runtime.events.SQSEvent; import javax.annotation.Nullable; @@ -34,13 +34,13 @@ public class SQSTransactionHelper extends AbstractMessageBasedTransactionHelper< private final SQSEvent.SQSMessage placeholderMessage = new SQSEvent.SQSMessage(); - private SQSTransactionHelper(ElasticApmTracer tracer) { + private SQSTransactionHelper(Tracer tracer) { super(tracer); } public static SQSTransactionHelper getInstance() { if (INSTANCE == null) { - INSTANCE = new SQSTransactionHelper(GlobalTracer.get().require(ElasticApmTracer.class)); + INSTANCE = new SQSTransactionHelper(GlobalTracer.get()); } return INSTANCE; } @@ -76,7 +76,7 @@ record = event.getRecords().get(0); } @Override - protected void addSpanLinks(Transaction transaction, SQSEvent event) { + protected void addSpanLinks(Transaction transaction, SQSEvent event) { List records = event.getRecords(); if (records != null && !records.isEmpty()) { for (SQSEvent.SQSMessage record : records) { diff --git a/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/AbstractLambdaTest.java b/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/AbstractLambdaTest.java index e196b30175..9722136ae1 100644 --- a/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/AbstractLambdaTest.java +++ b/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/AbstractLambdaTest.java @@ -27,6 +27,7 @@ import co.elastic.apm.agent.configuration.SpyConfiguration; import co.elastic.apm.agent.impl.metadata.MetaDataMock; import co.elastic.apm.agent.impl.stacktrace.StacktraceConfiguration; +import co.elastic.apm.agent.impl.transaction.Faas; import co.elastic.apm.agent.impl.transaction.TraceContext; import co.elastic.apm.agent.impl.transaction.TraceState; import co.elastic.apm.agent.impl.transaction.Transaction; diff --git a/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/ApiGatewayV1LambdaTest.java b/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/ApiGatewayV1LambdaTest.java index c6e0be6e30..6006e85979 100644 --- a/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/ApiGatewayV1LambdaTest.java +++ b/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/ApiGatewayV1LambdaTest.java @@ -45,7 +45,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.doReturn; -public class ApiGatewayV1LambdaTest extends AbstractLambdaTest { +public class ApiGatewayV1LambdaTest extends BaseGatewayLambdaTest { @BeforeAll @BeforeClass @@ -144,34 +144,6 @@ public void testBasicCall() { assertThat(faas.getTrigger().getRequestId()).isEqualTo(API_GATEWAY_REQUEST_ID); } - @Test - public void testCallWithNullInput() { - getFunction().handleRequest(null, context); - - reporter.awaitTransactionCount(1); - reporter.awaitSpanCount(1); - assertThat(reporter.getFirstSpan().getNameAsString()).isEqualTo("child-span"); - assertThat(reporter.getFirstSpan().getTransaction()).isEqualTo(reporter.getFirstTransaction()); - Transaction transaction = reporter.getFirstTransaction(); - assertThat(transaction.getNameAsString()).isEqualTo(TestContext.FUNCTION_NAME); - assertThat(transaction.getType()).isEqualTo("request"); - assertThat(transaction.getResult()).isEqualTo("HTTP 2xx"); - - assertThat(transaction.getContext().getCloudOrigin()).isNotNull(); - assertThat(transaction.getContext().getCloudOrigin().getProvider()).isEqualTo("aws"); - assertThat(transaction.getContext().getCloudOrigin().getServiceName()).isNull(); - assertThat(transaction.getContext().getCloudOrigin().getRegion()).isNull(); - assertThat(transaction.getContext().getCloudOrigin().getAccountId()).isNull(); - - assertThat(transaction.getContext().getServiceOrigin().hasContent()).isFalse(); - - Faas faas = transaction.getFaas(); - assertThat(faas.getExecution()).isEqualTo(TestContext.AWS_REQUEST_ID); - - assertThat(faas.getTrigger().getType()).isEqualTo("other"); - assertThat(faas.getTrigger().getRequestId()).isNull(); - } - @ParameterizedTest @ValueSource(booleans = {true, false}) public void testCallWithNullRequestContext(boolean isObjectNull) { @@ -210,19 +182,6 @@ public void testCallWithNullRequestContext(boolean isObjectNull) { assertThat(faas.getTrigger().getRequestId()).isNull(); } - @Test - public void testCallWithHErrorStatusCode() { - Objects.requireNonNull(context).setErrorStatusCode(); - getFunction().handleRequest(createInput(), context); - reporter.awaitTransactionCount(1); - reporter.awaitSpanCount(1); - assertThat(reporter.getFirstSpan().getNameAsString()).isEqualTo("child-span"); - assertThat(reporter.getFirstSpan().getTransaction()).isEqualTo(reporter.getFirstTransaction()); - Transaction transaction = reporter.getFirstTransaction(); - assertThat(transaction.getResult()).isEqualTo("HTTP 5xx"); - assertThat(transaction.getOutcome()).isEqualTo(Outcome.FAILURE); - } - @Test public void testTransactionNameForRestApiSpecificRoute() { getFunction().handleRequest(createInput("PUT", "/prod/test/12345", "/test", "prod"), context); @@ -256,6 +215,17 @@ public void testTransactionNameWithUsePathAsName() { assertThat(reporter.getFirstTransaction().getNameAsString()).isEqualTo("PUT /prod/proxy-test/12345"); } + @Test + public void testServiceNameAsLambdaUrl() { + APIGatewayProxyRequestEvent event = createInput(); + event.getRequestContext().setDomainName("myurl.lambda-url.us-west-2.on.aws"); + getFunction().handleRequest(event, context); + reporter.awaitTransactionCount(1); + reporter.awaitSpanCount(1); + Transaction transaction = reporter.getFirstTransaction(); + assertThat(transaction.getContext().getCloudOrigin().getServiceName()).isEqualTo("lambda url"); + } + @Override protected AbstractFunction createHandler() { return new ApiGatewayV1LambdaFunction(); diff --git a/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/ApiGatewayV2LambdaTest.java b/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/ApiGatewayV2LambdaTest.java index d2a7cd73b4..4315ca4d3f 100644 --- a/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/ApiGatewayV2LambdaTest.java +++ b/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/ApiGatewayV2LambdaTest.java @@ -31,6 +31,7 @@ import co.elastic.apm.agent.impl.transaction.Transaction; import co.elastic.apm.agent.tracer.Outcome; import co.elastic.apm.agent.tracer.metadata.PotentiallyMultiValuedMap; +import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent; import com.amazonaws.services.lambda.runtime.events.APIGatewayV2HTTPEvent; import com.amazonaws.services.lambda.runtime.events.APIGatewayV2HTTPResponse; import org.junit.BeforeClass; @@ -46,7 +47,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.doReturn; -public class ApiGatewayV2LambdaTest extends AbstractLambdaTest { +public class ApiGatewayV2LambdaTest extends BaseGatewayLambdaTest { @BeforeAll @BeforeClass @@ -150,34 +151,6 @@ public void testBasicCall() { assertThat(faas.getTrigger().getRequestId()).isEqualTo(API_GATEWAY_REQUEST_ID); } - @Test - public void testCallWithNullInput() { - getFunction().handleRequest(null, context); - - reporter.awaitTransactionCount(1); - reporter.awaitSpanCount(1); - assertThat(reporter.getFirstSpan().getNameAsString()).isEqualTo("child-span"); - assertThat(reporter.getFirstSpan().getTransaction()).isEqualTo(reporter.getFirstTransaction()); - Transaction transaction = reporter.getFirstTransaction(); - assertThat(transaction.getNameAsString()).isEqualTo(TestContext.FUNCTION_NAME); - assertThat(transaction.getType()).isEqualTo("request"); - assertThat(transaction.getResult()).isEqualTo("HTTP 2xx"); - - assertThat(transaction.getContext().getCloudOrigin()).isNotNull(); - assertThat(transaction.getContext().getCloudOrigin().getProvider()).isEqualTo("aws"); - assertThat(transaction.getContext().getCloudOrigin().getServiceName()).isNull(); - assertThat(transaction.getContext().getCloudOrigin().getRegion()).isNull(); - assertThat(transaction.getContext().getCloudOrigin().getAccountId()).isNull(); - - assertThat(transaction.getContext().getServiceOrigin().hasContent()).isFalse(); - - Faas faas = transaction.getFaas(); - assertThat(faas.getExecution()).isEqualTo(TestContext.AWS_REQUEST_ID); - - assertThat(faas.getTrigger().getType()).isEqualTo("other"); - assertThat(faas.getTrigger().getRequestId()).isNull(); - } - @ParameterizedTest @ValueSource(booleans = {true, false}) public void testCallWithNullRequestContext(boolean isObjectNull) { @@ -211,19 +184,6 @@ public void testCallWithNullRequestContext(boolean isObjectNull) { assertThat(faas.getTrigger().getRequestId()).isNull(); } - @Test - public void testCallWithHErrorStatusCode() { - Objects.requireNonNull(context).setErrorStatusCode(); - getFunction().handleRequest(createInput(), context); - reporter.awaitTransactionCount(1); - reporter.awaitSpanCount(1); - assertThat(reporter.getFirstSpan().getNameAsString()).isEqualTo("child-span"); - assertThat(reporter.getFirstSpan().getTransaction()).isEqualTo(reporter.getFirstTransaction()); - Transaction transaction = reporter.getFirstTransaction(); - assertThat(transaction.getResult()).isEqualTo("HTTP 5xx"); - assertThat(transaction.getOutcome()).isEqualTo(Outcome.FAILURE); - } - @Test public void testTransactionNameForRestApiSpecificRoute() { getFunction().handleRequest(createInput("PUT", "/prod/test", "ANY /test", "prod"), context); @@ -249,6 +209,17 @@ public void testTransactionNameWithUsePathAsName() { assertThat(reporter.getFirstTransaction().getNameAsString()).isEqualTo("PUT /prod/proxy-test/12345"); } + @Test + public void testServiceNameAsLambdaUrl() { + APIGatewayV2HTTPEvent event = createInput(); + event.getRequestContext().setDomainName("myurl.lambda-url.us-west-2.on.aws"); + getFunction().handleRequest(event, context); + reporter.awaitTransactionCount(1); + reporter.awaitSpanCount(1); + Transaction transaction = reporter.getFirstTransaction(); + assertThat(transaction.getContext().getCloudOrigin().getServiceName()).isEqualTo("lambda url"); + } + @Override protected AbstractFunction createHandler() { return new ApiGatewayV2LambdaFunction(); diff --git a/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/ApplicationLoadBalancerRequestEventLambdaTest.java b/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/ApplicationLoadBalancerRequestEventLambdaTest.java new file mode 100644 index 0000000000..5583ba1834 --- /dev/null +++ b/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/ApplicationLoadBalancerRequestEventLambdaTest.java @@ -0,0 +1,197 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. 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. + */ +package co.elastic.apm.agent.awslambda; + +import co.elastic.apm.agent.awslambda.lambdas.AbstractFunction; +import co.elastic.apm.agent.awslambda.lambdas.ApiGatewayV1LambdaFunction; +import co.elastic.apm.agent.awslambda.lambdas.ApplicationLoadBalancerRequestLambdaFunction; +import co.elastic.apm.agent.awslambda.lambdas.TestContext; +import co.elastic.apm.agent.configuration.CoreConfiguration; +import co.elastic.apm.agent.impl.context.Request; +import co.elastic.apm.agent.impl.context.Response; +import co.elastic.apm.agent.impl.context.Url; +import co.elastic.apm.agent.impl.transaction.Faas; +import co.elastic.apm.agent.impl.transaction.Transaction; +import co.elastic.apm.agent.tracer.Outcome; +import co.elastic.apm.agent.tracer.configuration.WebConfiguration; +import co.elastic.apm.agent.tracer.metadata.PotentiallyMultiValuedMap; +import com.amazonaws.services.lambda.runtime.events.APIGatewayV2HTTPEvent; +import com.amazonaws.services.lambda.runtime.events.ApplicationLoadBalancerRequestEvent; +import com.amazonaws.services.lambda.runtime.events.ApplicationLoadBalancerResponseEvent; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +import javax.annotation.Nonnull; +import java.util.Arrays; +import java.util.Map; +import java.util.Objects; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.doReturn; + +public class ApplicationLoadBalancerRequestEventLambdaTest extends BaseGatewayLambdaTest { + + @BeforeAll + // Need to overwrite the beforeAll() method from parent, + // because we need to mock serverlessConfiguration BEFORE instrumentation is initialized! + public static synchronized void beforeAll() { + AbstractLambdaTest.initAllButInstrumentation(); + doReturn(ApplicationLoadBalancerRequestLambdaFunction.class.getName()).when(Objects.requireNonNull(serverlessConfiguration)).getAwsLambdaHandler(); + AbstractLambdaTest.initInstrumentation(); + } + + @Override + protected AbstractFunction createHandler() { + return new ApplicationLoadBalancerRequestLambdaFunction(); + } + + @Override + protected ApplicationLoadBalancerRequestEvent createInput() { + var event = new ApplicationLoadBalancerRequestEvent(); + event.setBody("blablablabody"); + event.setIsBase64Encoded(false); + var requestContext = new ApplicationLoadBalancerRequestEvent.RequestContext(); + var elb = new ApplicationLoadBalancerRequestEvent.Elb(); + elb.setTargetGroupArn("arn:aws:elasticloadbalancing:us-east-2:123456789012:targetgroup/lambda-279XGJDqGZ5rsrHC2Fjr/49e9d65c45c6791a"); + requestContext.setElb(elb); + event.setRequestContext(requestContext); + event.setHttpMethod("POST"); + event.setPath("/toolz/api/v2.0/downloadPDF/PDF_2020-09-11_11-06-01.pdf"); + event.setQueryStringParameters(Map.of("test%40key", "test%40value", "language", "en-DE")); + event.setHeaders(Map.of("accept-encoding", "gzip,deflate", + "connection", "Keep-Alive", + "host", "blabla.com", + "user-agent", "Apache-HttpClient/4.5.13 (Java/11.0.15)", + "x-amzn-trace-id", "Root=1-xxxxxxxxxxxxxx", + "x-forwarded-for", "199.99.99.999", + "x-forwarded-port", "443", + "x-forwarded-proto", "https")); + return event; + } + + @Override + protected boolean supportsContextPropagation() { + return false; + } + + @Test + public void testBasicCall() { + doReturn(CoreConfiguration.EventType.ALL).when(config.getConfig(CoreConfiguration.class)).getCaptureBody(); + getFunction().handleRequest(createInput(), context); + reporter.awaitTransactionCount(1); + reporter.awaitSpanCount(1); + assertThat(reporter.getFirstSpan().getNameAsString()).isEqualTo("child-span"); + assertThat(reporter.getFirstSpan().getTransaction()).isEqualTo(reporter.getFirstTransaction()); + Transaction transaction = reporter.getFirstTransaction(); + assertThat(transaction.getNameAsString()).isEqualTo("FUNCTION_NAME"); + assertThat(transaction.getType()).isEqualTo("request"); + assertThat(transaction.getResult()).isEqualTo("HTTP 2xx"); + assertThat(transaction.getOutcome()).isEqualTo(Outcome.SUCCESS); + assertThat(reporter.getPartialTransactions()).containsExactly(transaction); + + Request request = transaction.getContext().getRequest(); + assertThat(request.getMethod()).isEqualTo(HTTP_METHOD); + assertThat(request.getBody()).isNull(); + assertThat(request.getHttpVersion()).isNull(); + + Url url = request.getUrl(); + assertThat(url.getHostname()).isEqualTo("blabla.com"); + assertThat(url.getPort()).isEqualTo(443); + assertThat(url.getPathname()).isEqualTo("/toolz/api/v2.0/downloadPDF/PDF_2020-09-11_11-06-01.pdf"); + assertThat(url.getSearch()).contains("test%40key=test%40value"); + assertThat(url.getSearch()).contains(Arrays.asList("language=en-DE", "test%40key=test%40value")); + assertThat(url.getProtocol()).isEqualTo("https"); + String baseUrl = "https://" + "blabla.com" + "/toolz/api/v2.0/downloadPDF/PDF_2020-09-11_11-06-01.pdf" + "?"; + assertThat(url.getFull().toString()).containsAnyOf(baseUrl + "test%40key=test%40value&language=en-DE", + baseUrl + "language=en-DE&test%40key=test%40value"); + + assertThat(request.getHeaders()).isNotNull(); + PotentiallyMultiValuedMap headers = request.getHeaders(); + assertThat(headers.get("connection")).isEqualTo("Keep-Alive"); + assertThat(headers.get("accept-encoding")).isEqualTo("gzip,deflate"); + + Response response = transaction.getContext().getResponse(); + assertThat(response.getStatusCode()).isEqualTo(ApiGatewayV1LambdaFunction.EXPECTED_STATUS_CODE); + assertThat(response.getHeaders()).isNotNull(); + assertThat(response.getHeaders().get(ApiGatewayV1LambdaFunction.EXPECTED_RESPONSE_HEADER_1_KEY)).isEqualTo(ApiGatewayV1LambdaFunction.EXPECTED_RESPONSE_HEADER_1_VALUE); + assertThat(response.getHeaders().get(ApiGatewayV1LambdaFunction.EXPECTED_RESPONSE_HEADER_2_KEY)).isEqualTo(ApiGatewayV1LambdaFunction.EXPECTED_RESPONSE_HEADER_2_VALUE); + + assertThat(transaction.getContext().getCloudOrigin()).isNotNull(); + assertThat(transaction.getContext().getCloudOrigin().getProvider()).isEqualTo("aws"); + assertThat(transaction.getContext().getCloudOrigin().getServiceName()).isEqualTo("elb"); + assertThat(transaction.getContext().getCloudOrigin().getAccountId()).isEqualTo("123456789012"); + assertThat(transaction.getContext().getCloudOrigin().getRegion()).isEqualTo("us-east-2"); + + assertThat(transaction.getContext().getServiceOrigin().hasContent()).isTrue(); + assertThat(transaction.getContext().getServiceOrigin().getName().toString()).isEqualTo("49e9d65c45c6791a"); + assertThat(transaction.getContext().getServiceOrigin().getId()).isEqualTo("arn:aws:elasticloadbalancing:us-east-2:123456789012:targetgroup/lambda-279XGJDqGZ5rsrHC2Fjr/49e9d65c45c6791a"); + assertThat(transaction.getContext().getServiceOrigin().getVersion()).isNull(); + + Faas faas = transaction.getFaas(); + assertThat(faas.getExecution()).isEqualTo(TestContext.AWS_REQUEST_ID); + assertThat(faas.getId()).isEqualTo(TestContext.FUNCTION_ARN); + assertThat(faas.getTrigger().getType()).isEqualTo("http"); + assertThat(faas.getTrigger().getRequestId()).isEqualTo("Root=1-xxxxxxxxxxxxxx"); + } + + @Test + public void testCallWithNullRequestContext() { + ApplicationLoadBalancerRequestEvent requestEvent = createInput(); + requestEvent.setRequestContext(null); + + getFunction().handleRequest(requestEvent, context); + + reporter.awaitTransactionCount(1); + reporter.awaitSpanCount(1); + assertThat(reporter.getFirstSpan().getNameAsString()).isEqualTo("child-span"); + assertThat(reporter.getFirstSpan().getTransaction()).isEqualTo(reporter.getFirstTransaction()); + Transaction transaction = reporter.getFirstTransaction(); + assertThat(transaction.getNameAsString()).isEqualTo(TestContext.FUNCTION_NAME); + assertThat(transaction.getType()).isEqualTo("request"); + assertThat(transaction.getResult()).isEqualTo("HTTP 2xx"); + + assertThat(transaction.getContext().getCloudOrigin()).isNotNull(); + assertThat(transaction.getContext().getCloudOrigin().getProvider()).isEqualTo("aws"); + + assertThat(transaction.getContext().getCloudOrigin().getServiceName()).isEqualTo("elb"); + + assertThat(transaction.getContext().getCloudOrigin().getRegion()).isNull(); + assertThat(transaction.getContext().getCloudOrigin().getAccountId()).isNull(); + + assertThat(transaction.getContext().getServiceOrigin().hasContent()).isFalse(); + + Faas faas = transaction.getFaas(); + assertThat(faas.getExecution()).isEqualTo(TestContext.AWS_REQUEST_ID); + + assertThat(faas.getTrigger().getType()).isEqualTo("http"); + assertThat(faas.getTrigger().getRequestId()).isEqualTo("Root=1-xxxxxxxxxxxxxx"); + } + + @Test + public void testTransactionNameWithUsePathAsName() { + doReturn(true).when(config.getConfig(WebConfiguration.class)).isUsePathAsName(); + getFunction().handleRequest(createInput(), context); + reporter.awaitTransactionCount(1); + reporter.awaitSpanCount(1); + assertThat(reporter.getFirstTransaction().getNameAsString()).isEqualTo("POST /toolz/api/v2.0/downloadPDF/PDF_2020-09-11_11-06-01.pdf"); + } + +} diff --git a/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/BaseGatewayLambdaTest.java b/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/BaseGatewayLambdaTest.java new file mode 100644 index 0000000000..22394fb6d6 --- /dev/null +++ b/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/BaseGatewayLambdaTest.java @@ -0,0 +1,75 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. 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. + */ +package co.elastic.apm.agent.awslambda; + +import co.elastic.apm.agent.awslambda.lambdas.TestContext; +import co.elastic.apm.agent.impl.transaction.Faas; +import co.elastic.apm.agent.impl.transaction.Transaction; +import co.elastic.apm.agent.tracer.Outcome; +import org.junit.jupiter.api.Test; + +import java.util.Objects; + +import static org.assertj.core.api.Assertions.assertThat; + +public abstract class BaseGatewayLambdaTest extends AbstractLambdaTest { + + @Test + public void testCallWithNullInput() { + getFunction().handleRequest(null, context); + + reporter.awaitTransactionCount(1); + reporter.awaitSpanCount(1); + assertThat(reporter.getFirstSpan().getNameAsString()).isEqualTo("child-span"); + assertThat(reporter.getFirstSpan().getTransaction()).isEqualTo(reporter.getFirstTransaction()); + Transaction transaction = reporter.getFirstTransaction(); + assertThat(transaction.getNameAsString()).isEqualTo(TestContext.FUNCTION_NAME); + assertThat(transaction.getType()).isEqualTo("request"); + assertThat(transaction.getResult()).isEqualTo("HTTP 2xx"); + + assertThat(transaction.getContext().getCloudOrigin()).isNotNull(); + assertThat(transaction.getContext().getCloudOrigin().getProvider()).isEqualTo("aws"); + assertThat(transaction.getContext().getCloudOrigin().getServiceName()).isNull(); + assertThat(transaction.getContext().getCloudOrigin().getRegion()).isNull(); + assertThat(transaction.getContext().getCloudOrigin().getAccountId()).isNull(); + + assertThat(transaction.getContext().getServiceOrigin().hasContent()).isFalse(); + + Faas faas = transaction.getFaas(); + assertThat(faas.getExecution()).isEqualTo(TestContext.AWS_REQUEST_ID); + + assertThat(faas.getTrigger().getType()).isEqualTo("other"); + assertThat(faas.getTrigger().getRequestId()).isNull(); + } + + + @Test + public void testCallWithErrorStatusCode() { + Objects.requireNonNull(context).setErrorStatusCode(); + getFunction().handleRequest(createInput(), context); + reporter.awaitTransactionCount(1); + reporter.awaitSpanCount(1); + assertThat(reporter.getFirstSpan().getNameAsString()).isEqualTo("child-span"); + assertThat(reporter.getFirstSpan().getTransaction()).isEqualTo(reporter.getFirstTransaction()); + Transaction transaction = reporter.getFirstTransaction(); + assertThat(transaction.getResult()).isEqualTo("HTTP 5xx"); + assertThat(transaction.getOutcome()).isEqualTo(Outcome.FAILURE); + } + +} diff --git a/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/lambdas/ApplicationLoadBalancerRequestLambdaFunction.java b/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/lambdas/ApplicationLoadBalancerRequestLambdaFunction.java new file mode 100644 index 0000000000..54dd61fa14 --- /dev/null +++ b/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/lambdas/ApplicationLoadBalancerRequestLambdaFunction.java @@ -0,0 +1,52 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. 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. + */ +package co.elastic.apm.agent.awslambda.lambdas; + +import com.amazonaws.services.lambda.runtime.Context; +import com.amazonaws.services.lambda.runtime.events.ApplicationLoadBalancerRequestEvent; +import com.amazonaws.services.lambda.runtime.events.ApplicationLoadBalancerResponseEvent; + +import java.util.Map; + +public class ApplicationLoadBalancerRequestLambdaFunction extends AbstractFunction { + public static final String EXPECTED_BODY = "This is some body"; + public static final String EXPECTED_RESPONSE_HEADER_1_KEY = "EXPECTED_HEADER_1_KEY"; + public static final String EXPECTED_RESPONSE_HEADER_1_VALUE = "EXPECTED_HEADER_1_VALUE"; + public static final String EXPECTED_RESPONSE_HEADER_2_KEY = "EXPECTED_HEADER_2_KEY"; + public static final String EXPECTED_RESPONSE_HEADER_2_VALUE = "EXPECTED_HEADER_2_VALUE"; + public static final int EXPECTED_STATUS_CODE = 202; + public static final int ERROR_STATUS_CODE = 505; + + @Override + public ApplicationLoadBalancerResponseEvent handleRequest(ApplicationLoadBalancerRequestEvent applicationLoadBalancerRequestEvent, Context context) { + createChildSpan(); + + ApplicationLoadBalancerResponseEvent response = new ApplicationLoadBalancerResponseEvent(); + response.setBody(EXPECTED_BODY); + response.setHeaders(Map.of(EXPECTED_RESPONSE_HEADER_1_KEY, EXPECTED_RESPONSE_HEADER_1_VALUE, EXPECTED_RESPONSE_HEADER_2_KEY, EXPECTED_RESPONSE_HEADER_2_VALUE)); + + if (((TestContext) context).shouldSetErrorStatusCode()) { + response.setStatusCode(ERROR_STATUS_CODE); + } else { + response.setStatusCode(EXPECTED_STATUS_CODE); + } + raiseException(context); + return response; + } +} diff --git a/apm-agent-plugins/apm-cassandra/apm-cassandra-core-plugin/pom.xml b/apm-agent-plugins/apm-cassandra/apm-cassandra-core-plugin/pom.xml index 110cc51a59..be3fbb0565 100644 --- a/apm-agent-plugins/apm-cassandra/apm-cassandra-core-plugin/pom.xml +++ b/apm-agent-plugins/apm-cassandra/apm-cassandra-core-plugin/pom.xml @@ -3,7 +3,7 @@ apm-cassandra co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugins/apm-cassandra/apm-cassandra3-plugin/pom.xml b/apm-agent-plugins/apm-cassandra/apm-cassandra3-plugin/pom.xml index 245b37dda1..f8ad869438 100644 --- a/apm-agent-plugins/apm-cassandra/apm-cassandra3-plugin/pom.xml +++ b/apm-agent-plugins/apm-cassandra/apm-cassandra3-plugin/pom.xml @@ -3,7 +3,7 @@ apm-cassandra co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugins/apm-cassandra/apm-cassandra4-plugin/pom.xml b/apm-agent-plugins/apm-cassandra/apm-cassandra4-plugin/pom.xml index 57bb53d1cc..1130b7ff35 100644 --- a/apm-agent-plugins/apm-cassandra/apm-cassandra4-plugin/pom.xml +++ b/apm-agent-plugins/apm-cassandra/apm-cassandra4-plugin/pom.xml @@ -3,7 +3,7 @@ apm-cassandra co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugins/apm-cassandra/pom.xml b/apm-agent-plugins/apm-cassandra/pom.xml index 3628a07846..a6fcd2e7a1 100644 --- a/apm-agent-plugins/apm-cassandra/pom.xml +++ b/apm-agent-plugins/apm-cassandra/pom.xml @@ -3,7 +3,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugins/apm-dubbo-plugin/pom.xml b/apm-agent-plugins/apm-dubbo-plugin/pom.xml index 4e07dff93c..bef2e71d9e 100644 --- a/apm-agent-plugins/apm-dubbo-plugin/pom.xml +++ b/apm-agent-plugins/apm-dubbo-plugin/pom.xml @@ -3,7 +3,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugins/apm-ecs-logging-plugin/pom.xml b/apm-agent-plugins/apm-ecs-logging-plugin/pom.xml index d7d4191da5..794c55ad97 100644 --- a/apm-agent-plugins/apm-ecs-logging-plugin/pom.xml +++ b/apm-agent-plugins/apm-ecs-logging-plugin/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-ecs-logging-plugin @@ -41,7 +41,7 @@ org.apache.logging.log4j log4j-core - 2.23.0 + 2.23.1 provided true diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/pom.xml b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/pom.xml index 953b7df444..e3145e447e 100644 --- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/pom.xml +++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/pom.xml @@ -5,7 +5,7 @@ apm-es-restclient-plugin co.elastic.apm - 1.48.1 + 1.49.0 apm-es-restclient-plugin-5_6 diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/pom.xml b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/pom.xml index ecebe23244..d3ce291f35 100644 --- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/pom.xml +++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/pom.xml @@ -5,7 +5,7 @@ apm-es-restclient-plugin co.elastic.apm - 1.48.1 + 1.49.0 apm-es-restclient-plugin-6_4 diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-7_x/pom.xml b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-7_x/pom.xml index 1d7449dde8..972d0f081f 100644 --- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-7_x/pom.xml +++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-7_x/pom.xml @@ -5,7 +5,7 @@ apm-es-restclient-plugin co.elastic.apm - 1.48.1 + 1.49.0 apm-es-restclient-plugin-7_x diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-8_x/pom.xml b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-8_x/pom.xml index ede3c16185..cba4d9d614 100644 --- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-8_x/pom.xml +++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-8_x/pom.xml @@ -3,7 +3,7 @@ apm-es-restclient-plugin co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/pom.xml b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/pom.xml index 1b9542947f..11191c15d0 100644 --- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/pom.xml +++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/pom.xml @@ -5,7 +5,7 @@ apm-es-restclient-plugin co.elastic.apm - 1.48.1 + 1.49.0 apm-es-restclient-plugin-common diff --git a/apm-agent-plugins/apm-es-restclient-plugin/pom.xml b/apm-agent-plugins/apm-es-restclient-plugin/pom.xml index f6f737e86e..284c69814d 100644 --- a/apm-agent-plugins/apm-es-restclient-plugin/pom.xml +++ b/apm-agent-plugins/apm-es-restclient-plugin/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-es-restclient-plugin diff --git a/apm-agent-plugins/apm-finagle-httpclient-plugin/pom.xml b/apm-agent-plugins/apm-finagle-httpclient-plugin/pom.xml index 358b698acf..c5282b5a39 100644 --- a/apm-agent-plugins/apm-finagle-httpclient-plugin/pom.xml +++ b/apm-agent-plugins/apm-finagle-httpclient-plugin/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-finagle-httpclient-plugin diff --git a/apm-agent-plugins/apm-grails-plugin/pom.xml b/apm-agent-plugins/apm-grails-plugin/pom.xml index ce4941288f..395750bc79 100644 --- a/apm-agent-plugins/apm-grails-plugin/pom.xml +++ b/apm-agent-plugins/apm-grails-plugin/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-grails-plugin diff --git a/apm-agent-plugins/apm-grpc/apm-grpc-plugin/pom.xml b/apm-agent-plugins/apm-grpc/apm-grpc-plugin/pom.xml index 9633786176..cce2de5dc1 100644 --- a/apm-agent-plugins/apm-grpc/apm-grpc-plugin/pom.xml +++ b/apm-agent-plugins/apm-grpc/apm-grpc-plugin/pom.xml @@ -5,7 +5,7 @@ co.elastic.apm apm-grpc - 1.48.1 + 1.49.0 apm-grpc-plugin diff --git a/apm-agent-plugins/apm-grpc/apm-grpc-test-1.6.1/pom.xml b/apm-agent-plugins/apm-grpc/apm-grpc-test-1.6.1/pom.xml index b435a854e3..fc32f566a9 100644 --- a/apm-agent-plugins/apm-grpc/apm-grpc-test-1.6.1/pom.xml +++ b/apm-agent-plugins/apm-grpc/apm-grpc-test-1.6.1/pom.xml @@ -5,7 +5,7 @@ co.elastic.apm apm-grpc - 1.48.1 + 1.49.0 apm-grpc-test-1.6.1 diff --git a/apm-agent-plugins/apm-grpc/apm-grpc-test-latest/pom.xml b/apm-agent-plugins/apm-grpc/apm-grpc-test-latest/pom.xml index 0a15cdba35..216087d7a8 100644 --- a/apm-agent-plugins/apm-grpc/apm-grpc-test-latest/pom.xml +++ b/apm-agent-plugins/apm-grpc/apm-grpc-test-latest/pom.xml @@ -5,7 +5,7 @@ co.elastic.apm apm-grpc - 1.48.1 + 1.49.0 apm-grpc-test-latest diff --git a/apm-agent-plugins/apm-grpc/pom.xml b/apm-agent-plugins/apm-grpc/pom.xml index 297f801075..759c1f1320 100644 --- a/apm-agent-plugins/apm-grpc/pom.xml +++ b/apm-agent-plugins/apm-grpc/pom.xml @@ -5,7 +5,7 @@ co.elastic.apm apm-agent-plugins - 1.48.1 + 1.49.0 apm-grpc diff --git a/apm-agent-plugins/apm-hibernate-search-plugin/apm-hibernate-search-plugin-5_x/pom.xml b/apm-agent-plugins/apm-hibernate-search-plugin/apm-hibernate-search-plugin-5_x/pom.xml index 5231eadcfa..8f48e364f7 100644 --- a/apm-agent-plugins/apm-hibernate-search-plugin/apm-hibernate-search-plugin-5_x/pom.xml +++ b/apm-agent-plugins/apm-hibernate-search-plugin/apm-hibernate-search-plugin-5_x/pom.xml @@ -5,7 +5,7 @@ apm-hibernate-search-plugin co.elastic.apm - 1.48.1 + 1.49.0 apm-hibernate-search-plugin-5_x diff --git a/apm-agent-plugins/apm-hibernate-search-plugin/apm-hibernate-search-plugin-6_x/pom.xml b/apm-agent-plugins/apm-hibernate-search-plugin/apm-hibernate-search-plugin-6_x/pom.xml index f90873c3f7..ab99217b36 100644 --- a/apm-agent-plugins/apm-hibernate-search-plugin/apm-hibernate-search-plugin-6_x/pom.xml +++ b/apm-agent-plugins/apm-hibernate-search-plugin/apm-hibernate-search-plugin-6_x/pom.xml @@ -5,7 +5,7 @@ apm-hibernate-search-plugin co.elastic.apm - 1.48.1 + 1.49.0 apm-hibernate-search-plugin-6_x diff --git a/apm-agent-plugins/apm-hibernate-search-plugin/apm-hibernate-search-plugin-common/pom.xml b/apm-agent-plugins/apm-hibernate-search-plugin/apm-hibernate-search-plugin-common/pom.xml index 0bd46f79af..e5ad36c01d 100644 --- a/apm-agent-plugins/apm-hibernate-search-plugin/apm-hibernate-search-plugin-common/pom.xml +++ b/apm-agent-plugins/apm-hibernate-search-plugin/apm-hibernate-search-plugin-common/pom.xml @@ -5,7 +5,7 @@ apm-hibernate-search-plugin co.elastic.apm - 1.48.1 + 1.49.0 apm-hibernate-search-plugin-common diff --git a/apm-agent-plugins/apm-hibernate-search-plugin/pom.xml b/apm-agent-plugins/apm-hibernate-search-plugin/pom.xml index 5f8b49d2a3..e87bec250b 100644 --- a/apm-agent-plugins/apm-hibernate-search-plugin/pom.xml +++ b/apm-agent-plugins/apm-hibernate-search-plugin/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-hibernate-search-plugin diff --git a/apm-agent-plugins/apm-httpclient-core/pom.xml b/apm-agent-plugins/apm-httpclient-core/pom.xml index df0969200c..6f0e154bc2 100644 --- a/apm-agent-plugins/apm-httpclient-core/pom.xml +++ b/apm-agent-plugins/apm-httpclient-core/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-httpclient-core diff --git a/apm-agent-plugins/apm-httpserver-core/pom.xml b/apm-agent-plugins/apm-httpserver-core/pom.xml index 2fff28b293..d82a19e192 100644 --- a/apm-agent-plugins/apm-httpserver-core/pom.xml +++ b/apm-agent-plugins/apm-httpserver-core/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-httpserver-core diff --git a/apm-agent-plugins/apm-jakarta-websocket-plugin/pom.xml b/apm-agent-plugins/apm-jakarta-websocket-plugin/pom.xml index 06e4e69463..c60a31e44d 100644 --- a/apm-agent-plugins/apm-jakarta-websocket-plugin/pom.xml +++ b/apm-agent-plugins/apm-jakarta-websocket-plugin/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-jakarta-websocket-plugin diff --git a/apm-agent-plugins/apm-java-concurrent-plugin/pom.xml b/apm-agent-plugins/apm-java-concurrent-plugin/pom.xml index b182dbd8e7..c87a92c14d 100644 --- a/apm-agent-plugins/apm-java-concurrent-plugin/pom.xml +++ b/apm-agent-plugins/apm-java-concurrent-plugin/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-java-concurrent-plugin diff --git a/apm-agent-plugins/apm-java-ldap-plugin/pom.xml b/apm-agent-plugins/apm-java-ldap-plugin/pom.xml index 96bf17a825..2263c5dd1d 100644 --- a/apm-agent-plugins/apm-java-ldap-plugin/pom.xml +++ b/apm-agent-plugins/apm-java-ldap-plugin/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-java-ldap-plugin diff --git a/apm-agent-plugins/apm-javalin-plugin/pom.xml b/apm-agent-plugins/apm-javalin-plugin/pom.xml index 72d3615e04..a36e51557d 100644 --- a/apm-agent-plugins/apm-javalin-plugin/pom.xml +++ b/apm-agent-plugins/apm-javalin-plugin/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-javalin-plugin diff --git a/apm-agent-plugins/apm-jaxrs-plugin-jakartaee-test/pom.xml b/apm-agent-plugins/apm-jaxrs-plugin-jakartaee-test/pom.xml index f31c284347..2b1abf4e04 100644 --- a/apm-agent-plugins/apm-jaxrs-plugin-jakartaee-test/pom.xml +++ b/apm-agent-plugins/apm-jaxrs-plugin-jakartaee-test/pom.xml @@ -3,7 +3,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugins/apm-jaxrs-plugin/pom.xml b/apm-agent-plugins/apm-jaxrs-plugin/pom.xml index 9ee30678ed..45a0e56639 100644 --- a/apm-agent-plugins/apm-jaxrs-plugin/pom.xml +++ b/apm-agent-plugins/apm-jaxrs-plugin/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-jaxrs-plugin diff --git a/apm-agent-plugins/apm-jaxws-plugin-jakartaee-test/pom.xml b/apm-agent-plugins/apm-jaxws-plugin-jakartaee-test/pom.xml index 8356ea4a83..40d4a93f9a 100644 --- a/apm-agent-plugins/apm-jaxws-plugin-jakartaee-test/pom.xml +++ b/apm-agent-plugins/apm-jaxws-plugin-jakartaee-test/pom.xml @@ -3,7 +3,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugins/apm-jaxws-plugin/pom.xml b/apm-agent-plugins/apm-jaxws-plugin/pom.xml index e97b1acb0b..90a111b56c 100644 --- a/apm-agent-plugins/apm-jaxws-plugin/pom.xml +++ b/apm-agent-plugins/apm-jaxws-plugin/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-jaxws-plugin diff --git a/apm-agent-plugins/apm-jdbc-plugin/pom.xml b/apm-agent-plugins/apm-jdbc-plugin/pom.xml index 997d54e0e5..74f20b02a8 100644 --- a/apm-agent-plugins/apm-jdbc-plugin/pom.xml +++ b/apm-agent-plugins/apm-jdbc-plugin/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-jdbc-plugin diff --git a/apm-agent-plugins/apm-jdbc-plugin/src/main/java/co/elastic/apm/agent/jdbc/helper/JdbcConfiguration.java b/apm-agent-plugins/apm-jdbc-plugin/src/main/java/co/elastic/apm/agent/jdbc/helper/JdbcConfiguration.java new file mode 100644 index 0000000000..87dcfb976d --- /dev/null +++ b/apm-agent-plugins/apm-jdbc-plugin/src/main/java/co/elastic/apm/agent/jdbc/helper/JdbcConfiguration.java @@ -0,0 +1,52 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. 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. + */ +package co.elastic.apm.agent.jdbc.helper; + +import co.elastic.apm.agent.common.util.WildcardMatcher; +import co.elastic.apm.agent.tracer.configuration.WildcardMatcherValueConverter; +import org.stagemonitor.configuration.ConfigurationOption; +import org.stagemonitor.configuration.ConfigurationOptionProvider; +import org.stagemonitor.configuration.converter.DoubleValueConverter; +import org.stagemonitor.configuration.converter.ListValueConverter; +import org.stagemonitor.configuration.converter.StringValueConverter; + +import java.util.Arrays; +import java.util.List; + +public class JdbcConfiguration extends ConfigurationOptionProvider { + + private final ConfigurationOption> databaseMetaDataExclusionList = ConfigurationOption + .builder(new ListValueConverter(StringValueConverter.INSTANCE), List.class) + .key("exclude_from_getting_username") + .configurationCategory("Datastore") + .description("If any of these strings match part of the package or class name of the DatabaseMetaData instance, getUserName() won't be called" + + "\n" + + WildcardMatcher.DOCUMENTATION + ) + .tags("internal","added[1.49.0]") + .dynamic(true) + .buildWithDefault(Arrays.asList( + "hikari" + )); + + public List getDatabaseMetaDataExclusionList() { + return databaseMetaDataExclusionList.get(); + } + +} diff --git a/apm-agent-plugins/apm-jdbc-plugin/src/main/java/co/elastic/apm/agent/jdbc/helper/JdbcHelper.java b/apm-agent-plugins/apm-jdbc-plugin/src/main/java/co/elastic/apm/agent/jdbc/helper/JdbcHelper.java index 6853a14088..ca8f379e40 100644 --- a/apm-agent-plugins/apm-jdbc-plugin/src/main/java/co/elastic/apm/agent/jdbc/helper/JdbcHelper.java +++ b/apm-agent-plugins/apm-jdbc-plugin/src/main/java/co/elastic/apm/agent/jdbc/helper/JdbcHelper.java @@ -21,18 +21,21 @@ import co.elastic.apm.agent.sdk.internal.db.signature.Scanner; import co.elastic.apm.agent.sdk.internal.db.signature.SignatureParser; import co.elastic.apm.agent.tracer.AbstractSpan; +import co.elastic.apm.agent.tracer.GlobalTracer; import co.elastic.apm.agent.tracer.Span; import co.elastic.apm.agent.tracer.ElasticContext; import co.elastic.apm.agent.jdbc.JdbcFilter; import co.elastic.apm.agent.sdk.logging.Logger; import co.elastic.apm.agent.sdk.logging.LoggerFactory; import co.elastic.apm.agent.sdk.weakconcurrent.WeakMap; +import co.elastic.apm.agent.tracer.Tracer; import javax.annotation.Nullable; import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.SQLException; import java.sql.Statement; +import java.util.List; import java.util.concurrent.Callable; import static co.elastic.apm.agent.jdbc.helper.JdbcGlobalState.metaDataMap; @@ -45,6 +48,11 @@ public class JdbcHelper { public static final String DB_SPAN_ACTION = "query"; private static final JdbcHelper INSTANCE = new JdbcHelper(); + private final JdbcConfiguration config; + + public JdbcHelper() { + this.config = GlobalTracer.get().getConfig(JdbcConfiguration.class); + } public static JdbcHelper get() { return INSTANCE; @@ -181,7 +189,7 @@ private ConnectionMetaData getConnectionMetaData(@Nullable Connection connection DatabaseMetaData metaData = connection.getMetaData(); connectionMetaData = ConnectionMetaData.parse(metaData.getURL()) .withConnectionInstance(safeGetCatalog(connection)) - .withConnectionUser(metaData.getUserName()) + .withConnectionUser(maybeGetUserName(metaData, config)) .build(); if (logger.isDebugEnabled()) { @@ -201,6 +209,17 @@ private ConnectionMetaData getConnectionMetaData(@Nullable Connection connection return connectionMetaData; } + static String maybeGetUserName(DatabaseMetaData metaData, JdbcConfiguration config) throws SQLException { + List exclusionList = config.getDatabaseMetaDataExclusionList(); + String classname = metaData.getClass().getName(); + for (String exclude : exclusionList) { + if (classname.contains(exclude)) { + return null; + } + } + return metaData.getUserName(); + } + @Nullable private String safeGetCatalog(Connection connection) { String catalog = null; diff --git a/apm-agent-plugins/apm-jdbc-plugin/src/main/resources/META-INF/services/org.stagemonitor.configuration.ConfigurationOptionProvider b/apm-agent-plugins/apm-jdbc-plugin/src/main/resources/META-INF/services/org.stagemonitor.configuration.ConfigurationOptionProvider new file mode 100644 index 0000000000..38d62b1c55 --- /dev/null +++ b/apm-agent-plugins/apm-jdbc-plugin/src/main/resources/META-INF/services/org.stagemonitor.configuration.ConfigurationOptionProvider @@ -0,0 +1 @@ +co.elastic.apm.agent.jdbc.helper.JdbcConfiguration diff --git a/apm-agent-plugins/apm-jdbc-plugin/src/test/java/co/elastic/apm/agent/jdbc/helper/JdbcGetUserNameExclusionTest.java b/apm-agent-plugins/apm-jdbc-plugin/src/test/java/co/elastic/apm/agent/jdbc/helper/JdbcGetUserNameExclusionTest.java new file mode 100644 index 0000000000..5ff0962629 --- /dev/null +++ b/apm-agent-plugins/apm-jdbc-plugin/src/test/java/co/elastic/apm/agent/jdbc/helper/JdbcGetUserNameExclusionTest.java @@ -0,0 +1,77 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. 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. + */ +package co.elastic.apm.agent.jdbc.helper; + +import co.elastic.apm.agent.AbstractInstrumentationTest; +import co.elastic.apm.agent.MockTracer; +import co.elastic.apm.agent.bci.ElasticApmAgent; +import co.elastic.apm.agent.configuration.SpyConfiguration; +import co.elastic.apm.agent.impl.ElasticApmTracer; +import net.bytebuddy.agent.ByteBuddyAgent; +import org.junit.After; +import org.junit.BeforeClass; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.stagemonitor.configuration.ConfigurationRegistry; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.sql.DatabaseMetaData; +import java.sql.SQLException; +import java.util.List; + +import static co.elastic.apm.agent.testutils.assertions.Assertions.assertThat; +import static org.mockito.Mockito.doReturn; + +public class JdbcGetUserNameExclusionTest extends AbstractInstrumentationTest { + + protected static JdbcConfiguration jdbcconfig; + + @Test + public void hasUsernameCorrectlyExcludes() throws SQLException { + DatabaseMetaData meta = (DatabaseMetaData) Proxy.newProxyInstance( + this.getClass().getClassLoader(), + new Class[] { DatabaseMetaData.class }, + new MetadataInvocationHandler()); + + assertThat(JdbcHelper.maybeGetUserName(meta, config.getConfig(JdbcConfiguration.class))).isEqualTo("testuser"); + + String classname = meta.getClass().getName(); + String excludeName = classname.substring(classname.indexOf('$')+1); + doReturn(List.of(excludeName)) + .when(config.getConfig(JdbcConfiguration.class)) + .getDatabaseMetaDataExclusionList(); + + assertThat(JdbcHelper.maybeGetUserName(meta, config.getConfig(JdbcConfiguration.class))).isEqualTo(null); + } + + public class MetadataInvocationHandler implements InvocationHandler { + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + if (method.getName().equals("getUserName")) { + return "testuser"; + } + return null; + } + } + +} diff --git a/apm-agent-plugins/apm-jdk-httpclient-plugin/pom.xml b/apm-agent-plugins/apm-jdk-httpclient-plugin/pom.xml index cd638d2d04..6eb3481ba2 100644 --- a/apm-agent-plugins/apm-jdk-httpclient-plugin/pom.xml +++ b/apm-agent-plugins/apm-jdk-httpclient-plugin/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-jdk-httpclient-plugin diff --git a/apm-agent-plugins/apm-jdk-httpserver-plugin/pom.xml b/apm-agent-plugins/apm-jdk-httpserver-plugin/pom.xml index 0aefe8f0ba..9ec611014a 100644 --- a/apm-agent-plugins/apm-jdk-httpserver-plugin/pom.xml +++ b/apm-agent-plugins/apm-jdk-httpserver-plugin/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-jdk-httpserver-plugin diff --git a/apm-agent-plugins/apm-jms-plugin/apm-jms-jakarta/pom.xml b/apm-agent-plugins/apm-jms-plugin/apm-jms-jakarta/pom.xml index bd96256253..6d365048b9 100644 --- a/apm-agent-plugins/apm-jms-plugin/apm-jms-jakarta/pom.xml +++ b/apm-agent-plugins/apm-jms-plugin/apm-jms-jakarta/pom.xml @@ -3,7 +3,7 @@ apm-jms-plugin co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugins/apm-jms-plugin/apm-jms-javax/pom.xml b/apm-agent-plugins/apm-jms-plugin/apm-jms-javax/pom.xml index 9973007166..27471119bc 100644 --- a/apm-agent-plugins/apm-jms-plugin/apm-jms-javax/pom.xml +++ b/apm-agent-plugins/apm-jms-plugin/apm-jms-javax/pom.xml @@ -3,7 +3,7 @@ apm-jms-plugin co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugins/apm-jms-plugin/apm-jms-plugin-base/pom.xml b/apm-agent-plugins/apm-jms-plugin/apm-jms-plugin-base/pom.xml index e5089ad80d..33afe2abb0 100644 --- a/apm-agent-plugins/apm-jms-plugin/apm-jms-plugin-base/pom.xml +++ b/apm-agent-plugins/apm-jms-plugin/apm-jms-plugin-base/pom.xml @@ -5,7 +5,7 @@ apm-jms-plugin co.elastic.apm - 1.48.1 + 1.49.0 apm-jms-plugin-base diff --git a/apm-agent-plugins/apm-jms-plugin/apm-jms-spring-plugin/pom.xml b/apm-agent-plugins/apm-jms-plugin/apm-jms-spring-plugin/pom.xml index c427ab178b..39c4afcaf3 100644 --- a/apm-agent-plugins/apm-jms-plugin/apm-jms-spring-plugin/pom.xml +++ b/apm-agent-plugins/apm-jms-plugin/apm-jms-spring-plugin/pom.xml @@ -5,7 +5,7 @@ apm-jms-plugin co.elastic.apm - 1.48.1 + 1.49.0 apm-jms-spring-plugin diff --git a/apm-agent-plugins/apm-jms-plugin/pom.xml b/apm-agent-plugins/apm-jms-plugin/pom.xml index 2d4e692fe1..dc184d7c8f 100644 --- a/apm-agent-plugins/apm-jms-plugin/pom.xml +++ b/apm-agent-plugins/apm-jms-plugin/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-jms-plugin diff --git a/apm-agent-plugins/apm-jmx-plugin/pom.xml b/apm-agent-plugins/apm-jmx-plugin/pom.xml index 1112c40c13..b086bf9ba4 100644 --- a/apm-agent-plugins/apm-jmx-plugin/pom.xml +++ b/apm-agent-plugins/apm-jmx-plugin/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-jmx-plugin @@ -15,13 +15,4 @@ ${project.basedir}/../.. - - - - ${project.groupId} - apm-agent-core - ${project.version} - - - diff --git a/apm-agent-plugins/apm-jmx-plugin/src/main/java/co/elastic/apm/agent/jmx/JmxMetric.java b/apm-agent-plugins/apm-jmx-plugin/src/main/java/co/elastic/apm/agent/jmx/JmxMetric.java index 9fa1b4da6d..9409e810af 100644 --- a/apm-agent-plugins/apm-jmx-plugin/src/main/java/co/elastic/apm/agent/jmx/JmxMetric.java +++ b/apm-agent-plugins/apm-jmx-plugin/src/main/java/co/elastic/apm/agent/jmx/JmxMetric.java @@ -18,12 +18,11 @@ */ package co.elastic.apm.agent.jmx; -import co.elastic.apm.agent.metrics.Labels; +import co.elastic.apm.agent.tracer.metrics.Labels; import org.stagemonitor.configuration.converter.AbstractValueConverter; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import javax.management.MBeanServer; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; import java.util.ArrayList; diff --git a/apm-agent-plugins/apm-jmx-plugin/src/main/java/co/elastic/apm/agent/jmx/JmxMetricTracker.java b/apm-agent-plugins/apm-jmx-plugin/src/main/java/co/elastic/apm/agent/jmx/JmxMetricTracker.java index 5560f338a1..5c3733a639 100644 --- a/apm-agent-plugins/apm-jmx-plugin/src/main/java/co/elastic/apm/agent/jmx/JmxMetricTracker.java +++ b/apm-agent-plugins/apm-jmx-plugin/src/main/java/co/elastic/apm/agent/jmx/JmxMetricTracker.java @@ -18,16 +18,15 @@ */ package co.elastic.apm.agent.jmx; -import co.elastic.apm.agent.context.AbstractLifecycleListener; -import co.elastic.apm.agent.impl.ElasticApmTracer; -import co.elastic.apm.agent.metrics.DoubleSupplier; -import co.elastic.apm.agent.metrics.Labels; -import co.elastic.apm.agent.metrics.MetricRegistry; +import co.elastic.apm.agent.tracer.AbstractLifecycleListener; +import co.elastic.apm.agent.tracer.metrics.DoubleSupplier; +import co.elastic.apm.agent.tracer.Tracer; +import co.elastic.apm.agent.tracer.metrics.Labels; +import co.elastic.apm.agent.tracer.GlobalLocks; import co.elastic.apm.agent.sdk.internal.util.ExecutorUtils; import co.elastic.apm.agent.sdk.internal.util.PrivilegedActionUtils; import co.elastic.apm.agent.sdk.logging.Logger; import co.elastic.apm.agent.sdk.logging.LoggerFactory; -import co.elastic.apm.agent.tracer.GlobalLocks; import co.elastic.apm.agent.tracer.configuration.TimeDuration; import org.stagemonitor.configuration.ConfigurationOption; @@ -66,8 +65,8 @@ public class JmxMetricTracker extends AbstractLifecycleListener { private volatile Thread logManagerPropertyPoller; @Nullable private volatile MBeanServer server; + private final Tracer tracer; private final JmxConfiguration jmxConfiguration; - private final MetricRegistry metricRegistry; @Nullable private volatile NotificationListener listener; @@ -76,16 +75,16 @@ public class JmxMetricTracker extends AbstractLifecycleListener { @Nullable private ScheduledExecutorService retryExecutor; - public JmxMetricTracker(ElasticApmTracer tracer) { + public JmxMetricTracker(Tracer tracer) { + this.tracer = tracer; jmxConfiguration = tracer.getConfig(JmxConfiguration.class); - metricRegistry = tracer.getMetricRegistry(); // using a synchronized list so adding to the list does not require synchronization failedMetrics = Collections.synchronizedList(new ArrayList()); } @Override - public void start(ElasticApmTracer tracer) { + public void start(Tracer tracer) { ConfigurationOption.ChangeListener> captureJmxListener = new ConfigurationOption.ChangeListener>() { @Override public void onChange(ConfigurationOption configurationOption, List oldValue, List newValue) { @@ -197,10 +196,10 @@ public void onChange(ConfigurationOption configurationOption, List for (JmxMetricRegistration addedRegistration : removeAll(oldRegistrations, newRegistrations)) { - addedRegistration.register(platformMBeanServer, metricRegistry); + addedRegistration.register(platformMBeanServer, tracer); } for (JmxMetricRegistration deletedRegistration : removeAll(newRegistrations, oldRegistrations)) { - deletedRegistration.unregister(metricRegistry); + deletedRegistration.unregister(tracer); } } }); @@ -326,7 +325,7 @@ private static List removeAll(List removeFromThis, List toRemove) { private void register(List jmxMetrics, MBeanServer server, List failedMetrics) { for (JmxMetricRegistration registration : compileJmxMetricRegistrations(jmxMetrics, server, failedMetrics)) { - registration.register(server, metricRegistry); + registration.register(server, tracer); } } @@ -474,9 +473,9 @@ private JmxMetricRegistration(String metricName, Labels labels, String jmxAttrib } - void register(final MBeanServer server, final MetricRegistry metricRegistry) { + void register(final MBeanServer server, final Tracer tracer) { logger.debug("Registering JMX metric {} {}.{} as metric_name: {} labels: {}", objectName, jmxAttribute, compositeDataKey, metricName, labels); - metricRegistry.add(metricName, labels, new DoubleSupplier() { + tracer.addGauge(metricName, labels, new DoubleSupplier() { @Override public double get() { try { @@ -489,7 +488,7 @@ public double get() { return value; } catch (InstanceNotFoundException | AttributeNotFoundException e) { if (unsubscribeOnError) { - unregister(metricRegistry); + unregister(tracer); } return Double.NaN; } catch (Exception e) { @@ -499,9 +498,9 @@ public double get() { }); } - void unregister(MetricRegistry metricRegistry) { + void unregister(Tracer tracer) { logger.debug("Unregistering JMX metric {} {}.{} metric_name: {} labels: {}", objectName, jmxAttribute, compositeDataKey, metricName, labels); - metricRegistry.removeGauge(metricName, labels); + tracer.removeGauge(metricName, labels); } @Override diff --git a/apm-agent-plugins/apm-jmx-plugin/src/main/resources/META-INF/services/co.elastic.apm.agent.context.LifecycleListener b/apm-agent-plugins/apm-jmx-plugin/src/main/resources/META-INF/services/co.elastic.apm.agent.tracer.LifecycleListener similarity index 100% rename from apm-agent-plugins/apm-jmx-plugin/src/main/resources/META-INF/services/co.elastic.apm.agent.context.LifecycleListener rename to apm-agent-plugins/apm-jmx-plugin/src/main/resources/META-INF/services/co.elastic.apm.agent.tracer.LifecycleListener diff --git a/apm-agent-plugins/apm-jmx-plugin/src/test/java/co/elastic/apm/agent/jmx/JmxMetricTrackerTest.java b/apm-agent-plugins/apm-jmx-plugin/src/test/java/co/elastic/apm/agent/jmx/JmxMetricTrackerTest.java index cc8eeca851..640a374bde 100644 --- a/apm-agent-plugins/apm-jmx-plugin/src/test/java/co/elastic/apm/agent/jmx/JmxMetricTrackerTest.java +++ b/apm-agent-plugins/apm-jmx-plugin/src/test/java/co/elastic/apm/agent/jmx/JmxMetricTrackerTest.java @@ -21,7 +21,7 @@ import co.elastic.apm.agent.MockTracer; import co.elastic.apm.agent.configuration.SpyConfiguration; import co.elastic.apm.agent.impl.ElasticApmTracer; -import co.elastic.apm.agent.metrics.Labels; +import co.elastic.apm.agent.tracer.metrics.Labels; import co.elastic.apm.agent.metrics.MetricRegistry; import co.elastic.apm.agent.report.serialize.MetricRegistrySerializer; import org.junit.jupiter.api.AfterEach; diff --git a/apm-agent-plugins/apm-jsf-plugin/pom.xml b/apm-agent-plugins/apm-jsf-plugin/pom.xml index 7368aa8462..d2940944e1 100644 --- a/apm-agent-plugins/apm-jsf-plugin/pom.xml +++ b/apm-agent-plugins/apm-jsf-plugin/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-jsf-plugin diff --git a/apm-agent-plugins/apm-kafka-plugin/apm-kafka-base-plugin/pom.xml b/apm-agent-plugins/apm-kafka-plugin/apm-kafka-base-plugin/pom.xml index b0f150727a..b250536ff2 100644 --- a/apm-agent-plugins/apm-kafka-plugin/apm-kafka-base-plugin/pom.xml +++ b/apm-agent-plugins/apm-kafka-plugin/apm-kafka-base-plugin/pom.xml @@ -3,7 +3,7 @@ apm-kafka-plugin co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugins/apm-kafka-plugin/apm-kafka-headers-plugin/pom.xml b/apm-agent-plugins/apm-kafka-plugin/apm-kafka-headers-plugin/pom.xml index cdcd4d0462..ad0b8527b0 100644 --- a/apm-agent-plugins/apm-kafka-plugin/apm-kafka-headers-plugin/pom.xml +++ b/apm-agent-plugins/apm-kafka-plugin/apm-kafka-headers-plugin/pom.xml @@ -4,7 +4,7 @@ apm-kafka-plugin co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugins/apm-kafka-plugin/apm-kafka-spring-plugin/pom.xml b/apm-agent-plugins/apm-kafka-plugin/apm-kafka-spring-plugin/pom.xml index 82284c44a6..5dc62cbc7d 100644 --- a/apm-agent-plugins/apm-kafka-plugin/apm-kafka-spring-plugin/pom.xml +++ b/apm-agent-plugins/apm-kafka-plugin/apm-kafka-spring-plugin/pom.xml @@ -4,7 +4,7 @@ apm-kafka-plugin co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugins/apm-kafka-plugin/pom.xml b/apm-agent-plugins/apm-kafka-plugin/pom.xml index ac7ded3a3d..dc6c403130 100644 --- a/apm-agent-plugins/apm-kafka-plugin/pom.xml +++ b/apm-agent-plugins/apm-kafka-plugin/pom.xml @@ -3,7 +3,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugins/apm-logging-plugin/apm-jboss-logging-plugin/pom.xml b/apm-agent-plugins/apm-logging-plugin/apm-jboss-logging-plugin/pom.xml index e17343791c..c634b39c11 100644 --- a/apm-agent-plugins/apm-logging-plugin/apm-jboss-logging-plugin/pom.xml +++ b/apm-agent-plugins/apm-logging-plugin/apm-jboss-logging-plugin/pom.xml @@ -5,7 +5,7 @@ apm-logging-plugin co.elastic.apm - 1.48.1 + 1.49.0 apm-jboss-logging-plugin diff --git a/apm-agent-plugins/apm-logging-plugin/apm-jul-plugin/pom.xml b/apm-agent-plugins/apm-logging-plugin/apm-jul-plugin/pom.xml index 2d1c5a996c..ee67d929c8 100644 --- a/apm-agent-plugins/apm-logging-plugin/apm-jul-plugin/pom.xml +++ b/apm-agent-plugins/apm-logging-plugin/apm-jul-plugin/pom.xml @@ -5,7 +5,7 @@ apm-logging-plugin co.elastic.apm - 1.48.1 + 1.49.0 apm-jul-plugin diff --git a/apm-agent-plugins/apm-logging-plugin/apm-log4j1-plugin/pom.xml b/apm-agent-plugins/apm-logging-plugin/apm-log4j1-plugin/pom.xml index ca055fbf6b..ab55c53b33 100644 --- a/apm-agent-plugins/apm-logging-plugin/apm-log4j1-plugin/pom.xml +++ b/apm-agent-plugins/apm-logging-plugin/apm-log4j1-plugin/pom.xml @@ -5,7 +5,7 @@ apm-logging-plugin co.elastic.apm - 1.48.1 + 1.49.0 apm-log4j1-plugin diff --git a/apm-agent-plugins/apm-logging-plugin/apm-log4j2-plugin/pom.xml b/apm-agent-plugins/apm-logging-plugin/apm-log4j2-plugin/pom.xml index ae81294677..b53fc81013 100644 --- a/apm-agent-plugins/apm-logging-plugin/apm-log4j2-plugin/pom.xml +++ b/apm-agent-plugins/apm-logging-plugin/apm-log4j2-plugin/pom.xml @@ -5,7 +5,7 @@ apm-logging-plugin co.elastic.apm - 1.48.1 + 1.49.0 apm-log4j2-plugin @@ -24,7 +24,7 @@ org.apache.logging.log4j log4j-core - 2.23.0 + 2.23.1 provided diff --git a/apm-agent-plugins/apm-logging-plugin/apm-logback-plugin/apm-logback-plugin-impl/pom.xml b/apm-agent-plugins/apm-logging-plugin/apm-logback-plugin/apm-logback-plugin-impl/pom.xml index b00ffd019e..2bc3528efe 100644 --- a/apm-agent-plugins/apm-logging-plugin/apm-logback-plugin/apm-logback-plugin-impl/pom.xml +++ b/apm-agent-plugins/apm-logging-plugin/apm-logback-plugin/apm-logback-plugin-impl/pom.xml @@ -5,7 +5,7 @@ apm-logback-plugin co.elastic.apm - 1.48.1 + 1.49.0 apm-logback-plugin-impl diff --git a/apm-agent-plugins/apm-logging-plugin/apm-logback-plugin/apm-logback-plugin-legacy-tests/pom.xml b/apm-agent-plugins/apm-logging-plugin/apm-logback-plugin/apm-logback-plugin-legacy-tests/pom.xml index cee32d6fe1..71f1701839 100644 --- a/apm-agent-plugins/apm-logging-plugin/apm-logback-plugin/apm-logback-plugin-legacy-tests/pom.xml +++ b/apm-agent-plugins/apm-logging-plugin/apm-logback-plugin/apm-logback-plugin-legacy-tests/pom.xml @@ -5,7 +5,7 @@ apm-logback-plugin co.elastic.apm - 1.48.1 + 1.49.0 apm-logback-plugin-legacy-tests diff --git a/apm-agent-plugins/apm-logging-plugin/apm-logback-plugin/pom.xml b/apm-agent-plugins/apm-logging-plugin/apm-logback-plugin/pom.xml index 07edd698d3..e25365e8e8 100644 --- a/apm-agent-plugins/apm-logging-plugin/apm-logback-plugin/pom.xml +++ b/apm-agent-plugins/apm-logging-plugin/apm-logback-plugin/pom.xml @@ -5,7 +5,7 @@ apm-logging-plugin co.elastic.apm - 1.48.1 + 1.49.0 apm-logback-plugin diff --git a/apm-agent-plugins/apm-logging-plugin/apm-logging-plugin-common/pom.xml b/apm-agent-plugins/apm-logging-plugin/apm-logging-plugin-common/pom.xml index 17507eb097..5eaeaa5d2f 100644 --- a/apm-agent-plugins/apm-logging-plugin/apm-logging-plugin-common/pom.xml +++ b/apm-agent-plugins/apm-logging-plugin/apm-logging-plugin-common/pom.xml @@ -5,7 +5,7 @@ apm-logging-plugin co.elastic.apm - 1.48.1 + 1.49.0 apm-logging-plugin-common diff --git a/apm-agent-plugins/apm-logging-plugin/apm-slf4j-plugin/pom.xml b/apm-agent-plugins/apm-logging-plugin/apm-slf4j-plugin/pom.xml index d9b6b779ef..1da12350ba 100644 --- a/apm-agent-plugins/apm-logging-plugin/apm-slf4j-plugin/pom.xml +++ b/apm-agent-plugins/apm-logging-plugin/apm-slf4j-plugin/pom.xml @@ -5,7 +5,7 @@ apm-logging-plugin co.elastic.apm - 1.48.1 + 1.49.0 apm-slf4j-plugin diff --git a/apm-agent-plugins/apm-logging-plugin/apm-tomcat-logging-plugin/pom.xml b/apm-agent-plugins/apm-logging-plugin/apm-tomcat-logging-plugin/pom.xml index 5c6f251b4b..624b9e9829 100644 --- a/apm-agent-plugins/apm-logging-plugin/apm-tomcat-logging-plugin/pom.xml +++ b/apm-agent-plugins/apm-logging-plugin/apm-tomcat-logging-plugin/pom.xml @@ -5,7 +5,7 @@ apm-logging-plugin co.elastic.apm - 1.48.1 + 1.49.0 apm-tomcat-logging-plugin diff --git a/apm-agent-plugins/apm-logging-plugin/pom.xml b/apm-agent-plugins/apm-logging-plugin/pom.xml index 033cb42d4a..a64baaddbc 100644 --- a/apm-agent-plugins/apm-logging-plugin/pom.xml +++ b/apm-agent-plugins/apm-logging-plugin/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-logging-plugin diff --git a/apm-agent-plugins/apm-micrometer-plugin/pom.xml b/apm-agent-plugins/apm-micrometer-plugin/pom.xml index 101e463b63..1a5fbb68c0 100644 --- a/apm-agent-plugins/apm-micrometer-plugin/pom.xml +++ b/apm-agent-plugins/apm-micrometer-plugin/pom.xml @@ -3,7 +3,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 @@ -20,16 +20,10 @@ - - - ${project.groupId} - apm-agent-core - ${project.version} - io.micrometer micrometer-core - 1.12.2 + 1.12.4 provided diff --git a/apm-agent-plugins/apm-micrometer-plugin/src/main/java/co/elastic/apm/agent/micrometer/AbstractMicrometerInstrumentation.java b/apm-agent-plugins/apm-micrometer-plugin/src/main/java/co/elastic/apm/agent/micrometer/AbstractMicrometerInstrumentation.java index f9ac5ef254..056daf8df2 100644 --- a/apm-agent-plugins/apm-micrometer-plugin/src/main/java/co/elastic/apm/agent/micrometer/AbstractMicrometerInstrumentation.java +++ b/apm-agent-plugins/apm-micrometer-plugin/src/main/java/co/elastic/apm/agent/micrometer/AbstractMicrometerInstrumentation.java @@ -18,7 +18,6 @@ */ package co.elastic.apm.agent.micrometer; -import co.elastic.apm.agent.impl.ElasticApmTracer; import co.elastic.apm.agent.sdk.ElasticApmInstrumentation; import co.elastic.apm.agent.tracer.GlobalTracer; import co.elastic.apm.agent.tracer.Tracer; @@ -30,7 +29,7 @@ public abstract class AbstractMicrometerInstrumentation extends ElasticApmInstru private static final Tracer tracer = GlobalTracer.get(); - static final MicrometerMetricsReporter reporter = new MicrometerMetricsReporter(tracer.require(ElasticApmTracer.class)); + static final MicrometerMetricsReporter reporter = new MicrometerMetricsReporter(tracer); public Collection getInstrumentationGroupNames() { return Collections.singletonList("micrometer"); diff --git a/apm-agent-plugins/apm-micrometer-plugin/src/main/java/co/elastic/apm/agent/micrometer/MicrometerMeterRegistrySerializer.java b/apm-agent-plugins/apm-micrometer-plugin/src/main/java/co/elastic/apm/agent/micrometer/MicrometerMeterRegistrySerializer.java index 683df9632f..58048dde12 100644 --- a/apm-agent-plugins/apm-micrometer-plugin/src/main/java/co/elastic/apm/agent/micrometer/MicrometerMeterRegistrySerializer.java +++ b/apm-agent-plugins/apm-micrometer-plugin/src/main/java/co/elastic/apm/agent/micrometer/MicrometerMeterRegistrySerializer.java @@ -18,13 +18,13 @@ */ package co.elastic.apm.agent.micrometer; -import co.elastic.apm.agent.report.serialize.DslJsonSerializer; import co.elastic.apm.agent.sdk.internal.util.PrivilegedActionUtils; import co.elastic.apm.agent.sdk.logging.Logger; import co.elastic.apm.agent.sdk.logging.LoggerFactory; import co.elastic.apm.agent.sdk.weakconcurrent.WeakConcurrent; import co.elastic.apm.agent.sdk.weakconcurrent.WeakSet; import co.elastic.apm.agent.tracer.configuration.MetricsConfiguration; +import co.elastic.apm.agent.tracer.metrics.DslJsonUtil; import com.dslplatform.json.DslJson; import com.dslplatform.json.JsonWriter; import com.dslplatform.json.NumberConverter; @@ -100,14 +100,14 @@ boolean serializeMetricSet(List tags, List meters, long epochMicros, boolean dedotMetricName = config.isDedotCustomMetrics(); jw.writeByte(JsonWriter.OBJECT_START); { - DslJsonSerializer.writeFieldName("metricset", jw); + DslJsonUtil.writeFieldName("metricset", jw); jw.writeByte(JsonWriter.OBJECT_START); { - DslJsonSerializer.writeFieldName("timestamp", jw); + DslJsonUtil.writeFieldName("timestamp", jw); NumberConverter.serialize(epochMicros, jw); jw.writeByte(JsonWriter.COMMA); serializeTags(tags, replaceBuilder, jw); - DslJsonSerializer.writeFieldName("samples", jw); + DslJsonUtil.writeFieldName("samples", jw); jw.writeByte(JsonWriter.OBJECT_START); ClassLoader originalContextCL = PrivilegedActionUtils.getContextClassLoader(Thread.currentThread()); @@ -167,16 +167,16 @@ private static void serializeTags(List tags, StringBuilder replaceBuilder, if (tags.isEmpty()) { return; } - DslJsonSerializer.writeFieldName("tags", jw); + DslJsonUtil.writeFieldName("tags", jw); jw.writeByte(OBJECT_START); for (int i = 0, tagsSize = tags.size(); i < tagsSize; i++) { Tag tag = tags.get(i); if (i > 0) { jw.writeByte(COMMA); } - DslJsonSerializer.writeStringValue(DslJsonSerializer.sanitizePropertyName(tag.getKey(), replaceBuilder), replaceBuilder, jw); + DslJsonUtil.writeStringValue(DslJsonUtil.sanitizePropertyName(tag.getKey(), replaceBuilder), replaceBuilder, jw); jw.writeByte(JsonWriter.SEMI); - DslJsonSerializer.writeStringValue(tag.getValue(), replaceBuilder, jw); + DslJsonUtil.writeStringValue(tag.getValue(), replaceBuilder, jw); } jw.writeByte(OBJECT_END); jw.writeByte(COMMA); @@ -320,7 +320,7 @@ private static void serializeValueStart(String key, String suffix, JsonWriter jw private static void serializeObjectStart(String key, String objectName, String suffix, JsonWriter jw, StringBuilder replaceBuilder, boolean dedotMetricName) { replaceBuilder.setLength(0); if (dedotMetricName) { - DslJsonSerializer.sanitizePropertyName(key, replaceBuilder); + DslJsonUtil.sanitizePropertyName(key, replaceBuilder); } else { replaceBuilder.append(key); } diff --git a/apm-agent-plugins/apm-micrometer-plugin/src/main/java/co/elastic/apm/agent/micrometer/MicrometerMetricsReporter.java b/apm-agent-plugins/apm-micrometer-plugin/src/main/java/co/elastic/apm/agent/micrometer/MicrometerMetricsReporter.java index 3379ce66cd..6ec9e2cbaa 100644 --- a/apm-agent-plugins/apm-micrometer-plugin/src/main/java/co/elastic/apm/agent/micrometer/MicrometerMetricsReporter.java +++ b/apm-agent-plugins/apm-micrometer-plugin/src/main/java/co/elastic/apm/agent/micrometer/MicrometerMetricsReporter.java @@ -18,14 +18,12 @@ */ package co.elastic.apm.agent.micrometer; -import co.elastic.apm.agent.impl.ElasticApmTracer; -import co.elastic.apm.agent.impl.Tracer; import co.elastic.apm.agent.common.util.WildcardMatcher; -import co.elastic.apm.agent.report.Reporter; import co.elastic.apm.agent.sdk.logging.Logger; import co.elastic.apm.agent.sdk.logging.LoggerFactory; import co.elastic.apm.agent.sdk.weakconcurrent.WeakConcurrent; import co.elastic.apm.agent.sdk.weakconcurrent.WeakMap; +import co.elastic.apm.agent.tracer.Tracer; import co.elastic.apm.agent.tracer.configuration.MetricsConfiguration; import co.elastic.apm.agent.tracer.configuration.ReporterConfiguration; import com.dslplatform.json.JsonWriter; @@ -90,19 +88,17 @@ public class MicrometerMetricsReporter implements Runnable, Closeable { private final WeakMap meterRegistries = WeakConcurrent.buildMap(); private final WeakMap configMap = WeakConcurrent.buildMap(); private final MicrometerMeterRegistrySerializer serializer; - private final Reporter reporter; - private final ElasticApmTracer tracer; + private final Tracer tracer; private final AtomicBoolean scheduledReporting = new AtomicBoolean(); private final boolean disableScheduler; - public MicrometerMetricsReporter(ElasticApmTracer tracer) { + public MicrometerMetricsReporter(Tracer tracer) { this(tracer, false); } //constructor split up to have this available for testing - MicrometerMetricsReporter(ElasticApmTracer tracer, boolean disableSchedulerThread) { + MicrometerMetricsReporter(Tracer tracer, boolean disableSchedulerThread) { this.tracer = tracer; - this.reporter = tracer.getReporter(); tracer.addShutdownHook(this); serializer = new MicrometerMeterRegistrySerializer(tracer.getConfig(MetricsConfiguration.class)); this.disableScheduler = disableSchedulerThread; @@ -135,7 +131,7 @@ private synchronized void scheduleReporting() { // called for every class loader that loaded micrometer // that's because a new MicrometerMetricsReporter instance is created in every IndyPluginClassLoader // for example if multiple webapps use potentially different versions of Micrometer - tracer.getSharedSingleThreadedPool().scheduleAtFixedRate(this, 0, INTERVAL_BETWEEN_CHECKS_IN_MILLISECONDS, TimeUnit.MILLISECONDS); + tracer.schedule(this, INTERVAL_BETWEEN_CHECKS_IN_MILLISECONDS, TimeUnit.MILLISECONDS); } } @@ -147,7 +143,7 @@ public void run() { //run split up to have this available for testing void run(final long now) { - if (tracer.getState() != Tracer.TracerState.RUNNING) { + if (!tracer.isRunning()) { return; } long metricsIntervalMs = tracer.getConfig(ReporterConfiguration.class).getMetricsIntervalMs(); @@ -190,7 +186,7 @@ void run(final long now) { } logger.debug("Reporting {} meters", meterConsumer.meters.size()); for (JsonWriter serializedMetricSet : serializer.serialize(meterConsumer.meters, now * 1000)) { - reporter.reportMetrics(serializedMetricSet); + tracer.reportMetric(serializedMetricSet); } } @@ -220,7 +216,7 @@ private long getStep(MeterRegistry meterRegistry) { public void close() { // flushing out metrics before shutting down // this is especially important for counters as the counts that were accumulated between the last report and the shutdown would otherwise get lost - tracer.getSharedSingleThreadedPool().submit(this); + tracer.submit(this); } private static class MeterMapConsumer implements Consumer { diff --git a/apm-agent-plugins/apm-mongodb/apm-mongodb-common/pom.xml b/apm-agent-plugins/apm-mongodb/apm-mongodb-common/pom.xml index c8c68661bc..bc303c0d7b 100644 --- a/apm-agent-plugins/apm-mongodb/apm-mongodb-common/pom.xml +++ b/apm-agent-plugins/apm-mongodb/apm-mongodb-common/pom.xml @@ -4,7 +4,7 @@ apm-mongodb co.elastic.apm - 1.48.1 + 1.49.0 diff --git a/apm-agent-plugins/apm-mongodb/apm-mongodb3-plugin/pom.xml b/apm-agent-plugins/apm-mongodb/apm-mongodb3-plugin/pom.xml index f9a8903c3f..6e257d53a4 100644 --- a/apm-agent-plugins/apm-mongodb/apm-mongodb3-plugin/pom.xml +++ b/apm-agent-plugins/apm-mongodb/apm-mongodb3-plugin/pom.xml @@ -3,7 +3,7 @@ apm-mongodb co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugins/apm-mongodb/apm-mongodb4-plugin/pom.xml b/apm-agent-plugins/apm-mongodb/apm-mongodb4-plugin/pom.xml index 09cb31f444..7dfdd18eda 100644 --- a/apm-agent-plugins/apm-mongodb/apm-mongodb4-plugin/pom.xml +++ b/apm-agent-plugins/apm-mongodb/apm-mongodb4-plugin/pom.xml @@ -5,7 +5,7 @@ apm-mongodb co.elastic.apm - 1.48.1 + 1.49.0 apm-mongodb4-plugin diff --git a/apm-agent-plugins/apm-mongodb/pom.xml b/apm-agent-plugins/apm-mongodb/pom.xml index ec8ee44c4e..6db3400406 100644 --- a/apm-agent-plugins/apm-mongodb/pom.xml +++ b/apm-agent-plugins/apm-mongodb/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-mongodb diff --git a/apm-agent-plugins/apm-okhttp-plugin/pom.xml b/apm-agent-plugins/apm-okhttp-plugin/pom.xml index 5ee95563c0..30822c0400 100644 --- a/apm-agent-plugins/apm-okhttp-plugin/pom.xml +++ b/apm-agent-plugins/apm-okhttp-plugin/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-okhttp-plugin diff --git a/apm-agent-plugins/apm-okhttp-test/pom.xml b/apm-agent-plugins/apm-okhttp-test/pom.xml index 1784e3a205..2a541552a3 100644 --- a/apm-agent-plugins/apm-okhttp-test/pom.xml +++ b/apm-agent-plugins/apm-okhttp-test/pom.xml @@ -3,7 +3,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-embedded-metrics-sdk/pom.xml b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-embedded-metrics-sdk/pom.xml index 2cd72d452c..7800ac6b1c 100644 --- a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-embedded-metrics-sdk/pom.xml +++ b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-embedded-metrics-sdk/pom.xml @@ -4,7 +4,7 @@ co.elastic.apm apm-opentelemetry - 1.48.1 + 1.49.0 apm-opentelemetry-embedded-metrics-sdk diff --git a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-embedded-metrics-sdk/src/main/java/co/elastic/apm/agent/embeddedotel/EmbeddedSdkManager.java b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-embedded-metrics-sdk/src/main/java/co/elastic/apm/agent/embeddedotel/EmbeddedSdkManager.java index 9793bbbe76..95c57c60c3 100644 --- a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-embedded-metrics-sdk/src/main/java/co/elastic/apm/agent/embeddedotel/EmbeddedSdkManager.java +++ b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-embedded-metrics-sdk/src/main/java/co/elastic/apm/agent/embeddedotel/EmbeddedSdkManager.java @@ -18,11 +18,11 @@ */ package co.elastic.apm.agent.embeddedotel; -import co.elastic.apm.agent.context.AbstractLifecycleListener; +import co.elastic.apm.agent.tracer.AbstractLifecycleListener; import co.elastic.apm.agent.embeddedotel.proxy.ProxyMeterProvider; -import co.elastic.apm.agent.impl.ElasticApmTracer; import co.elastic.apm.agent.sdk.logging.Logger; import co.elastic.apm.agent.sdk.logging.LoggerFactory; +import co.elastic.apm.agent.tracer.Tracer; import io.opentelemetry.sdk.metrics.SdkMeterProvider; import io.opentelemetry.sdk.metrics.SdkMeterProviderBuilder; @@ -40,14 +40,14 @@ public class EmbeddedSdkManager extends AbstractLifecycleListener { private static final Logger logger = LoggerFactory.getLogger(EmbeddedSdkManager.class); @Nullable - private ElasticApmTracer tracer; + private Tracer tracer; @Nullable private volatile SdkMeterProvider sdkInstance; private boolean isShutdown = false; @Override - public synchronized void start(ElasticApmTracer tracer) throws Exception { + public synchronized void start(Tracer tracer) throws Exception { this.tracer = tracer; } diff --git a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-embedded-metrics-sdk/src/main/resources/META-INF/services/co.elastic.apm.agent.context.LifecycleListener b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-embedded-metrics-sdk/src/main/resources/META-INF/services/co.elastic.apm.agent.tracer.LifecycleListener similarity index 100% rename from apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-embedded-metrics-sdk/src/main/resources/META-INF/services/co.elastic.apm.agent.context.LifecycleListener rename to apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-embedded-metrics-sdk/src/main/resources/META-INF/services/co.elastic.apm.agent.tracer.LifecycleListener diff --git a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metrics-bridge-parent/apm-opentelemetry-metrics-bridge-common/pom.xml b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metrics-bridge-parent/apm-opentelemetry-metrics-bridge-common/pom.xml index bd703e7427..d28deb47dd 100644 --- a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metrics-bridge-parent/apm-opentelemetry-metrics-bridge-common/pom.xml +++ b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metrics-bridge-parent/apm-opentelemetry-metrics-bridge-common/pom.xml @@ -3,7 +3,7 @@ apm-opentelemetry-metrics-bridge-parent co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metrics-bridge-parent/apm-opentelemetry-metrics-bridge-latest/pom.xml b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metrics-bridge-parent/apm-opentelemetry-metrics-bridge-latest/pom.xml index 70635e304b..3e536371c6 100644 --- a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metrics-bridge-parent/apm-opentelemetry-metrics-bridge-latest/pom.xml +++ b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metrics-bridge-parent/apm-opentelemetry-metrics-bridge-latest/pom.xml @@ -3,7 +3,7 @@ apm-opentelemetry-metrics-bridge-parent co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metrics-bridge-parent/apm-opentelemetry-metrics-bridge-v1_14/pom.xml b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metrics-bridge-parent/apm-opentelemetry-metrics-bridge-v1_14/pom.xml index dfd9e5b293..4c8eb9ee99 100644 --- a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metrics-bridge-parent/apm-opentelemetry-metrics-bridge-v1_14/pom.xml +++ b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metrics-bridge-parent/apm-opentelemetry-metrics-bridge-v1_14/pom.xml @@ -3,7 +3,7 @@ apm-opentelemetry-metrics-bridge-parent co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metrics-bridge-parent/pom.xml b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metrics-bridge-parent/pom.xml index d488231fd5..33500a984c 100644 --- a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metrics-bridge-parent/pom.xml +++ b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metrics-bridge-parent/pom.xml @@ -3,7 +3,7 @@ apm-opentelemetry co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metricsdk-plugin/pom.xml b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metricsdk-plugin/pom.xml index 1266170f5d..4aa623a588 100644 --- a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metricsdk-plugin/pom.xml +++ b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metricsdk-plugin/pom.xml @@ -4,7 +4,7 @@ co.elastic.apm apm-opentelemetry - 1.48.1 + 1.49.0 apm-opentelemetry-metricsdk-plugin diff --git a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metricsdk-plugin/src/main/java/co/elastic/apm/agent/otelmetricsdk/MetricSetSerializer.java b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metricsdk-plugin/src/main/java/co/elastic/apm/agent/otelmetricsdk/MetricSetSerializer.java index de8021c3bd..6484e08906 100644 --- a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metricsdk-plugin/src/main/java/co/elastic/apm/agent/otelmetricsdk/MetricSetSerializer.java +++ b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metricsdk-plugin/src/main/java/co/elastic/apm/agent/otelmetricsdk/MetricSetSerializer.java @@ -19,7 +19,7 @@ package co.elastic.apm.agent.otelmetricsdk; import co.elastic.apm.agent.report.Reporter; -import co.elastic.apm.agent.report.serialize.DslJsonSerializer; +import co.elastic.apm.agent.tracer.metrics.DslJsonUtil; import com.dslplatform.json.BoolConverter; import com.dslplatform.json.DslJson; import com.dslplatform.json.JsonWriter; @@ -56,14 +56,14 @@ public MetricSetSerializer(Attributes attributes, CharSequence instrumentationSc jw = DSL_JSON.newWriter(INITIAL_BUFFER_SIZE); jw.writeByte(JsonWriter.OBJECT_START); { - DslJsonSerializer.writeFieldName("metricset", jw); + DslJsonUtil.writeFieldName("metricset", jw); jw.writeByte(JsonWriter.OBJECT_START); { - DslJsonSerializer.writeFieldName("timestamp", jw); + DslJsonUtil.writeFieldName("timestamp", jw); NumberConverter.serialize(epochMicros, jw); jw.writeByte(JsonWriter.COMMA); serializeAttributes(instrumentationScopeName, attributes); - DslJsonSerializer.writeFieldName("samples", jw); + DslJsonUtil.writeFieldName("samples", jw); jw.writeByte(JsonWriter.OBJECT_START); } } @@ -188,7 +188,7 @@ private void serializeAttributes(CharSequence instrumentationScopeName, Attribut if (attributeMap.isEmpty() && instrumentationScopeName.length() == 0) { return; } - DslJsonSerializer.writeFieldName("tags", jw); + DslJsonUtil.writeFieldName("tags", jw); jw.writeByte(OBJECT_START); boolean anyWritten = false; if (instrumentationScopeName.length() > 0) { @@ -210,7 +210,7 @@ private boolean serializeAttribute(AttributeKey key, @Nullable Object value, if (prependComma) { jw.writeByte(COMMA); } - DslJsonSerializer.writeStringValue(DslJsonSerializer.sanitizePropertyName(key.getKey(), replaceBuilder), replaceBuilder, jw); + DslJsonUtil.writeStringValue(DslJsonUtil.sanitizePropertyName(key.getKey(), replaceBuilder), replaceBuilder, jw); jw.writeByte(JsonWriter.SEMI); AttributeType type = key.getType(); diff --git a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-plugin/pom.xml b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-plugin/pom.xml index 0d34df9662..8a26722207 100644 --- a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-plugin/pom.xml +++ b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-plugin/pom.xml @@ -4,7 +4,7 @@ co.elastic.apm apm-opentelemetry - 1.48.1 + 1.49.0 apm-opentelemetry-plugin diff --git a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-test/pom.xml b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-test/pom.xml index 0491af15dc..03b4573f92 100644 --- a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-test/pom.xml +++ b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-test/pom.xml @@ -4,7 +4,7 @@ co.elastic.apm apm-opentelemetry - 1.48.1 + 1.49.0 ${project.groupId}:${project.artifactId} diff --git a/apm-agent-plugins/apm-opentelemetry/pom.xml b/apm-agent-plugins/apm-opentelemetry/pom.xml index 2f16505192..9171c625c5 100644 --- a/apm-agent-plugins/apm-opentelemetry/pom.xml +++ b/apm-agent-plugins/apm-opentelemetry/pom.xml @@ -5,7 +5,7 @@ co.elastic.apm apm-agent-plugins - 1.48.1 + 1.49.0 apm-opentelemetry diff --git a/apm-agent-plugins/apm-opentracing-plugin/pom.xml b/apm-agent-plugins/apm-opentracing-plugin/pom.xml index ae90005844..be27c04d20 100644 --- a/apm-agent-plugins/apm-opentracing-plugin/pom.xml +++ b/apm-agent-plugins/apm-opentracing-plugin/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-opentracing-plugin diff --git a/apm-agent-plugins/apm-process-plugin/pom.xml b/apm-agent-plugins/apm-process-plugin/pom.xml index 0111e938da..533ed6b78c 100644 --- a/apm-agent-plugins/apm-process-plugin/pom.xml +++ b/apm-agent-plugins/apm-process-plugin/pom.xml @@ -3,7 +3,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugins/apm-profiling-plugin/pom.xml b/apm-agent-plugins/apm-profiling-plugin/pom.xml index 37e3cdc23d..7c54ea6958 100644 --- a/apm-agent-plugins/apm-profiling-plugin/pom.xml +++ b/apm-agent-plugins/apm-profiling-plugin/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-profiling-plugin diff --git a/apm-agent-plugins/apm-profiling-plugin/src/main/java/co/elastic/apm/agent/profiler/ProfilingFactory.java b/apm-agent-plugins/apm-profiling-plugin/src/main/java/co/elastic/apm/agent/profiler/ProfilingFactory.java index 400e28623c..e7ddcb77a4 100644 --- a/apm-agent-plugins/apm-profiling-plugin/src/main/java/co/elastic/apm/agent/profiler/ProfilingFactory.java +++ b/apm-agent-plugins/apm-profiling-plugin/src/main/java/co/elastic/apm/agent/profiler/ProfilingFactory.java @@ -18,8 +18,9 @@ */ package co.elastic.apm.agent.profiler; -import co.elastic.apm.agent.context.AbstractLifecycleListener; +import co.elastic.apm.agent.tracer.AbstractLifecycleListener; import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.tracer.Tracer; public class ProfilingFactory extends AbstractLifecycleListener { @@ -35,9 +36,10 @@ public ProfilingFactory(ElasticApmTracer tracer) { } @Override - public void start(ElasticApmTracer tracer) { + public void start(Tracer tracer) throws Exception { profiler.start(tracer); - tracer.registerSpanListener(new ProfilingActivationListener(tracer, profiler)); + ElasticApmTracer elasticApmTracer = tracer.require(ElasticApmTracer.class); + elasticApmTracer.registerSpanListener(new ProfilingActivationListener(elasticApmTracer, profiler)); } @Override diff --git a/apm-agent-plugins/apm-profiling-plugin/src/main/java/co/elastic/apm/agent/profiler/SamplingProfiler.java b/apm-agent-plugins/apm-profiling-plugin/src/main/java/co/elastic/apm/agent/profiler/SamplingProfiler.java index 1a33248b5a..0c8cb3f674 100644 --- a/apm-agent-plugins/apm-profiling-plugin/src/main/java/co/elastic/apm/agent/profiler/SamplingProfiler.java +++ b/apm-agent-plugins/apm-profiling-plugin/src/main/java/co/elastic/apm/agent/profiler/SamplingProfiler.java @@ -19,7 +19,7 @@ package co.elastic.apm.agent.profiler; import co.elastic.apm.agent.common.util.WildcardMatcher; -import co.elastic.apm.agent.context.AbstractLifecycleListener; +import co.elastic.apm.agent.tracer.AbstractLifecycleListener; import co.elastic.apm.agent.impl.ElasticApmTracer; import co.elastic.apm.agent.impl.transaction.Span; import co.elastic.apm.agent.impl.transaction.StackFrame; @@ -30,6 +30,7 @@ import co.elastic.apm.agent.sdk.internal.util.ExecutorUtils; import co.elastic.apm.agent.sdk.logging.Logger; import co.elastic.apm.agent.sdk.logging.LoggerFactory; +import co.elastic.apm.agent.tracer.Tracer; import co.elastic.apm.agent.tracer.configuration.CoreConfiguration; import co.elastic.apm.agent.tracer.configuration.TimeDuration; import co.elastic.apm.agent.tracer.pooling.Allocator; @@ -697,7 +698,7 @@ void copyFromFiles(Path activationEvents, Path traces) throws IOException { } @Override - public void start(ElasticApmTracer tracer) { + public void start(Tracer tracer) { scheduler.submit(this); } diff --git a/apm-agent-plugins/apm-profiling-plugin/src/main/resources/META-INF/services/co.elastic.apm.agent.context.LifecycleListener b/apm-agent-plugins/apm-profiling-plugin/src/main/resources/META-INF/services/co.elastic.apm.agent.tracer.LifecycleListener similarity index 100% rename from apm-agent-plugins/apm-profiling-plugin/src/main/resources/META-INF/services/co.elastic.apm.agent.context.LifecycleListener rename to apm-agent-plugins/apm-profiling-plugin/src/main/resources/META-INF/services/co.elastic.apm.agent.tracer.LifecycleListener diff --git a/apm-agent-plugins/apm-quartz/apm-quartz-common/pom.xml b/apm-agent-plugins/apm-quartz/apm-quartz-common/pom.xml index 403bbf01dc..5edcec6136 100644 --- a/apm-agent-plugins/apm-quartz/apm-quartz-common/pom.xml +++ b/apm-agent-plugins/apm-quartz/apm-quartz-common/pom.xml @@ -3,7 +3,7 @@ apm-quartz co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugins/apm-quartz/apm-quartz-plugin-1/pom.xml b/apm-agent-plugins/apm-quartz/apm-quartz-plugin-1/pom.xml index 234b339ee0..2d5a1baf8b 100644 --- a/apm-agent-plugins/apm-quartz/apm-quartz-plugin-1/pom.xml +++ b/apm-agent-plugins/apm-quartz/apm-quartz-plugin-1/pom.xml @@ -3,7 +3,7 @@ apm-quartz co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugins/apm-quartz/apm-quartz-plugin-2/pom.xml b/apm-agent-plugins/apm-quartz/apm-quartz-plugin-2/pom.xml index 3504cf38dc..f971adf098 100644 --- a/apm-agent-plugins/apm-quartz/apm-quartz-plugin-2/pom.xml +++ b/apm-agent-plugins/apm-quartz/apm-quartz-plugin-2/pom.xml @@ -3,7 +3,7 @@ apm-quartz co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugins/apm-quartz/pom.xml b/apm-agent-plugins/apm-quartz/pom.xml index 816532c5b2..9c26ec94ad 100644 --- a/apm-agent-plugins/apm-quartz/pom.xml +++ b/apm-agent-plugins/apm-quartz/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-quartz diff --git a/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-plugin/pom.xml b/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-plugin/pom.xml index 0b5ce43811..ea32ca0f82 100644 --- a/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-plugin/pom.xml +++ b/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-plugin/pom.xml @@ -5,7 +5,7 @@ apm-rabbitmq co.elastic.apm - 1.48.1 + 1.49.0 apm-rabbitmq-plugin diff --git a/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-spring/pom.xml b/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-spring/pom.xml index 9c0cbdd2b8..be3e19e6a1 100644 --- a/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-spring/pom.xml +++ b/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-spring/pom.xml @@ -5,7 +5,7 @@ apm-rabbitmq co.elastic.apm - 1.48.1 + 1.49.0 apm-rabbitmq-spring diff --git a/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-test-3/pom.xml b/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-test-3/pom.xml index 4bb6c21fdc..83a7c279cc 100644 --- a/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-test-3/pom.xml +++ b/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-test-3/pom.xml @@ -5,7 +5,7 @@ apm-rabbitmq co.elastic.apm - 1.48.1 + 1.49.0 apm-rabbitmq-test-3 diff --git a/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-test-4/pom.xml b/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-test-4/pom.xml index 26095b556a..a87c19884d 100644 --- a/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-test-4/pom.xml +++ b/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-test-4/pom.xml @@ -5,7 +5,7 @@ apm-rabbitmq co.elastic.apm - 1.48.1 + 1.49.0 apm-rabbitmq-test-4 diff --git a/apm-agent-plugins/apm-rabbitmq/pom.xml b/apm-agent-plugins/apm-rabbitmq/pom.xml index a3659d7921..e0a2323da9 100644 --- a/apm-agent-plugins/apm-rabbitmq/pom.xml +++ b/apm-agent-plugins/apm-rabbitmq/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-rabbitmq diff --git a/apm-agent-plugins/apm-reactor-plugin/pom.xml b/apm-agent-plugins/apm-reactor-plugin/pom.xml index 111a6febac..9e538c6043 100644 --- a/apm-agent-plugins/apm-reactor-plugin/pom.xml +++ b/apm-agent-plugins/apm-reactor-plugin/pom.xml @@ -5,7 +5,7 @@ co.elastic.apm apm-agent-plugins - 1.48.1 + 1.49.0 apm-reactor-plugin diff --git a/apm-agent-plugins/apm-redis-plugin/apm-jedis-2-tests/pom.xml b/apm-agent-plugins/apm-redis-plugin/apm-jedis-2-tests/pom.xml index c94d152b40..1d7bec2069 100644 --- a/apm-agent-plugins/apm-redis-plugin/apm-jedis-2-tests/pom.xml +++ b/apm-agent-plugins/apm-redis-plugin/apm-jedis-2-tests/pom.xml @@ -5,7 +5,7 @@ apm-redis-plugin co.elastic.apm - 1.48.1 + 1.49.0 apm-jedis-2-tests diff --git a/apm-agent-plugins/apm-redis-plugin/apm-jedis-3-tests/pom.xml b/apm-agent-plugins/apm-redis-plugin/apm-jedis-3-tests/pom.xml index e8c2de4861..a0fe35c569 100644 --- a/apm-agent-plugins/apm-redis-plugin/apm-jedis-3-tests/pom.xml +++ b/apm-agent-plugins/apm-redis-plugin/apm-jedis-3-tests/pom.xml @@ -5,7 +5,7 @@ apm-redis-plugin co.elastic.apm - 1.48.1 + 1.49.0 apm-jedis-3-tests diff --git a/apm-agent-plugins/apm-redis-plugin/apm-jedis-4-plugin/pom.xml b/apm-agent-plugins/apm-redis-plugin/apm-jedis-4-plugin/pom.xml index e9673307ed..9c6fcc4a4d 100644 --- a/apm-agent-plugins/apm-redis-plugin/apm-jedis-4-plugin/pom.xml +++ b/apm-agent-plugins/apm-redis-plugin/apm-jedis-4-plugin/pom.xml @@ -5,7 +5,7 @@ apm-redis-plugin co.elastic.apm - 1.48.1 + 1.49.0 apm-jedis-4-plugin diff --git a/apm-agent-plugins/apm-redis-plugin/apm-jedis-5-tests/pom.xml b/apm-agent-plugins/apm-redis-plugin/apm-jedis-5-tests/pom.xml index e4900c367e..d944984596 100644 --- a/apm-agent-plugins/apm-redis-plugin/apm-jedis-5-tests/pom.xml +++ b/apm-agent-plugins/apm-redis-plugin/apm-jedis-5-tests/pom.xml @@ -5,7 +5,7 @@ apm-redis-plugin co.elastic.apm - 1.48.1 + 1.49.0 apm-jedis-5-tests diff --git a/apm-agent-plugins/apm-redis-plugin/apm-jedis-plugin/pom.xml b/apm-agent-plugins/apm-redis-plugin/apm-jedis-plugin/pom.xml index f24e4bc799..f584237c3e 100644 --- a/apm-agent-plugins/apm-redis-plugin/apm-jedis-plugin/pom.xml +++ b/apm-agent-plugins/apm-redis-plugin/apm-jedis-plugin/pom.xml @@ -5,7 +5,7 @@ apm-redis-plugin co.elastic.apm - 1.48.1 + 1.49.0 apm-jedis-plugin diff --git a/apm-agent-plugins/apm-redis-plugin/apm-lettuce-3-tests/pom.xml b/apm-agent-plugins/apm-redis-plugin/apm-lettuce-3-tests/pom.xml index e45daa53c3..d95aae9259 100644 --- a/apm-agent-plugins/apm-redis-plugin/apm-lettuce-3-tests/pom.xml +++ b/apm-agent-plugins/apm-redis-plugin/apm-lettuce-3-tests/pom.xml @@ -3,7 +3,7 @@ apm-redis-plugin co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugins/apm-redis-plugin/apm-lettuce-plugin/pom.xml b/apm-agent-plugins/apm-redis-plugin/apm-lettuce-plugin/pom.xml index 3fde25d809..514ffe48f8 100644 --- a/apm-agent-plugins/apm-redis-plugin/apm-lettuce-plugin/pom.xml +++ b/apm-agent-plugins/apm-redis-plugin/apm-lettuce-plugin/pom.xml @@ -3,7 +3,7 @@ apm-redis-plugin co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugins/apm-redis-plugin/apm-redis-common/pom.xml b/apm-agent-plugins/apm-redis-plugin/apm-redis-common/pom.xml index b4812c6fda..1007e8613c 100644 --- a/apm-agent-plugins/apm-redis-plugin/apm-redis-common/pom.xml +++ b/apm-agent-plugins/apm-redis-plugin/apm-redis-common/pom.xml @@ -5,7 +5,7 @@ apm-redis-plugin co.elastic.apm - 1.48.1 + 1.49.0 apm-redis-common diff --git a/apm-agent-plugins/apm-redis-plugin/apm-redisson-plugin/pom.xml b/apm-agent-plugins/apm-redis-plugin/apm-redisson-plugin/pom.xml index 46bbb3a0d6..c87bcfcfa0 100644 --- a/apm-agent-plugins/apm-redis-plugin/apm-redisson-plugin/pom.xml +++ b/apm-agent-plugins/apm-redis-plugin/apm-redisson-plugin/pom.xml @@ -5,7 +5,7 @@ apm-redis-plugin co.elastic.apm - 1.48.1 + 1.49.0 apm-redisson-plugin diff --git a/apm-agent-plugins/apm-redis-plugin/pom.xml b/apm-agent-plugins/apm-redis-plugin/pom.xml index 2c5f5bae5f..560691c71c 100644 --- a/apm-agent-plugins/apm-redis-plugin/pom.xml +++ b/apm-agent-plugins/apm-redis-plugin/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-redis-plugin diff --git a/apm-agent-plugins/apm-scala-concurrent-plugin/pom.xml b/apm-agent-plugins/apm-scala-concurrent-plugin/pom.xml index 49b1ec62a3..943daf423d 100644 --- a/apm-agent-plugins/apm-scala-concurrent-plugin/pom.xml +++ b/apm-agent-plugins/apm-scala-concurrent-plugin/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-scala-concurrent-plugin diff --git a/apm-agent-plugins/apm-scheduled-annotation-plugin-jakartaee-test/pom.xml b/apm-agent-plugins/apm-scheduled-annotation-plugin-jakartaee-test/pom.xml index 6cccfbc2d9..ecea4dfa34 100644 --- a/apm-agent-plugins/apm-scheduled-annotation-plugin-jakartaee-test/pom.xml +++ b/apm-agent-plugins/apm-scheduled-annotation-plugin-jakartaee-test/pom.xml @@ -3,7 +3,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugins/apm-scheduled-annotation-plugin/pom.xml b/apm-agent-plugins/apm-scheduled-annotation-plugin/pom.xml index 9a84de38ed..cf39551c41 100644 --- a/apm-agent-plugins/apm-scheduled-annotation-plugin/pom.xml +++ b/apm-agent-plugins/apm-scheduled-annotation-plugin/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-scheduled-annotation-plugin diff --git a/apm-agent-plugins/apm-servlet-jakarta-test/pom.xml b/apm-agent-plugins/apm-servlet-jakarta-test/pom.xml index 5f74e01506..be040cba19 100644 --- a/apm-agent-plugins/apm-servlet-jakarta-test/pom.xml +++ b/apm-agent-plugins/apm-servlet-jakarta-test/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-servlet-jakarta-test diff --git a/apm-agent-plugins/apm-servlet-plugin/pom.xml b/apm-agent-plugins/apm-servlet-plugin/pom.xml index daad3d4005..c8dd43f4de 100644 --- a/apm-agent-plugins/apm-servlet-plugin/pom.xml +++ b/apm-agent-plugins/apm-servlet-plugin/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-servlet-plugin diff --git a/apm-agent-plugins/apm-sparkjava-plugin/pom.xml b/apm-agent-plugins/apm-sparkjava-plugin/pom.xml index 086eaef2b7..e435044523 100644 --- a/apm-agent-plugins/apm-sparkjava-plugin/pom.xml +++ b/apm-agent-plugins/apm-sparkjava-plugin/pom.xml @@ -3,7 +3,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugins/apm-spring-resttemplate/apm-spring-restclient-test/pom.xml b/apm-agent-plugins/apm-spring-resttemplate/apm-spring-restclient-test/pom.xml index 3bbe86c0b2..b529ca9fea 100644 --- a/apm-agent-plugins/apm-spring-resttemplate/apm-spring-restclient-test/pom.xml +++ b/apm-agent-plugins/apm-spring-resttemplate/apm-spring-restclient-test/pom.xml @@ -5,7 +5,7 @@ co.elastic.apm apm-spring-resttemplate - 1.48.1 + 1.49.0 apm-spring-restclient-test diff --git a/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-plugin/pom.xml b/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-plugin/pom.xml index 4ce5b21314..2f6c4456ea 100644 --- a/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-plugin/pom.xml +++ b/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-plugin/pom.xml @@ -5,7 +5,7 @@ co.elastic.apm apm-spring-resttemplate - 1.48.1 + 1.49.0 apm-spring-resttemplate-plugin diff --git a/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-test/pom.xml b/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-test/pom.xml index 8feed99793..82d497b2eb 100644 --- a/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-test/pom.xml +++ b/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-test/pom.xml @@ -5,7 +5,7 @@ co.elastic.apm apm-spring-resttemplate - 1.48.1 + 1.49.0 apm-spring-resttemplate-test diff --git a/apm-agent-plugins/apm-spring-resttemplate/pom.xml b/apm-agent-plugins/apm-spring-resttemplate/pom.xml index 7cbd13450d..f1d1463f07 100644 --- a/apm-agent-plugins/apm-spring-resttemplate/pom.xml +++ b/apm-agent-plugins/apm-spring-resttemplate/pom.xml @@ -5,7 +5,7 @@ co.elastic.apm apm-agent-plugins - 1.48.1 + 1.49.0 apm-spring-resttemplate diff --git a/apm-agent-plugins/apm-spring-webflux/apm-spring-webclient-plugin/pom.xml b/apm-agent-plugins/apm-spring-webflux/apm-spring-webclient-plugin/pom.xml index c296198695..19d61ff288 100755 --- a/apm-agent-plugins/apm-spring-webflux/apm-spring-webclient-plugin/pom.xml +++ b/apm-agent-plugins/apm-spring-webflux/apm-spring-webclient-plugin/pom.xml @@ -5,7 +5,7 @@ co.elastic.apm apm-spring-webflux - 1.48.1 + 1.49.0 apm-spring-webclient-plugin diff --git a/apm-agent-plugins/apm-spring-webflux/apm-spring-webflux-common-spring5/pom.xml b/apm-agent-plugins/apm-spring-webflux/apm-spring-webflux-common-spring5/pom.xml index 3cb1bb3649..79e5c0b0b3 100644 --- a/apm-agent-plugins/apm-spring-webflux/apm-spring-webflux-common-spring5/pom.xml +++ b/apm-agent-plugins/apm-spring-webflux/apm-spring-webflux-common-spring5/pom.xml @@ -4,7 +4,7 @@ co.elastic.apm apm-spring-webflux - 1.48.1 + 1.49.0 apm-spring-webflux-common-spring5 diff --git a/apm-agent-plugins/apm-spring-webflux/apm-spring-webflux-common/pom.xml b/apm-agent-plugins/apm-spring-webflux/apm-spring-webflux-common/pom.xml index 4e09f1c9cc..a0bf5cbbf9 100644 --- a/apm-agent-plugins/apm-spring-webflux/apm-spring-webflux-common/pom.xml +++ b/apm-agent-plugins/apm-spring-webflux/apm-spring-webflux-common/pom.xml @@ -4,7 +4,7 @@ co.elastic.apm apm-spring-webflux - 1.48.1 + 1.49.0 apm-spring-webflux-common diff --git a/apm-agent-plugins/apm-spring-webflux/apm-spring-webflux-plugin/pom.xml b/apm-agent-plugins/apm-spring-webflux/apm-spring-webflux-plugin/pom.xml index 594d935872..0e43d1d7ea 100644 --- a/apm-agent-plugins/apm-spring-webflux/apm-spring-webflux-plugin/pom.xml +++ b/apm-agent-plugins/apm-spring-webflux/apm-spring-webflux-plugin/pom.xml @@ -5,7 +5,7 @@ co.elastic.apm apm-spring-webflux - 1.48.1 + 1.49.0 apm-spring-webflux-plugin diff --git a/apm-agent-plugins/apm-spring-webflux/apm-spring-webflux-spring5/pom.xml b/apm-agent-plugins/apm-spring-webflux/apm-spring-webflux-spring5/pom.xml index 2bc3dc392b..ee213cf370 100644 --- a/apm-agent-plugins/apm-spring-webflux/apm-spring-webflux-spring5/pom.xml +++ b/apm-agent-plugins/apm-spring-webflux/apm-spring-webflux-spring5/pom.xml @@ -5,7 +5,7 @@ co.elastic.apm apm-spring-webflux - 1.48.1 + 1.49.0 apm-spring-webflux-spring5 diff --git a/apm-agent-plugins/apm-spring-webflux/apm-spring-webflux-testapp/pom.xml b/apm-agent-plugins/apm-spring-webflux/apm-spring-webflux-testapp/pom.xml index 885cddc043..a4f28af941 100644 --- a/apm-agent-plugins/apm-spring-webflux/apm-spring-webflux-testapp/pom.xml +++ b/apm-agent-plugins/apm-spring-webflux/apm-spring-webflux-testapp/pom.xml @@ -5,7 +5,7 @@ co.elastic.apm apm-spring-webflux - 1.48.1 + 1.49.0 apm-spring-webflux-testapp diff --git a/apm-agent-plugins/apm-spring-webflux/pom.xml b/apm-agent-plugins/apm-spring-webflux/pom.xml index fec6bc31c9..ca0f7359cf 100644 --- a/apm-agent-plugins/apm-spring-webflux/pom.xml +++ b/apm-agent-plugins/apm-spring-webflux/pom.xml @@ -5,7 +5,7 @@ co.elastic.apm apm-agent-plugins - 1.48.1 + 1.49.0 apm-spring-webflux diff --git a/apm-agent-plugins/apm-spring-webmvc/apm-spring-webmvc-plugin/pom.xml b/apm-agent-plugins/apm-spring-webmvc/apm-spring-webmvc-plugin/pom.xml index d9b0d31e49..3dfa508043 100644 --- a/apm-agent-plugins/apm-spring-webmvc/apm-spring-webmvc-plugin/pom.xml +++ b/apm-agent-plugins/apm-spring-webmvc/apm-spring-webmvc-plugin/pom.xml @@ -5,7 +5,7 @@ apm-spring-webmvc co.elastic.apm - 1.48.1 + 1.49.0 apm-spring-webmvc-plugin diff --git a/apm-agent-plugins/apm-spring-webmvc/apm-spring-webmvc-spring5/pom.xml b/apm-agent-plugins/apm-spring-webmvc/apm-spring-webmvc-spring5/pom.xml index 74b1169377..de6ea95ec3 100644 --- a/apm-agent-plugins/apm-spring-webmvc/apm-spring-webmvc-spring5/pom.xml +++ b/apm-agent-plugins/apm-spring-webmvc/apm-spring-webmvc-spring5/pom.xml @@ -5,7 +5,7 @@ apm-spring-webmvc co.elastic.apm - 1.48.1 + 1.49.0 apm-spring-webmvc-spring5 diff --git a/apm-agent-plugins/apm-spring-webmvc/pom.xml b/apm-agent-plugins/apm-spring-webmvc/pom.xml index 0e0dbc1cfa..af3b7fa514 100644 --- a/apm-agent-plugins/apm-spring-webmvc/pom.xml +++ b/apm-agent-plugins/apm-spring-webmvc/pom.xml @@ -3,7 +3,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugins/apm-struts-plugin/pom.xml b/apm-agent-plugins/apm-struts-plugin/pom.xml index f7adb7f895..1e47f97dd8 100644 --- a/apm-agent-plugins/apm-struts-plugin/pom.xml +++ b/apm-agent-plugins/apm-struts-plugin/pom.xml @@ -3,7 +3,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/apm-agent-plugins/apm-urlconnection-plugin/pom.xml b/apm-agent-plugins/apm-urlconnection-plugin/pom.xml index d741479e10..fdacc1e9b5 100644 --- a/apm-agent-plugins/apm-urlconnection-plugin/pom.xml +++ b/apm-agent-plugins/apm-urlconnection-plugin/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-urlconnection-plugin diff --git a/apm-agent-plugins/apm-vertx/apm-vertx-common/pom.xml b/apm-agent-plugins/apm-vertx/apm-vertx-common/pom.xml index a55dee0f1f..4db2506f70 100644 --- a/apm-agent-plugins/apm-vertx/apm-vertx-common/pom.xml +++ b/apm-agent-plugins/apm-vertx/apm-vertx-common/pom.xml @@ -5,7 +5,7 @@ apm-vertx co.elastic.apm - 1.48.1 + 1.49.0 apm-vertx-common diff --git a/apm-agent-plugins/apm-vertx/apm-vertx3-plugin/pom.xml b/apm-agent-plugins/apm-vertx/apm-vertx3-plugin/pom.xml index 80699ce105..1c4e03391d 100644 --- a/apm-agent-plugins/apm-vertx/apm-vertx3-plugin/pom.xml +++ b/apm-agent-plugins/apm-vertx/apm-vertx3-plugin/pom.xml @@ -5,7 +5,7 @@ apm-vertx co.elastic.apm - 1.48.1 + 1.49.0 apm-vertx3-plugin diff --git a/apm-agent-plugins/apm-vertx/apm-vertx3-test-latest/pom.xml b/apm-agent-plugins/apm-vertx/apm-vertx3-test-latest/pom.xml index b0c07fb7d3..60a2ebca8b 100644 --- a/apm-agent-plugins/apm-vertx/apm-vertx3-test-latest/pom.xml +++ b/apm-agent-plugins/apm-vertx/apm-vertx3-test-latest/pom.xml @@ -5,7 +5,7 @@ apm-vertx co.elastic.apm - 1.48.1 + 1.49.0 apm-vertx3-test-latest diff --git a/apm-agent-plugins/apm-vertx/apm-vertx4-plugin/pom.xml b/apm-agent-plugins/apm-vertx/apm-vertx4-plugin/pom.xml index 93240e1ed4..c47ffc1e4e 100644 --- a/apm-agent-plugins/apm-vertx/apm-vertx4-plugin/pom.xml +++ b/apm-agent-plugins/apm-vertx/apm-vertx4-plugin/pom.xml @@ -5,7 +5,7 @@ apm-vertx co.elastic.apm - 1.48.1 + 1.49.0 apm-vertx4-plugin diff --git a/apm-agent-plugins/apm-vertx/pom.xml b/apm-agent-plugins/apm-vertx/pom.xml index 52ffacae81..1e935c6347 100644 --- a/apm-agent-plugins/apm-vertx/pom.xml +++ b/apm-agent-plugins/apm-vertx/pom.xml @@ -5,7 +5,7 @@ apm-agent-plugins co.elastic.apm - 1.48.1 + 1.49.0 apm-vertx diff --git a/apm-agent-plugins/pom.xml b/apm-agent-plugins/pom.xml index 2643a3f595..6acbfe7d40 100644 --- a/apm-agent-plugins/pom.xml +++ b/apm-agent-plugins/pom.xml @@ -5,7 +5,7 @@ apm-agent-parent co.elastic.apm - 1.48.1 + 1.49.0 apm-agent-plugins diff --git a/apm-agent-tracer/pom.xml b/apm-agent-tracer/pom.xml index 52ee021f60..cf71cc4e53 100644 --- a/apm-agent-tracer/pom.xml +++ b/apm-agent-tracer/pom.xml @@ -4,7 +4,7 @@ co.elastic.apm apm-agent-parent - 1.48.1 + 1.49.0 apm-agent-tracer @@ -24,6 +24,11 @@ apm-agent-common ${project.version} + + com.dslplatform + dsl-json + 1.9.3 + net.bytebuddy diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/context/AbstractLifecycleListener.java b/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/AbstractLifecycleListener.java similarity index 83% rename from apm-agent-core/src/main/java/co/elastic/apm/agent/context/AbstractLifecycleListener.java rename to apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/AbstractLifecycleListener.java index 02c4f0c0be..6489ae1441 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/context/AbstractLifecycleListener.java +++ b/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/AbstractLifecycleListener.java @@ -16,17 +16,15 @@ * specific language governing permissions and limitations * under the License. */ -package co.elastic.apm.agent.context; - -import co.elastic.apm.agent.impl.ElasticApmTracer; +package co.elastic.apm.agent.tracer; public abstract class AbstractLifecycleListener implements LifecycleListener { @Override - public void init(ElasticApmTracer tracer) throws Exception { + public void init(Tracer tracer) throws Exception { } @Override - public void start(ElasticApmTracer tracer) throws Exception { + public void start(Tracer tracer) throws Exception { } @Override diff --git a/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/Faas.java b/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/Faas.java new file mode 100644 index 0000000000..678c02b6ea --- /dev/null +++ b/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/Faas.java @@ -0,0 +1,36 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. 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. + */ +package co.elastic.apm.agent.tracer; + +import javax.annotation.Nullable; + +public interface Faas { + + FaasTrigger getTrigger(); + + Faas withId(@Nullable String id); + + Faas withName(@Nullable String name); + + Faas withVersion(@Nullable String version); + + Faas withExecution(@Nullable String execution); + + Faas withColdStart(boolean coldStart); +} diff --git a/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/FaasTrigger.java b/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/FaasTrigger.java new file mode 100644 index 0000000000..72fd88913e --- /dev/null +++ b/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/FaasTrigger.java @@ -0,0 +1,28 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. 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. + */ +package co.elastic.apm.agent.tracer; + +import javax.annotation.Nullable; + +public interface FaasTrigger { + + FaasTrigger withType(@Nullable String type); + + FaasTrigger withRequestId(@Nullable String requestId); +} diff --git a/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/GlobalTracer.java b/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/GlobalTracer.java index 449622326e..692ffdca5e 100644 --- a/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/GlobalTracer.java +++ b/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/GlobalTracer.java @@ -19,13 +19,17 @@ package co.elastic.apm.agent.tracer; import co.elastic.apm.agent.tracer.dispatch.HeaderGetter; +import co.elastic.apm.agent.tracer.metrics.DoubleSupplier; +import co.elastic.apm.agent.tracer.metrics.Labels; import co.elastic.apm.agent.tracer.pooling.ObjectPoolFactory; import co.elastic.apm.agent.tracer.reference.ReferenceCounted; import co.elastic.apm.agent.tracer.reference.ReferenceCountedMap; import co.elastic.apm.agent.tracer.service.Service; +import com.dslplatform.json.JsonWriter; import javax.annotation.Nullable; import java.util.Set; +import java.util.concurrent.TimeUnit; public class GlobalTracer implements Tracer { @@ -156,4 +160,45 @@ public Service createService(String ephemeralId) { public Throwable redactExceptionIfRequired(@Nullable Throwable original) { return tracer.redactExceptionIfRequired(original); } + + @Override + public void flush() { + tracer.flush(); + } + + @Override + public void completeMetaData(String name, String version, String id, String region) { + tracer.completeMetaData(name, version, id, region); + } + + @Override + public void removeGauge(String name, Labels.Immutable labels) { + tracer.removeGauge(name, labels); + } + + @Override + public void addGauge(String name, Labels.Immutable labels, DoubleSupplier supplier) { + tracer.addGauge(name, labels, supplier); + } + + @Override + public void submit(Runnable job) { + tracer.submit(job); + } + + @Override + public void schedule(Runnable job, long interval, TimeUnit timeUnit) { + tracer.schedule(job, interval, timeUnit); + } + + @Override + public void addShutdownHook(AutoCloseable hook) { + tracer.addShutdownHook(hook); + } + + @Override + public void reportMetric(JsonWriter metrics) { + tracer.reportMetric(metrics); + } + } diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/context/LifecycleListener.java b/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/LifecycleListener.java similarity index 74% rename from apm-agent-core/src/main/java/co/elastic/apm/agent/context/LifecycleListener.java rename to apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/LifecycleListener.java index 3b4716518c..a1b55634c4 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/context/LifecycleListener.java +++ b/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/LifecycleListener.java @@ -16,42 +16,39 @@ * specific language governing permissions and limitations * under the License. */ -package co.elastic.apm.agent.context; - -import co.elastic.apm.agent.impl.ElasticApmTracer; -import co.elastic.apm.agent.impl.Tracer; +package co.elastic.apm.agent.tracer; /** - * A {@link LifecycleListener} notifies about the start and stop event of the {@link ElasticApmTracer}. + * A {@link LifecycleListener} notifies about the start and stop event of the {@link Tracer}. *

* Implement this interface and register it as a {@linkplain java.util.ServiceLoader service} under - * {@code src/main/resources/META-INF/services/co.elastic.apm.agent.context.LifecycleListener}. + * {@code src/main/resources/META-INF/services/co.elastic.apm.agent.tracer.LifecycleListener}. *

*

- * Implementations may have a constructor with an {@link ElasticApmTracer} argument + * Implementations may have a constructor with an {@link Tracer} argument *

*/ public interface LifecycleListener { /** - * Callback for tracer initialization. As opposed to {@link LifecycleListener#start(ElasticApmTracer)}, which may + * Callback for tracer initialization. As opposed to {@link LifecycleListener#start(Tracer)}, which may * be called in a delay, this callback is called at the bootstrap of the JVM, before anything else start. * This may be useful for listeners that need to operate very early on, for example such that setup class loading * requirement to support OSGi systems. * @param tracer the tracer * @throws Exception */ - void init(ElasticApmTracer tracer) throws Exception; + void init(Tracer tracer) throws Exception; /** - * Callback for when the {@link ElasticApmTracer} starts. + * Callback for when the {@link Tracer} starts. * * @param tracer The tracer. */ - void start(ElasticApmTracer tracer) throws Exception; + void start(Tracer tracer) throws Exception; /** - * Callback for when {@link ElasticApmTracer#pause()} has been called. + * Callback for when the {@link Tracer} is paused. *

* Typically, this method is used to reduce overhead on the application to a minimum. This can be done by cleaning * up resources like object pools, as well as by avoiding tracing-related overhead. @@ -65,7 +62,7 @@ public interface LifecycleListener { void pause() throws Exception; /** - * Callback for when {@link ElasticApmTracer#resume()} has been called. + * Callback for when {@link Tracer} resumes. *

* Typically, used in order to revert the actions taken by the {@link LifecycleListener#pause()} method, allowing * the agent to restore all tracing capabilities @@ -79,7 +76,7 @@ public interface LifecycleListener { void resume() throws Exception; /** - * Callback for when {@link ElasticApmTracer#stop()} has been called. + * Callback for when the {@link Tracer} is stopped. *

* Typically, this method is used to clean up resources like thread pools * so that there are no class loader leaks when a webapp is redeployed in an application server. @@ -96,17 +93,14 @@ public interface LifecycleListener { * The order in which lifecycle listeners are called is non-deterministic. * *

  • - * The {@link ElasticApmTracer#getSharedSingleThreadedPool()} is shut down gracefully, + * Any {@link Tracer}-managed thread pool is shut down gracefully, * waiting a moment for the already scheduled tasks to be completed. * This means that implementations of this method can schedule a last command to this pool that is executed before shutdown. - * The {@link Tracer#getState()} will still be {@link Tracer.TracerState#RUNNING} in the tasks scheduled to - * {@link ElasticApmTracer#getSharedSingleThreadedPool()} within this method. - *
  • - *
  • - * The tracer state is set to {@link co.elastic.apm.agent.impl.Tracer.TracerState#STOPPED}. + * The {@link Tracer#isRunning()} will still be {@code true} in the tasks scheduled to + * complete within {@link Tracer}-managed threads within this method. *
  • *
  • - * The {@link co.elastic.apm.agent.report.Reporter} is closed. + * The tracer state is set to {@link Tracer#isRunning()} being {@code false}. *
  • * * diff --git a/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/NoopTracer.java b/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/NoopTracer.java index 5ee5d8a652..85fab5a76a 100644 --- a/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/NoopTracer.java +++ b/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/NoopTracer.java @@ -19,14 +19,18 @@ package co.elastic.apm.agent.tracer; import co.elastic.apm.agent.tracer.dispatch.HeaderGetter; +import co.elastic.apm.agent.tracer.metrics.DoubleSupplier; +import co.elastic.apm.agent.tracer.metrics.Labels; import co.elastic.apm.agent.tracer.pooling.ObjectPoolFactory; import co.elastic.apm.agent.tracer.reference.ReferenceCounted; import co.elastic.apm.agent.tracer.reference.ReferenceCountedMap; import co.elastic.apm.agent.tracer.service.Service; +import com.dslplatform.json.JsonWriter; import javax.annotation.Nullable; import java.util.Collections; import java.util.Set; +import java.util.concurrent.TimeUnit; class NoopTracer implements Tracer { @@ -131,4 +135,36 @@ public Service createService(String ephemeralId) { public Throwable redactExceptionIfRequired(@Nullable Throwable original) { return original; } + + @Override + public void flush() { + } + + @Override + public void completeMetaData(String name, String version, String id, String region) { + } + + @Override + public void addGauge(String name, Labels.Immutable labels, DoubleSupplier supplier) { + } + + @Override + public void removeGauge(String name, Labels.Immutable labels) { + } + + @Override + public void submit(Runnable job) { + } + + @Override + public void schedule(Runnable job, long interval, TimeUnit timeUnit) { + } + + @Override + public void addShutdownHook(AutoCloseable hook) { + } + + @Override + public void reportMetric(JsonWriter metrics) { + } } diff --git a/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/ServiceOrigin.java b/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/ServiceOrigin.java new file mode 100644 index 0000000000..9159bb29b5 --- /dev/null +++ b/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/ServiceOrigin.java @@ -0,0 +1,30 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. 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. + */ +package co.elastic.apm.agent.tracer; + +import javax.annotation.Nullable; + +public interface ServiceOrigin { + + ServiceOrigin withVersion(@Nullable String version); + + ServiceOrigin withName(@Nullable CharSequence name); + + ServiceOrigin withId(@Nullable String id); +} diff --git a/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/Tracer.java b/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/Tracer.java index 1cd0529de8..4f1d6efc2e 100644 --- a/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/Tracer.java +++ b/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/Tracer.java @@ -19,13 +19,17 @@ package co.elastic.apm.agent.tracer; import co.elastic.apm.agent.tracer.dispatch.HeaderGetter; +import co.elastic.apm.agent.tracer.metrics.DoubleSupplier; +import co.elastic.apm.agent.tracer.metrics.Labels; import co.elastic.apm.agent.tracer.pooling.ObjectPoolFactory; import co.elastic.apm.agent.tracer.reference.ReferenceCounted; import co.elastic.apm.agent.tracer.reference.ReferenceCountedMap; import co.elastic.apm.agent.tracer.service.Service; +import com.dslplatform.json.JsonWriter; import javax.annotation.Nullable; import java.util.Set; +import java.util.concurrent.TimeUnit; public interface Tracer { @@ -91,4 +95,20 @@ public interface Tracer { @Nullable Throwable redactExceptionIfRequired(@Nullable Throwable original); + + void removeGauge(String name, Labels.Immutable labels); + + void addGauge(String name, Labels.Immutable labels, DoubleSupplier supplier); + + void submit(Runnable job); + + void schedule(Runnable job, long interval, TimeUnit timeUnit); + + void addShutdownHook(AutoCloseable hook); + + void reportMetric(JsonWriter metrics); // TODO: replace with internalized DSL writer that only accepts data. + + void flush(); + + void completeMetaData(String name, String version, String id, String region); } diff --git a/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/Transaction.java b/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/Transaction.java index 1f6ade713c..aec2fafaba 100644 --- a/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/Transaction.java +++ b/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/Transaction.java @@ -57,6 +57,8 @@ public interface Transaction> extends AbstractSpan { void setFrameworkVersion(@Nullable String frameworkVersion); + Faas getFaas(); + void setPendingTransactionException(Throwable exception); @Nullable diff --git a/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/TransactionContext.java b/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/TransactionContext.java index baafaacb96..d1800dd91c 100644 --- a/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/TransactionContext.java +++ b/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/TransactionContext.java @@ -43,4 +43,6 @@ public interface TransactionContext extends AbstractContext { User getUser(); CloudOrigin getCloudOrigin(); + + ServiceOrigin getServiceOrigin(); } diff --git a/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/metadata/Request.java b/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/metadata/Request.java index fe8afd2f5f..46ac03f623 100644 --- a/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/metadata/Request.java +++ b/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/metadata/Request.java @@ -75,6 +75,15 @@ public interface Request { Request addFormUrlEncodedParameters(String key, String[] values); + /** + * Adds a request header. + * + * @param headerName The name of the header. + * @param headerValue The value of the header. + * @return {@code this}, for fluent method chaining + */ + Request addHeader(String headerName, @Nullable String headerValue); + Request addHeader(String headerName, @Nullable Enumeration headerValues); Request addCookie(String cookieName, String cookieValue); diff --git a/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/metadata/Response.java b/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/metadata/Response.java index e87a517a8a..43a4457dab 100644 --- a/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/metadata/Response.java +++ b/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/metadata/Response.java @@ -40,5 +40,7 @@ public interface Response { Response withHeadersSent(boolean headersSent); + Response addHeader(String headerName, @Nullable String headerValue); + Response addHeader(String headerName, @Nullable Collection headerValues); } diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/DoubleSupplier.java b/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/metrics/DoubleSupplier.java similarity index 94% rename from apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/DoubleSupplier.java rename to apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/metrics/DoubleSupplier.java index 120a72221d..7f5087b653 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/DoubleSupplier.java +++ b/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/metrics/DoubleSupplier.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package co.elastic.apm.agent.metrics; +package co.elastic.apm.agent.tracer.metrics; public interface DoubleSupplier { diff --git a/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/metrics/DslJsonUtil.java b/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/metrics/DslJsonUtil.java new file mode 100644 index 0000000000..256c8def4d --- /dev/null +++ b/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/metrics/DslJsonUtil.java @@ -0,0 +1,80 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. 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. + */ +package co.elastic.apm.agent.tracer.metrics; + +import com.dslplatform.json.JsonWriter; + +public class DslJsonUtil { + + public static final int MAX_VALUE_LENGTH = 1024; + + private static final String[] DISALLOWED_IN_PROPERTY_NAME = new String[]{".", "*", "\""}; + + public static void writeFieldName(final String fieldName, final JsonWriter jw) { + jw.writeByte(JsonWriter.QUOTE); + jw.writeAscii(fieldName); + jw.writeByte(JsonWriter.QUOTE); + jw.writeByte(JsonWriter.SEMI); + } + + + public static CharSequence sanitizePropertyName(String key, StringBuilder replaceBuilder) { + for (int i = 0; i < DISALLOWED_IN_PROPERTY_NAME.length; i++) { + if (key.contains(DISALLOWED_IN_PROPERTY_NAME[i])) { + return replaceAll(key, DISALLOWED_IN_PROPERTY_NAME, "_", replaceBuilder); + } + } + return key; + } + + private static CharSequence replaceAll(String s, String[] stringsToReplace, String replacement, StringBuilder replaceBuilder) { + // uses a instance variable StringBuilder to avoid allocations + replaceBuilder.setLength(0); + replaceBuilder.append(s); + for (String toReplace : stringsToReplace) { + replace(replaceBuilder, toReplace, replacement, 0); + } + return replaceBuilder; + } + + static void replace(StringBuilder replaceBuilder, String toReplace, String replacement, int fromIndex) { + for (int i = replaceBuilder.indexOf(toReplace, fromIndex); i != -1; i = replaceBuilder.indexOf(toReplace, fromIndex)) { + replaceBuilder.replace(i, i + toReplace.length(), replacement); + fromIndex = i; + } + } + + public static void writeStringValue(CharSequence value, final StringBuilder replaceBuilder, final JsonWriter jw) { + if (value.length() > MAX_VALUE_LENGTH) { + replaceBuilder.setLength(0); + replaceBuilder.append(value, 0, Math.min(value.length(), MAX_VALUE_LENGTH + 1)); + writeStringBuilderValue(replaceBuilder, jw); + } else { + jw.writeString(value); + } + } + + private static void writeStringBuilderValue(StringBuilder value, JsonWriter jw) { + if (value.length() > MAX_VALUE_LENGTH) { + value.setLength(MAX_VALUE_LENGTH - 1); + value.append('…'); + } + jw.writeString(value); + } +} diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/Labels.java b/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/metrics/Labels.java similarity index 98% rename from apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/Labels.java rename to apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/metrics/Labels.java index c6a2e0475d..a48076bbed 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/metrics/Labels.java +++ b/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/metrics/Labels.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package co.elastic.apm.agent.metrics; +package co.elastic.apm.agent.tracer.metrics; import co.elastic.apm.agent.tracer.pooling.Recyclable; @@ -31,10 +31,6 @@ * However, there are also top-level labels which are not nested under the {@code labels} object, * for example {@link #getTransactionName()}, {@link #getTransactionType()}, {@link #getSpanType()} and {@link #getSpanSubType()}. *

    - * Metrics are structured into multiple {@link MetricSet}s. - * For each distinct combination of {@link Labels}, there is one {@link MetricSet}. - *

    - *

    * Labels allow for {@link CharSequence}s as a value, * thus avoiding allocations for {@code transaction.name.toString()} when tracking breakdown metrics for a transaction. * Iterations over the labels also don't allocate an Iterator, in contrast to {@code Map.entrySet().iterator()}. diff --git a/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/LabelsTest.java b/apm-agent-tracer/src/test/java/co/elastic/apm/agent/tracer/metrics/LabelsTest.java similarity index 99% rename from apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/LabelsTest.java rename to apm-agent-tracer/src/test/java/co/elastic/apm/agent/tracer/metrics/LabelsTest.java index 21e55850c0..ef68d9a229 100644 --- a/apm-agent-core/src/test/java/co/elastic/apm/agent/metrics/LabelsTest.java +++ b/apm-agent-tracer/src/test/java/co/elastic/apm/agent/tracer/metrics/LabelsTest.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package co.elastic.apm.agent.metrics; +package co.elastic.apm.agent.tracer.metrics; import org.junit.jupiter.api.Test; diff --git a/apm-opentracing/pom.xml b/apm-opentracing/pom.xml index 552bd7b756..1e34b37172 100644 --- a/apm-opentracing/pom.xml +++ b/apm-opentracing/pom.xml @@ -5,7 +5,7 @@ apm-agent-parent co.elastic.apm - 1.48.1 + 1.49.0 apm-opentracing diff --git a/cloudfoundry/index.yml b/cloudfoundry/index.yml index 750c4919ab..24b766a778 100644 --- a/cloudfoundry/index.yml +++ b/cloudfoundry/index.yml @@ -60,3 +60,4 @@ 1.47.0: https://repo1.maven.org/maven2/co/elastic/apm/elastic-apm-agent/1.47.0/elastic-apm-agent-1.47.0.jar 1.47.1: https://repo1.maven.org/maven2/co/elastic/apm/elastic-apm-agent/1.47.1/elastic-apm-agent-1.47.1.jar 1.48.0: https://repo1.maven.org/maven2/co/elastic/apm/elastic-apm-agent/1.48.0/elastic-apm-agent-1.48.0.jar +1.48.1: https://repo1.maven.org/maven2/co/elastic/apm/elastic-apm-agent/1.48.1/elastic-apm-agent-1.48.1.jar diff --git a/docs/setup-aws-lambda.asciidoc b/docs/setup-aws-lambda.asciidoc index 632cee9119..2149c2d534 100644 --- a/docs/setup-aws-lambda.asciidoc +++ b/docs/setup-aws-lambda.asciidoc @@ -4,6 +4,10 @@ The Java APM Agent can be used with AWS Lambda to monitor the execution of your AWS Lambda functions. +``` +Note: The Centralized Agent Configuration on the Elasticsearch APM currently does NOT support AWS Lambda. +``` + [float] [[aws-lambda-java-quick-start]] === Quick Start diff --git a/elastic-apm-agent-java8/pom.xml b/elastic-apm-agent-java8/pom.xml index 8f80175967..ce3d63b288 100644 --- a/elastic-apm-agent-java8/pom.xml +++ b/elastic-apm-agent-java8/pom.xml @@ -5,7 +5,7 @@ co.elastic.apm apm-agent-parent - 1.48.1 + 1.49.0 elastic-apm-agent-java8 diff --git a/elastic-apm-agent-premain/pom.xml b/elastic-apm-agent-premain/pom.xml index c9c5476159..94ad89199b 100644 --- a/elastic-apm-agent-premain/pom.xml +++ b/elastic-apm-agent-premain/pom.xml @@ -3,7 +3,7 @@ apm-agent-parent co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/elastic-apm-agent/pom.xml b/elastic-apm-agent/pom.xml index 1d6e625611..a7fb3005e7 100644 --- a/elastic-apm-agent/pom.xml +++ b/elastic-apm-agent/pom.xml @@ -5,7 +5,7 @@ co.elastic.apm apm-agent-parent - 1.48.1 + 1.49.0 elastic-apm-agent diff --git a/integration-tests/application-server-integration-tests/pom.xml b/integration-tests/application-server-integration-tests/pom.xml index 821a2ab925..ff82f3c7f7 100644 --- a/integration-tests/application-server-integration-tests/pom.xml +++ b/integration-tests/application-server-integration-tests/pom.xml @@ -5,7 +5,7 @@ integration-tests co.elastic.apm - 1.48.1 + 1.49.0 application-server-integration-tests diff --git a/integration-tests/aws-lambda-test/pom.xml b/integration-tests/aws-lambda-test/pom.xml index eaafe01c06..8d4ccb5cb1 100644 --- a/integration-tests/aws-lambda-test/pom.xml +++ b/integration-tests/aws-lambda-test/pom.xml @@ -3,7 +3,7 @@ integration-tests co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/integration-tests/cdi-app/cdi-app-dependent/pom.xml b/integration-tests/cdi-app/cdi-app-dependent/pom.xml index 10838ff968..7fa8622b49 100644 --- a/integration-tests/cdi-app/cdi-app-dependent/pom.xml +++ b/integration-tests/cdi-app/cdi-app-dependent/pom.xml @@ -4,7 +4,7 @@ cdi-app co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/integration-tests/cdi-app/cdi-app-standalone/pom.xml b/integration-tests/cdi-app/cdi-app-standalone/pom.xml index 3bce8646f2..6976c519c7 100644 --- a/integration-tests/cdi-app/cdi-app-standalone/pom.xml +++ b/integration-tests/cdi-app/cdi-app-standalone/pom.xml @@ -4,7 +4,7 @@ cdi-app co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/integration-tests/cdi-app/pom.xml b/integration-tests/cdi-app/pom.xml index 6d90f7280f..751dcc6c8f 100644 --- a/integration-tests/cdi-app/pom.xml +++ b/integration-tests/cdi-app/pom.xml @@ -4,7 +4,7 @@ integration-tests co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/integration-tests/cdi-jakartaee-app/cdi-jakartaee-app-dependent/pom.xml b/integration-tests/cdi-jakartaee-app/cdi-jakartaee-app-dependent/pom.xml index 527744cfda..90de8b028e 100644 --- a/integration-tests/cdi-jakartaee-app/cdi-jakartaee-app-dependent/pom.xml +++ b/integration-tests/cdi-jakartaee-app/cdi-jakartaee-app-dependent/pom.xml @@ -4,7 +4,7 @@ cdi-jakartaee-app co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/integration-tests/cdi-jakartaee-app/cdi-jakartaee-app-standalone/pom.xml b/integration-tests/cdi-jakartaee-app/cdi-jakartaee-app-standalone/pom.xml index 40ac20e077..ce3b1d89b4 100644 --- a/integration-tests/cdi-jakartaee-app/cdi-jakartaee-app-standalone/pom.xml +++ b/integration-tests/cdi-jakartaee-app/cdi-jakartaee-app-standalone/pom.xml @@ -4,7 +4,7 @@ cdi-jakartaee-app co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/integration-tests/cdi-jakartaee-app/pom.xml b/integration-tests/cdi-jakartaee-app/pom.xml index cfa65f2e72..e2a1eb57c2 100644 --- a/integration-tests/cdi-jakartaee-app/pom.xml +++ b/integration-tests/cdi-jakartaee-app/pom.xml @@ -4,7 +4,7 @@ integration-tests co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/integration-tests/external-plugin-otel-test/external-plugin-otel-test-app/pom.xml b/integration-tests/external-plugin-otel-test/external-plugin-otel-test-app/pom.xml index 47fde11ba3..fbc6852359 100644 --- a/integration-tests/external-plugin-otel-test/external-plugin-otel-test-app/pom.xml +++ b/integration-tests/external-plugin-otel-test/external-plugin-otel-test-app/pom.xml @@ -4,7 +4,7 @@ co.elastic.apm external-plugin-otel-test - 1.48.1 + 1.49.0 external-plugin-otel-test-app diff --git a/integration-tests/external-plugin-otel-test/external-plugin-otel-test-plugin1/pom.xml b/integration-tests/external-plugin-otel-test/external-plugin-otel-test-plugin1/pom.xml index 15b5daa0ee..b544aef5c2 100644 --- a/integration-tests/external-plugin-otel-test/external-plugin-otel-test-plugin1/pom.xml +++ b/integration-tests/external-plugin-otel-test/external-plugin-otel-test-plugin1/pom.xml @@ -4,7 +4,7 @@ co.elastic.apm external-plugin-otel-test - 1.48.1 + 1.49.0 external-plugin-otel-test-plugin1 diff --git a/integration-tests/external-plugin-otel-test/external-plugin-otel-test-plugin2/pom.xml b/integration-tests/external-plugin-otel-test/external-plugin-otel-test-plugin2/pom.xml index 74fc5c585c..9d08c966f9 100644 --- a/integration-tests/external-plugin-otel-test/external-plugin-otel-test-plugin2/pom.xml +++ b/integration-tests/external-plugin-otel-test/external-plugin-otel-test-plugin2/pom.xml @@ -4,7 +4,7 @@ co.elastic.apm external-plugin-otel-test - 1.48.1 + 1.49.0 external-plugin-otel-test-plugin2 diff --git a/integration-tests/external-plugin-otel-test/pom.xml b/integration-tests/external-plugin-otel-test/pom.xml index 06f4084f52..4bd83805c8 100644 --- a/integration-tests/external-plugin-otel-test/pom.xml +++ b/integration-tests/external-plugin-otel-test/pom.xml @@ -4,7 +4,7 @@ co.elastic.apm integration-tests - 1.48.1 + 1.49.0 external-plugin-otel-test diff --git a/integration-tests/external-plugin-test/external-plugin-app/pom.xml b/integration-tests/external-plugin-test/external-plugin-app/pom.xml index ee288ab1f4..5cc0210bf5 100644 --- a/integration-tests/external-plugin-test/external-plugin-app/pom.xml +++ b/integration-tests/external-plugin-test/external-plugin-app/pom.xml @@ -6,7 +6,7 @@ external-plugin-test co.elastic.apm - 1.48.1 + 1.49.0 external-plugin-app diff --git a/integration-tests/external-plugin-test/external-plugin-jakarta-app/pom.xml b/integration-tests/external-plugin-test/external-plugin-jakarta-app/pom.xml index 376b0fda26..3a3c626b5b 100644 --- a/integration-tests/external-plugin-test/external-plugin-jakarta-app/pom.xml +++ b/integration-tests/external-plugin-test/external-plugin-jakarta-app/pom.xml @@ -6,7 +6,7 @@ external-plugin-test co.elastic.apm - 1.48.1 + 1.49.0 external-plugin-jakarta-app diff --git a/integration-tests/external-plugin-test/external-plugin/pom.xml b/integration-tests/external-plugin-test/external-plugin/pom.xml index 455233737c..635ec073d8 100644 --- a/integration-tests/external-plugin-test/external-plugin/pom.xml +++ b/integration-tests/external-plugin-test/external-plugin/pom.xml @@ -6,7 +6,7 @@ external-plugin-test co.elastic.apm - 1.48.1 + 1.49.0 external-plugin diff --git a/integration-tests/external-plugin-test/plugin-instrumentation-target/pom.xml b/integration-tests/external-plugin-test/plugin-instrumentation-target/pom.xml index 9963bb9464..1e008f01e2 100644 --- a/integration-tests/external-plugin-test/plugin-instrumentation-target/pom.xml +++ b/integration-tests/external-plugin-test/plugin-instrumentation-target/pom.xml @@ -6,7 +6,7 @@ external-plugin-test co.elastic.apm - 1.48.1 + 1.49.0 plugin-instrumentation-target diff --git a/integration-tests/external-plugin-test/pom.xml b/integration-tests/external-plugin-test/pom.xml index 9bfb8a0a39..1ab2a4717e 100644 --- a/integration-tests/external-plugin-test/pom.xml +++ b/integration-tests/external-plugin-test/pom.xml @@ -3,7 +3,7 @@ integration-tests co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/integration-tests/jakartaee-jsf-app/jakartaee-jsf-app-dependent/pom.xml b/integration-tests/jakartaee-jsf-app/jakartaee-jsf-app-dependent/pom.xml index 091241e9a1..5e450c96fe 100644 --- a/integration-tests/jakartaee-jsf-app/jakartaee-jsf-app-dependent/pom.xml +++ b/integration-tests/jakartaee-jsf-app/jakartaee-jsf-app-dependent/pom.xml @@ -3,7 +3,7 @@ jakartaee-jsf-app co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/integration-tests/jakartaee-jsf-app/jakartaee-jsf-app-standalone/pom.xml b/integration-tests/jakartaee-jsf-app/jakartaee-jsf-app-standalone/pom.xml index 068e92b87d..4ad7029e6d 100644 --- a/integration-tests/jakartaee-jsf-app/jakartaee-jsf-app-standalone/pom.xml +++ b/integration-tests/jakartaee-jsf-app/jakartaee-jsf-app-standalone/pom.xml @@ -3,7 +3,7 @@ jakartaee-jsf-app co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/integration-tests/jakartaee-jsf-app/pom.xml b/integration-tests/jakartaee-jsf-app/pom.xml index 420d5d44ec..32fa2c1fa8 100644 --- a/integration-tests/jakartaee-jsf-app/pom.xml +++ b/integration-tests/jakartaee-jsf-app/pom.xml @@ -3,7 +3,7 @@ integration-tests co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 pom diff --git a/integration-tests/jakartaee-simple-webapp/pom.xml b/integration-tests/jakartaee-simple-webapp/pom.xml index 29dbd0c91c..3a265054c1 100644 --- a/integration-tests/jakartaee-simple-webapp/pom.xml +++ b/integration-tests/jakartaee-simple-webapp/pom.xml @@ -5,7 +5,7 @@ integration-tests co.elastic.apm - 1.48.1 + 1.49.0 jakartaee-simple-webapp diff --git a/integration-tests/jsf-app/jsf-app-dependent/pom.xml b/integration-tests/jsf-app/jsf-app-dependent/pom.xml index 07b6525d8b..4632305024 100644 --- a/integration-tests/jsf-app/jsf-app-dependent/pom.xml +++ b/integration-tests/jsf-app/jsf-app-dependent/pom.xml @@ -4,7 +4,7 @@ jsf-app co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/integration-tests/jsf-app/jsf-app-standalone/pom.xml b/integration-tests/jsf-app/jsf-app-standalone/pom.xml index 82358a7655..cb554b6882 100644 --- a/integration-tests/jsf-app/jsf-app-standalone/pom.xml +++ b/integration-tests/jsf-app/jsf-app-standalone/pom.xml @@ -6,7 +6,7 @@ jsf-app co.elastic.apm - 1.48.1 + 1.49.0 jsf-app-standalone diff --git a/integration-tests/jsf-app/pom.xml b/integration-tests/jsf-app/pom.xml index 15bf87c569..4a77fc6fc8 100644 --- a/integration-tests/jsf-app/pom.xml +++ b/integration-tests/jsf-app/pom.xml @@ -6,7 +6,7 @@ integration-tests co.elastic.apm - 1.48.1 + 1.49.0 jsf-app diff --git a/integration-tests/main-app-test/pom.xml b/integration-tests/main-app-test/pom.xml index cfd0d1cc1c..2394a2d859 100644 --- a/integration-tests/main-app-test/pom.xml +++ b/integration-tests/main-app-test/pom.xml @@ -5,7 +5,7 @@ integration-tests co.elastic.apm - 1.48.1 + 1.49.0 main-app-test diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index e1e668fb04..9e925c082c 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -5,7 +5,7 @@ apm-agent-parent co.elastic.apm - 1.48.1 + 1.49.0 integration-tests diff --git a/integration-tests/quarkus/pom.xml b/integration-tests/quarkus/pom.xml index 5155f0a7c1..71b503b0f3 100644 --- a/integration-tests/quarkus/pom.xml +++ b/integration-tests/quarkus/pom.xml @@ -5,7 +5,7 @@ integration-tests co.elastic.apm - 1.48.1 + 1.49.0 quarkus diff --git a/integration-tests/quarkus/quarkus-jaxrs-base/pom.xml b/integration-tests/quarkus/quarkus-jaxrs-base/pom.xml index 0844fd2315..fb55d2f3a0 100644 --- a/integration-tests/quarkus/quarkus-jaxrs-base/pom.xml +++ b/integration-tests/quarkus/quarkus-jaxrs-base/pom.xml @@ -5,7 +5,7 @@ quarkus co.elastic.apm - 1.48.1 + 1.49.0 quarkus-jaxrs-base diff --git a/integration-tests/quarkus/quarkus-jaxrs-undertow/pom.xml b/integration-tests/quarkus/quarkus-jaxrs-undertow/pom.xml index 9579589899..ba4c3c4e5a 100644 --- a/integration-tests/quarkus/quarkus-jaxrs-undertow/pom.xml +++ b/integration-tests/quarkus/quarkus-jaxrs-undertow/pom.xml @@ -5,7 +5,7 @@ quarkus co.elastic.apm - 1.48.1 + 1.49.0 quarkus-jaxrs-undertow diff --git a/integration-tests/quarkus/quarkus-jaxrs-vertx/pom.xml b/integration-tests/quarkus/quarkus-jaxrs-vertx/pom.xml index 63b1078af0..ef2d751b8b 100644 --- a/integration-tests/quarkus/quarkus-jaxrs-vertx/pom.xml +++ b/integration-tests/quarkus/quarkus-jaxrs-vertx/pom.xml @@ -5,7 +5,7 @@ quarkus co.elastic.apm - 1.48.1 + 1.49.0 quarkus-jaxrs-vertx diff --git a/integration-tests/runtime-attach/pom.xml b/integration-tests/runtime-attach/pom.xml index c2f384da95..3cd9da7adf 100644 --- a/integration-tests/runtime-attach/pom.xml +++ b/integration-tests/runtime-attach/pom.xml @@ -6,7 +6,7 @@ integration-tests co.elastic.apm - 1.48.1 + 1.49.0 runtime-attach diff --git a/integration-tests/runtime-attach/runtime-attach-app/pom.xml b/integration-tests/runtime-attach/runtime-attach-app/pom.xml index 3d4e1ba2c9..69de69af65 100644 --- a/integration-tests/runtime-attach/runtime-attach-app/pom.xml +++ b/integration-tests/runtime-attach/runtime-attach-app/pom.xml @@ -3,7 +3,7 @@ runtime-attach co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/integration-tests/runtime-attach/runtime-attach-test/pom.xml b/integration-tests/runtime-attach/runtime-attach-test/pom.xml index 7a8335522a..604a113b35 100644 --- a/integration-tests/runtime-attach/runtime-attach-test/pom.xml +++ b/integration-tests/runtime-attach/runtime-attach-test/pom.xml @@ -3,7 +3,7 @@ runtime-attach co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 @@ -31,7 +31,7 @@ org.awaitility awaitility - 4.2.0 + 4.2.1 test diff --git a/integration-tests/simple-webapp/pom.xml b/integration-tests/simple-webapp/pom.xml index c6fda1e5a5..35b1604594 100644 --- a/integration-tests/simple-webapp/pom.xml +++ b/integration-tests/simple-webapp/pom.xml @@ -6,7 +6,7 @@ integration-tests co.elastic.apm - 1.48.1 + 1.49.0 simple-webapp diff --git a/integration-tests/soap-test/pom.xml b/integration-tests/soap-test/pom.xml index ee7878bdf5..0d03952129 100644 --- a/integration-tests/soap-test/pom.xml +++ b/integration-tests/soap-test/pom.xml @@ -5,7 +5,7 @@ integration-tests co.elastic.apm - 1.48.1 + 1.49.0 soap-test diff --git a/integration-tests/spring-boot-1-5/pom.xml b/integration-tests/spring-boot-1-5/pom.xml index f2e60f25b2..82ffa2180c 100644 --- a/integration-tests/spring-boot-1-5/pom.xml +++ b/integration-tests/spring-boot-1-5/pom.xml @@ -5,7 +5,7 @@ integration-tests co.elastic.apm - 1.48.1 + 1.49.0 spring-boot-1-5 diff --git a/integration-tests/spring-boot-2/pom.xml b/integration-tests/spring-boot-2/pom.xml index f6b797ae08..8f1aaa1d15 100644 --- a/integration-tests/spring-boot-2/pom.xml +++ b/integration-tests/spring-boot-2/pom.xml @@ -5,7 +5,7 @@ integration-tests co.elastic.apm - 1.48.1 + 1.49.0 spring-boot-2 diff --git a/integration-tests/spring-boot-2/spring-boot-2-base/pom.xml b/integration-tests/spring-boot-2/spring-boot-2-base/pom.xml index 8571f30a4b..ff01bc47fb 100644 --- a/integration-tests/spring-boot-2/spring-boot-2-base/pom.xml +++ b/integration-tests/spring-boot-2/spring-boot-2-base/pom.xml @@ -5,7 +5,7 @@ spring-boot-2 co.elastic.apm - 1.48.1 + 1.49.0 spring-boot-2-base diff --git a/integration-tests/spring-boot-2/spring-boot-2-jetty/pom.xml b/integration-tests/spring-boot-2/spring-boot-2-jetty/pom.xml index e5033ba0e8..879735c5a5 100644 --- a/integration-tests/spring-boot-2/spring-boot-2-jetty/pom.xml +++ b/integration-tests/spring-boot-2/spring-boot-2-jetty/pom.xml @@ -5,7 +5,7 @@ spring-boot-2 co.elastic.apm - 1.48.1 + 1.49.0 spring-boot-2-jetty diff --git a/integration-tests/spring-boot-2/spring-boot-2-tomcat/pom.xml b/integration-tests/spring-boot-2/spring-boot-2-tomcat/pom.xml index 3373ee2fb1..229fc95d95 100644 --- a/integration-tests/spring-boot-2/spring-boot-2-tomcat/pom.xml +++ b/integration-tests/spring-boot-2/spring-boot-2-tomcat/pom.xml @@ -5,7 +5,7 @@ spring-boot-2 co.elastic.apm - 1.48.1 + 1.49.0 spring-boot-2-tomcat diff --git a/integration-tests/spring-boot-2/spring-boot-2-undertow/pom.xml b/integration-tests/spring-boot-2/spring-boot-2-undertow/pom.xml index 5ee5340308..85ceea0865 100644 --- a/integration-tests/spring-boot-2/spring-boot-2-undertow/pom.xml +++ b/integration-tests/spring-boot-2/spring-boot-2-undertow/pom.xml @@ -5,7 +5,7 @@ spring-boot-2 co.elastic.apm - 1.48.1 + 1.49.0 spring-boot-2-undertow diff --git a/integration-tests/spring-boot-3/pom.xml b/integration-tests/spring-boot-3/pom.xml index 4dea8a7b02..744200d853 100644 --- a/integration-tests/spring-boot-3/pom.xml +++ b/integration-tests/spring-boot-3/pom.xml @@ -5,7 +5,7 @@ integration-tests co.elastic.apm - 1.48.1 + 1.49.0 spring-boot-3 diff --git a/integration-tests/spring-boot-3/spring-boot-3-jetty/pom.xml b/integration-tests/spring-boot-3/spring-boot-3-jetty/pom.xml index 3ff81f77dd..b7ba4b02bf 100644 --- a/integration-tests/spring-boot-3/spring-boot-3-jetty/pom.xml +++ b/integration-tests/spring-boot-3/spring-boot-3-jetty/pom.xml @@ -3,7 +3,7 @@ spring-boot-3 co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/integration-tests/spring-boot-3/spring-boot-3-tomcat/pom.xml b/integration-tests/spring-boot-3/spring-boot-3-tomcat/pom.xml index e0fc0192e5..bc0b652eb9 100644 --- a/integration-tests/spring-boot-3/spring-boot-3-tomcat/pom.xml +++ b/integration-tests/spring-boot-3/spring-boot-3-tomcat/pom.xml @@ -3,7 +3,7 @@ spring-boot-3 co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/integration-tests/spring-boot-3/spring-boot-3-undertow/pom.xml b/integration-tests/spring-boot-3/spring-boot-3-undertow/pom.xml index 4ba6db6657..d1818a48c5 100644 --- a/integration-tests/spring-boot-3/spring-boot-3-undertow/pom.xml +++ b/integration-tests/spring-boot-3/spring-boot-3-undertow/pom.xml @@ -3,7 +3,7 @@ spring-boot-3 co.elastic.apm - 1.48.1 + 1.49.0 4.0.0 diff --git a/pom.xml b/pom.xml index 38d8bcf393..262422be2c 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ co.elastic.apm apm-agent-parent - 1.48.1 + 1.49.0 pom ${project.groupId}:${project.artifactId} @@ -30,7 +30,7 @@ scm:git:git@github.com:elastic/apm-agent-java.git scm:git:git@github.com:elastic/apm-agent-java.git https://github.com/elastic/apm-agent-java - v1.48.1 + HEAD @@ -129,7 +129,7 @@ 1.5.0 5.0.15.RELEASE 9.4.11.v20180605 - 1.1.0 + 1.3.3 1.14.12 9.6 @@ -380,17 +380,9 @@ - maven-release-plugin - - false - gpg - true - v@{project.version} - - **/apm-agent-benchmarks/src/main/resources/** - **/apm-agent-plugins/apm-profiling-plugin/src/main/resources/** - - + org.codehaus.mojo + versions-maven-plugin + 2.16.2 org.sonatype.plugins @@ -817,7 +809,7 @@ org.awaitility awaitility - 4.2.0 + 4.2.1 test