Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* 'main' of https://github.com/elastic/apm-agent-java: (35 commits)
  buildkite: opentelemetry+elastic agent overhead benchmark on a weekly basis (elastic#3371)
  ci(action): remove unrequired action (elastic#3387)
  Bump org.springframework.boot:spring-boot-dependencies from 2.7.16 to 3.1.5 (elastic#3380)
  ci(action): archive benchmarks.jar (elastic#3386)
  remove noise (elastic#3385)
  Process otel benchmark (elastic#3384)
  Update tests for Jedis 5 (elastic#3382)
  added entry to community plugins (elastic#3383)
  added capturing s3 otel attributes from lamba S3Event (elastic#3364)
  Bump version.log4j from 2.12.4 to 2.21.0 (elastic#3366)
  Fix aws sdk instrumentation (elastic#3373)
  action: remove leftover from Jenkins (elastic#3368)
  Bump org.apache.logging.log4j:log4j-bom from 2.20.0 to 2.21.0 (elastic#3367)
  Bump io.micrometer:micrometer-core from 1.11.4 to 1.11.5 (elastic#3360)
  Add guard against invalid end timestamps (elastic#3363)
  Added otel to dependabot config, upgraded dependencies (elastic#3359)
  Bump version.byte-buddy from 1.14.8 to 1.14.9 (elastic#3361)
  Fix off-by-one error in tests which effectively disabled recycling validation (elastic#3357)
  Fix multiple spans being created for HTTPUrlConnection HEAD requests (elastic#3353)
  Bump org.ow2.asm:asm-tree from 9.5 to 9.6 (elastic#3349)
  ...
  • Loading branch information
v1v committed Oct 27, 2023
2 parents 7f15c02 + e83573e commit 6d452fa
Show file tree
Hide file tree
Showing 249 changed files with 1,262 additions and 400 deletions.
9 changes: 9 additions & 0 deletions .buildkite/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,12 @@ This is the Buildkite pipeline for the APM Agent java in charge of the snaposhot

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.

## opentelemetry-benchmark pipeline

This is the Buildkite pipeline for the Opentelemetry Benchmark.

### Pipeline Configuration

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`.
85 changes: 21 additions & 64 deletions .buildkite/hooks/pre-command
Original file line number Diff line number Diff line change
Expand Up @@ -8,67 +8,24 @@

set -eo pipefail

echo "--- Prepare vault context :vault:"
VAULT_ROLE_ID_SECRET=$(vault read -field=role-id secret/ci/elastic-apm-agent-java/internal-ci-approle)
export VAULT_ROLE_ID_SECRET

VAULT_SECRET_ID_SECRET=$(vault read -field=secret-id secret/ci/elastic-apm-agent-java/internal-ci-approle)
export VAULT_SECRET_ID_SECRET

VAULT_ADDR=$(vault read -field=vault-url secret/ci/elastic-apm-agent-java/internal-ci-approle)
export VAULT_ADDR

# Delete the vault specific accessing the ci vault
PREVIOUS_VAULT_TOKEN=$VAULT_TOKEN
export PREVIOUS_VAULT_TOKEN
unset VAULT_TOKEN

echo "--- Prepare a secure temp :closed_lock_with_key:"
# Prepare a secure temp folder not shared between other jobs to store the key ring
export TMP_WORKSPACE=/tmp/secured
export KEY_FILE=$TMP_WORKSPACE"/private.key"

# Secure home for our keyring
export GNUPGHOME=$TMP_WORKSPACE"/keyring"
mkdir -p $GNUPGHOME
chmod -R 700 $TMP_WORKSPACE

echo "--- Prepare keys context :key:"
VAULT_TOKEN=$(vault write -field=token auth/approle/login role_id="$VAULT_ROLE_ID_SECRET" secret_id="$VAULT_SECRET_ID_SECRET")
export VAULT_TOKEN

# Nexus credentials
SERVER_USERNAME=$(vault read -field username secret/release/nexus)
export SERVER_USERNAME
SERVER_PASSWORD=$(vault read -field password secret/release/nexus)
export SERVER_PASSWORD

# Signing keys
vault read -field=key secret/release/signing >$KEY_FILE
KEYPASS_SECRET=$(vault read -field=passphrase secret/release/signing)
export KEYPASS_SECRET
export KEY_ID_SECRET=D88E42B4

# Import the key into the keyring
echo "$KEYPASS_SECRET" | gpg --batch --import "$KEY_FILE"

echo "--- Configure git context :git:"
# Configure the committer since the maven release requires to push changes to GitHub
# This will help with the SLSA requirements.
git config --global user.email "[email protected]"
git config --global user.name "apmmachine"

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

export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH

java -version || true
# Upload should not do much with the pre-command.
if [[ "$BUILDKITE_COMMAND" =~ .*"upload".* ]]; then
echo "Skipped pre-command when running the Upload pipeline"
exit 0
fi

## TODO: change name for the opentelemetry-benchmark
if [ "$BUILDKITE_PIPELINE_SLUG" == "apm-agent-java-load-testing" ]; then
source .buildkite/hooks/prepare-benchmark.sh
fi

if [ "$BUILDKITE_PIPELINE_SLUG" == "apm-agent-java-snapshot" ]; then
source .buildkite/hooks/prepare-release.sh
fi

if [ "$BUILDKITE_PIPELINE_SLUG" == "apm-agent-java-release" ]; then
source .buildkite/hooks/prepare-release.sh
fi

# Run always
source .buildkite/hooks/prepare-common.sh
25 changes: 25 additions & 0 deletions .buildkite/hooks/prepare-benchmark.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
set -euo pipefail

echo "--- Prepare elasticsearch secrets :vault:"
ES_URL_SECRET=$(vault read -field=es_url secret/ci/elastic-apm-agent-java/opentelemetry-benchmark)
ES_USER_SECRET=$(vault read -field=es_user secret/ci/elastic-apm-agent-java/opentelemetry-benchmark)
ES_PASS_SECRET=$(vault read -field=es_pass secret/ci/elastic-apm-agent-java/opentelemetry-benchmark)
export ES_URL_SECRET ES_USER_SECRET ES_PASS_SECRET

echo "--- Prepare github secrets :vault:"
GITHUB_SECRET=$(vault kv get -field token "kv/ci-shared/observability-ci/github-apmmachine")
GH_TOKEN=$GITHUB_SECRET
export GITHUB_SECRET GH_TOKEN
GITHUB_USERNAME=apmmachine
export GITHUB_USERNAME

echo "--- Install gh :github:"
GH_URL=https://github.com/cli/cli/releases/download/v2.37.0/gh_2.37.0_linux_amd64.tar.gz
GH_HOME=$(pwd)/.gh
curl -L --output /tmp/gh.tar.gz "$GH_URL"
mkdir -p "$GH_HOME"
tar --extract --file /tmp/gh.tar.gz --directory "$GH_HOME" --strip-components 1

PATH=$GH_HOME/bin:$PATH
export PATH
17 changes: 17 additions & 0 deletions .buildkite/hooks/prepare-common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/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

export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH

java -version || true
52 changes: 52 additions & 0 deletions .buildkite/hooks/prepare-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash
set -euo pipefail

echo "--- Prepare vault context :vault:"
VAULT_ROLE_ID_SECRET=$(vault read -field=role-id secret/ci/elastic-apm-agent-java/internal-ci-approle)
export VAULT_ROLE_ID_SECRET

VAULT_SECRET_ID_SECRET=$(vault read -field=secret-id secret/ci/elastic-apm-agent-java/internal-ci-approle)
export VAULT_SECRET_ID_SECRET

VAULT_ADDR=$(vault read -field=vault-url secret/ci/elastic-apm-agent-java/internal-ci-approle)
export VAULT_ADDR

# Delete the vault specific accessing the ci vault
PREVIOUS_VAULT_TOKEN=$VAULT_TOKEN
export PREVIOUS_VAULT_TOKEN
unset VAULT_TOKEN

echo "--- Prepare a secure temp :closed_lock_with_key:"
# Prepare a secure temp folder not shared between other jobs to store the key ring
export TMP_WORKSPACE=/tmp/secured
export KEY_FILE=$TMP_WORKSPACE"/private.key"

# Secure home for our keyring
export GNUPGHOME=$TMP_WORKSPACE"/keyring"
mkdir -p $GNUPGHOME
chmod -R 700 $TMP_WORKSPACE

echo "--- Prepare keys context :key:"
VAULT_TOKEN=$(vault write -field=token auth/approle/login role_id="$VAULT_ROLE_ID_SECRET" secret_id="$VAULT_SECRET_ID_SECRET")
export VAULT_TOKEN

# Nexus credentials
SERVER_USERNAME=$(vault read -field username secret/release/nexus)
export SERVER_USERNAME
SERVER_PASSWORD=$(vault read -field password secret/release/nexus)
export SERVER_PASSWORD

# Signing keys
vault read -field=key secret/release/signing >$KEY_FILE
KEYPASS_SECRET=$(vault read -field=passphrase secret/release/signing)
export KEYPASS_SECRET
export KEY_ID_SECRET=D88E42B4

# Import the key into the keyring
echo "$KEYPASS_SECRET" | gpg --batch --import "$KEY_FILE"

echo "--- Configure git context :git:"
# Configure the committer since the maven release requires to push changes to GitHub
# This will help with the SLSA requirements.
git config --global user.email "[email protected]"
git config --global user.name "apmmachine"
2 changes: 1 addition & 1 deletion .buildkite/load-testing.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# @reakaleek: This is a place holder to create the pipeline in Buildkite. I will work on it, in a follow-up.
steps:
- label: ":wave: Greetings" # Label (with rich emojis https://ela.st/bk-emoji).
command: "echo 'My first pipeline!'" # Command to run (evaluated by Bash).
command: "echo 'My first pipeline!'" # Command to run (evaluated by Bash).
13 changes: 13 additions & 0 deletions .buildkite/opentelemetry-benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
steps:
- label: "Run the opentelemetry-benchmark"
commands: .buildkite/scripts/opentelemetry-benchmark.sh
agents:
queue: observability-microbenchmarks
artifact_paths:
- "**/build/reports/tests/test/classes/io.opentelemetry.OverheadTests.html"
- "**/build/reports/tests/test/index.html"
- "output.json"

notify:
- slack: "#apm-agent-java"
if: 'build.state != "passed"'
83 changes: 83 additions & 0 deletions .buildkite/scripts/opentelemetry-benchmark.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/env bash
set -eo pipefail

CONTAINER_NAME=mock-apm-server
JSON_FILE="$(pwd)/output.json"

function cleanup {
echo "--- Tear down the environment"
MOCK_APM_SERVER=$(docker ps | grep $CONTAINER_NAME | awk '{print $1}')
docker stop $MOCK_APM_SERVER
docker rm $MOCK_APM_SERVER
}

trap cleanup EXIT

echo "--- Download the latest elastic-apm-agent artifact"
# run earlier so gh can use the current github repository.
run_id=$(gh run list --branch main --status success --workflow main.yml -L 1 --json databaseId --jq '.[].databaseId')
echo "downloading the latest artifact 'elastic-apm-agent' (using the workflow run '$run_id')"
gh run download "$run_id" -n elastic-apm-agent
ELASTIC_SNAPSHOT_JAR=$(ls -1 elastic-apm-agent-*.jar)
ELASTIC_SNAPSHOT_JAR_FILE="$(pwd)/$ELASTIC_SNAPSHOT_JAR"
echo "$ELASTIC_SNAPSHOT_JAR_FILE has been downloaded."
gh run download "$run_id" -n apm-agent-benchmarks
BENCHMARKS_JAR=$(ls -1 benchmarks*.jar)
BENCHMARKS_JAR_FILE="$(pwd)/$BENCHMARKS_JAR"
echo "$BENCHMARKS_JAR_FILE has been downloaded."

echo "--- Start APM Server mock"
git clone https://github.com/elastic/apm-mutating-webhook.git
pushd apm-mutating-webhook/test/mock
docker build -t $CONTAINER_NAME .
docker run -dp 127.0.0.1:8027:8027 $CONTAINER_NAME
popd

echo "--- Build opentelemetry-java-instrumentation"
git clone https://github.com/open-telemetry/opentelemetry-java-instrumentation.git --depth 1 --branch main
pushd opentelemetry-java-instrumentation/
./gradlew assemble

echo "--- Customise the elastic opentelemetry java instrumentation"
pushd benchmark-overhead
cp "$ELASTIC_SNAPSHOT_JAR_FILE" .
ELASTIC_SNAPSHOT_ENTRY="new Agent(\\\"elastic-snapshot\\\",\\\"latest available snapshot version from elastic main\\\",\\\"file://$PWD/$ELASTIC_SNAPSHOT_JAR\\\", java.util.List.of(\\\"-Delastic.apm.server_url=http://host.docker.internal:8027/\\\"))"
ELASTIC_LATEST_VERSION=$(curl -s https://repo1.maven.org/maven2/co/elastic/apm/elastic-apm-agent/ | perl -ne 's/<.*?>//g; if(s/^([\d\.]+).*$/$1/){print}' | sort -V | tail -1)
ELASTIC_LATEST_ENTRY="new Agent(\\\"elastic-latest\\\",\\\"latest available released version from elastic main\\\",\\\"https://repo1.maven.org/maven2/co/elastic/apm/elastic-apm-agent/$ELASTIC_LATEST_VERSION/elastic-apm-agent-$ELASTIC_LATEST_VERSION.jar\\\", java.util.List.of(\\\"-Delastic.apm.server_url=http://host.docker.internal:8027/\\\"))"
ELASTIC_LATEST_ENTRY2="new Agent(\\\"elastic-async\\\",\\\"latest available released version from elastic main\\\",\\\"https://repo1.maven.org/maven2/co/elastic/apm/elastic-apm-agent/$ELASTIC_LATEST_VERSION/elastic-apm-agent-$ELASTIC_LATEST_VERSION.jar\\\", java.util.List.of(\\\"-Delastic.apm.delay_agent_premain_ms=15000\\\",\\\"-Delastic.apm.server_url=http://host.docker.internal:8027/\\\"))"
NEW_LINE=" .withAgents(Agent.NONE, Agent.LATEST_RELEASE, Agent.LATEST_SNAPSHOT, $ELASTIC_LATEST_ENTRY, $ELASTIC_LATEST_ENTRY2, $ELASTIC_SNAPSHOT_ENTRY)"
echo $NEW_LINE
perl -i -ne "if (/withAgents/) {print \"$NEW_LINE\n\"}else{print}" src/test/java/io/opentelemetry/config/Configs.java

echo "--- Run tests of benchmark-overhead"
./gradlew test

echo "--- Report in Buildkite"

REPORT_FILE=$(pwd)/build/reports/tests/test/classes/io.opentelemetry.OverheadTests.html
perl -ne '/Standard output/ && $on++; /\<\/pre\>/ && ($on=0);$on && s/\<.*\>//;$on && !/^\s*$/ && print' $REPORT_FILE | tee report.txt

# Buildkite annotation
if [ -n "$BUILDKITE" ]; then
REPORT=$(cat report.txt)
cat << EOF | buildkite-agent annotate --style "info" --context report
### OverheadTests Report
\`\`\`
${REPORT}
\`\`\`
EOF
fi

echo "--- Generate ES docs"
java -cp $BENCHMARKS_JAR_FILE \
co.elastic.apm.agent.benchmark.ProcessOtelBenchmarkResults \
"$REPORT_FILE" "$JSON_FILE" "$ELASTIC_LATEST_VERSION" ./opentelemetry-javaagent.jar

echo "--- Send Report"
curl -X POST \
--user "${ES_USER_SECRET}:${ES_PASS_SECRET}" \
"${ES_URL_SECRET}/_bulk?pretty" \
-H "Content-Type: application/x-ndjson" \
--data-binary @"$JSON_FILE"
2 changes: 2 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ updates:
- dependency-name: "io.vertx:*"
- dependency-name: "org.apache.logging.log4j:*"
- dependency-name: "org.springframework.boot:*"
- dependency-name: "io.opentelemetry:*"
- dependency-name: "io.opentelemetry.semconv:*"
ignore:
- dependency-name: "net.bytebuddy:byte-buddy-agent"
# We deliberately want to keep this older version of Byte Buddy for our runtime attach test
Expand Down
26 changes: 22 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,13 @@ jobs:
path: |
./apm-agent-plugin-sdk/target/apm-agent-plugin-sdk-*.jar
!./**/*-sources.jar
- name: Upload benchmark binaries as artifacts
uses: actions/upload-artifact@v3
with:
name: apm-agent-benchmarks
path: |
./apm-agent-benchmarks/target/benchmarks*.jar
!./**/*-sources.jar
license:
name: License
Expand Down Expand Up @@ -176,6 +181,18 @@ jobs:
with:
name: build
path: ${{ github.workspace }}
# As long as there are some space issues with the CI runners.
- name: Free Disk Space
continue-on-error: true
uses: jlumbroso/free-disk-space@f68fdb76e2ea636224182cfb7377ff9a1708f9b8
with:
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true
tool-cache: false
- uses: ./.github/workflows/maven-goal
with:
command: ./mvnw -q -P ci-non-application-server-integration-tests verify
Expand Down Expand Up @@ -205,7 +222,8 @@ jobs:
path: ${{ github.workspace }}
# As long as there are some space issues with the CI runners.
- name: Free Disk Space
uses: jlumbroso/free-disk-space@0add001504c51b93b35ac8e81d252bdd47e4ef07
continue-on-error: true
uses: jlumbroso/free-disk-space@f68fdb76e2ea636224182cfb7377ff9a1708f9b8
with:
android: true
dotnet: true
Expand Down Expand Up @@ -283,7 +301,7 @@ jobs:
distribution: 'temurin'
- version: 20
distribution: 'temurin'
- version: 21-ea
- version: 21
distribution: 'zulu'
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:

maven_central_deploy:
name: "Deploy to Maven Central (Buildkite)"
if: ${{ ! inputs.skip_maven_deploy }}
if: ${{ ! inputs.skip_maven_deploy && ( inputs.skip_preparation || success() ) }}
runs-on: ubuntu-latest
needs:
- prepare_release
Expand Down
Loading

0 comments on commit 6d452fa

Please sign in to comment.