Skip to content

Commit cc8e20d

Browse files
authored
Merge branch 'main' into enable-self-instrumentation-tracing
2 parents 2a6b579 + 23a0b0d commit cc8e20d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+742
-206
lines changed

.ci/scripts/push-pgo-pr.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
set -eo pipefail
4+
5+
PGO_BRANCH="update-pgo-$(date +%s)"
6+
cd $WORKSPACE_PATH
7+
git fetch origin main
8+
git checkout main
9+
git checkout -b $PGO_BRANCH
10+
mv $PROFILE_PATH x-pack/apm-server/default.pgo
11+
git add x-pack/apm-server/default.pgo
12+
git commit -m "PGO: Update default.pgo from benchmarks $WORKFLOW."
13+
git push -u origin $PGO_BRANCH
14+
gh pr create -B main -H $PGO_BRANCH -t "PGO: Update default.pgo" -b "Update default.pgo CPU profile from the benchmarks [workflow]($WORKFLOW)." -R elastic/apm-server
15+
gh pr merge --auto --delete-branch --squash $PGO_BRANCH

.github/workflows/benchmarks.yml

Lines changed: 86 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ name: benchmarks
33
on:
44
workflow_dispatch:
55
inputs:
6+
runStandalone:
7+
description: 'Run the benchmarks against standalone APM Server with Moxy'
8+
required: false
9+
type: boolean
10+
default: false
611
profile:
712
description: 'The system profile used to run the benchmarks'
813
required: false
@@ -21,10 +26,12 @@ on:
2126
required: false
2227
type: string
2328
schedule:
24-
- cron: '0 17 * * *'
29+
- cron: '0 17 * * *' # Scheduled regular benchmarks.
30+
- cron: '0 5 */5 * *' # Scheduled PGO benchmarks.
2531

2632
env:
2733
PNG_REPORT_FILE: out.png
34+
BENCHMARK_CPU_OUT: default.pgo
2835
BENCHMARK_RESULT: benchmark-result.txt
2936
WORKING_DIRECTORY: testing/benchmark
3037

@@ -38,12 +45,13 @@ jobs:
3845
run:
3946
working-directory: ${{ env.WORKING_DIRECTORY }}
4047
permissions:
41-
contents: read
48+
contents: write
4249
id-token: write
4350
env:
4451
SSH_KEY: ./id_rsa_terraform
4552
TF_VAR_private_key: ./id_rsa_terraform
4653
TF_VAR_public_key: ./id_rsa_terraform.pub
54+
RUN_STANDALONE: ${{ inputs.runStandalone || github.event.schedule=='0 5 */5 * *' }}
4755
TFVARS_SOURCE: ${{ inputs.profile || 'system-profiles/8GBx1zone.tfvars' }} # // Default to use an 8gb profile
4856
TF_VAR_BUILD_ID: ${{ github.run_id }}
4957
TF_VAR_ENVIRONMENT: ci
@@ -101,28 +109,48 @@ jobs:
101109
terraform_version: 1.3.7
102110
terraform_wrapper: false
103111

112+
- name: Init terraform module
113+
id: init
114+
run: make init
115+
104116
- name: Build apmbench
105117
run: make apmbench $SSH_KEY terraform.tfvars
106118

119+
- name: Build APM Server and Moxy
120+
if: ${{ env.RUN_STANDALONE == 'true' }}
121+
run: |
122+
make apm-server
123+
make moxy
124+
107125
- name: Override docker committed version
108-
if: ${{ ! inputs.runOnStable }}
126+
if: ${{ ! inputs.runOnStable && env.RUN_STANDALONE == 'false' }}
109127
run: make docker-override-committed-version
110128

111129
- name: Spin up benchmark environment
112130
id: deploy
113131
run: |
114-
make init apply
132+
make apply
115133
admin_console_url=$(terraform output -raw admin_console_url)
116134
echo "admin_console_url=$admin_console_url" >> "$GITHUB_OUTPUT"
117135
echo "-> infra setup done"
136+
env:
137+
TF_VAR_worker_region: ${{ env.AWS_REGION }}
138+
TF_VAR_run_standalone: ${{ env.RUN_STANDALONE }}
118139

119140
- name: Run benchmarks autotuned
120141
if: ${{ inputs.benchmarkAgents == '' }}
121-
run: make run-benchmark-autotuned index-benchmark-results
142+
run: make run-benchmark-autotuned
122143

123144
- name: Run benchmarks self tuned
124145
if: ${{ inputs.benchmarkAgents != '' }}
125-
run: make run-benchmark index-benchmark-results
146+
run: make run-benchmark
147+
148+
- name: Cat standalone server logs
149+
if: ${{ env.RUN_STANDALONE == 'true' && failure() }}
150+
run: make cat-apm-server-logs
151+
152+
- name: Index benchmarks result
153+
run: make index-benchmark-results
126154

127155
- name: Download PNG
128156
run: >-
@@ -150,15 +178,65 @@ jobs:
150178
151179
- name: Upload benchmark result
152180
uses: actions/upload-artifact@v4
153-
if: always()
154181
with:
155182
name: benchmark-result
156183
path: ${{ env.WORKING_DIRECTORY }}/${{ env.BENCHMARK_RESULT }}
157184
if-no-files-found: error
158185

186+
# The next section injects CPU profile collected by apmbench into the build.
187+
# By copying the profile, uploading it to the artifacts and pushing it
188+
# via a PR to update default.pgo.
189+
190+
- name: Copy CPU profile
191+
run: make cp-cpuprof
192+
193+
- name: Upload CPU profile
194+
uses: actions/upload-artifact@v4
195+
with:
196+
name: cpu-profile
197+
path: ${{ env.WORKING_DIRECTORY }}/${{ env.BENCHMARK_CPU_OUT }}
198+
if-no-files-found: error
199+
200+
- name: Get token
201+
id: get_token
202+
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
203+
with:
204+
app_id: ${{ secrets.OBS_AUTOMATION_APP_ID }}
205+
private_key: ${{ secrets.OBS_AUTOMATION_APP_PEM }}
206+
permissions: >-
207+
{
208+
"contents": "write",
209+
"pull_requests": "write"
210+
}
211+
212+
# Required to use a service account, otherwise PRs created by
213+
# GitHub bot won't trigger any CI builds.
214+
# See https://github.com/peter-evans/create-pull-request/issues/48#issuecomment-537478081
215+
- name: Configure git user
216+
uses: elastic/oblt-actions/git/setup@v1
217+
with:
218+
github-token: ${{ steps.get_token.outputs.token }}
219+
220+
- name: Import GPG key
221+
uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0
222+
with:
223+
gpg_private_key: ${{ secrets.APM_SERVER_RELEASE_GPG_PRIVATE_KEY }}
224+
passphrase: ${{ secrets.APM_SERVER_RELEASE_PASSPHRASE }}
225+
git_user_signingkey: true
226+
git_commit_gpgsign: true
227+
228+
- name: Open PGO PR
229+
if: ${{ env.RUN_STANDALONE == 'true' && github.ref == 'refs/heads/main' }}
230+
run: ${{ github.workspace }}/.ci/scripts/push-pgo-pr.sh
231+
env:
232+
WORKSPACE_PATH: ${{ github.workspace }}
233+
PROFILE_PATH: ${{ env.WORKING_DIRECTORY }}/${{ env.BENCHMARK_CPU_OUT }}
234+
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
235+
WORKFLOW: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}
236+
159237
- name: Tear down benchmark environment
160238
if: always()
161-
run: make destroy
239+
run: make init destroy
162240

163241
# Notify failure to Slack only on schedule (nightly run)
164242
- if: failure() && github.event_name == 'schedule'

NOTICE.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -829,11 +829,11 @@ SOFTWARE
829829

830830
--------------------------------------------------------------------------------
831831
Dependency : github.com/elastic/elastic-agent-libs
832-
Version: v0.11.0
832+
Version: v0.12.0
833833
Licence type (autodetected): Apache-2.0
834834
--------------------------------------------------------------------------------
835835

836-
Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-libs@v0.11.0/LICENSE:
836+
Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-libs@v0.12.0/LICENSE:
837837

838838
Apache License
839839
Version 2.0, January 2004

docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ x-logging: &default-logging
1111
services:
1212
elasticsearch:
1313
# TODO: replace with a pinned version such as 9.0.0-aaaaaaaa-SNAPSHOT
14-
image: docker.elastic.co/elasticsearch/elasticsearch:9.0.0-bda98d6d-SNAPSHOT
14+
image: docker.elastic.co/elasticsearch/elasticsearch:9.0.0-db2e645e-SNAPSHOT
1515
ports:
1616
- 9200:9200
1717
healthcheck:
@@ -43,7 +43,7 @@ services:
4343

4444
kibana:
4545
# TODO: replace with a pinned version such as 9.0.0-aaaaaaaa-SNAPSHOT
46-
image: docker.elastic.co/kibana/kibana:9.0.0-bda98d6d-SNAPSHOT
46+
image: docker.elastic.co/kibana/kibana:9.0.0-db2e645e-SNAPSHOT
4747
ports:
4848
- 5601:5601
4949
healthcheck:
@@ -63,7 +63,7 @@ services:
6363

6464
metricbeat:
6565
# TODO: replace with a pinned version such as 9.0.0-aaaaaaaa-SNAPSHOT
66-
image: docker.elastic.co/beats/metricbeat:9.0.0-bda98d6d-SNAPSHOT
66+
image: docker.elastic.co/beats/metricbeat:9.0.0-db2e645e-SNAPSHOT
6767
environment:
6868
ELASTICSEARCH_HOSTS: '["http://elasticsearch:9200"]'
6969
ELASTICSEARCH_USERNAME: "${KIBANA_ES_USER:-admin}"

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
github.com/elastic/apm-data v1.13.1
1111
github.com/elastic/beats/v7 v7.0.0-alpha2.0.20240924123012-ecc521545d94
1212
github.com/elastic/elastic-agent-client/v7 v7.16.0
13-
github.com/elastic/elastic-agent-libs v0.11.0
13+
github.com/elastic/elastic-agent-libs v0.12.0
1414
github.com/elastic/elastic-agent-system-metrics v0.11.3
1515
github.com/elastic/gmux v0.3.2
1616
github.com/elastic/go-docappender/v2 v2.3.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ github.com/elastic/elastic-agent-autodiscover v0.8.2 h1:Fs2FhR33AMBPfm5/jz4drVza
139139
github.com/elastic/elastic-agent-autodiscover v0.8.2/go.mod h1:VZnU53EVaFTxR8Xf6YsLN8FHD5DKQzHSPlKax9/4w+o=
140140
github.com/elastic/elastic-agent-client/v7 v7.16.0 h1:yKGq2+CxAuW8Kh0EoNl202tqAyQKfBcPRawVKs2Jve0=
141141
github.com/elastic/elastic-agent-client/v7 v7.16.0/go.mod h1:6h+f9QdIr3GO2ODC0Y8+aEXRwzbA5W4eV4dd/67z7nI=
142-
github.com/elastic/elastic-agent-libs v0.11.0 h1:m9rnNE3BkBF2XJoqubqEbu/kbtKEBZ7pHCjDlxfVRH0=
143-
github.com/elastic/elastic-agent-libs v0.11.0/go.mod h1:5CR02awPrBr+tfmjBBK+JI+dMmHNQjpVY24J0wjbC7M=
142+
github.com/elastic/elastic-agent-libs v0.12.0 h1:xfVVCYIaI6XEPVpJNq7HQav7O/VxLj+YbQK/poWb7wA=
143+
github.com/elastic/elastic-agent-libs v0.12.0/go.mod h1:5CR02awPrBr+tfmjBBK+JI+dMmHNQjpVY24J0wjbC7M=
144144
github.com/elastic/elastic-agent-system-metrics v0.11.3 h1:LDzRwP8kxvsYEtMDgMSKZs1TgPcSEukit+/EAP5Y28A=
145145
github.com/elastic/elastic-agent-system-metrics v0.11.3/go.mod h1:saqLKe9fuyuAo6IADAnnuy1kaBI7VNlxfwMo8KzSRyQ=
146146
github.com/elastic/elastic-transport-go/v8 v8.6.0 h1:Y2S/FBjx1LlCv5m6pWAF2kDJAHoSjSRSJCApolgfthA=

systemtest/benchtest/profiles.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func (p *profiles) recordCPU() error {
8888
if benchConfig.CPUProfile == "" {
8989
return nil
9090
}
91-
duration := 2 * benchConfig.Benchtime
91+
duration := benchConfig.Benchtime
9292
profile, err := fetchProfile("/debug/pprof/profile", duration)
9393
if err != nil {
9494
return fmt.Errorf("failed to fetch CPU profile: %w", err)

testing/benchmark/Makefile

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ APMBENCH_PATH ?= ../../systemtest/cmd/apmbench
22
APMBENCH_GOOS ?= linux
33
APMBENCH_GOARCH ?= amd64
44

5+
MOXY_GOOS ?= linux
6+
MOXY_GOARCH ?= amd64
7+
8+
APM_SERVER_GOOS ?= linux
9+
APM_SERVER_GOARCH ?= amd64
10+
511
TFVARS_SOURCE ?= terraform.tfvars.example
612

713
BENCHMARK_WARMUP_TIME ?= 5m
@@ -23,6 +29,8 @@ SSH_USER ?= ec2-user
2329
SSH_OPTS ?= -o LogLevel=ERROR -o StrictHostKeyChecking=no -o ServerAliveInterval=60 -o ServerAliveCountMax=10
2430
SSH_KEY ?= ~/.ssh/id_rsa_terraform
2531
WORKER_IP = $(shell terraform output -raw public_ip)
32+
APM_SERVER_IP = $(shell terraform output -raw apm_server_ip)
33+
RUN_STANDALONE = $(shell echo var.run_standalone | terraform console | tr -d '"')
2634

2735
SHELL = /bin/bash
2836
.SHELLFLAGS = -o pipefail -c
@@ -67,6 +75,15 @@ apmbench:
6775
@echo "-> Building apmbench..."
6876
@cd $(APMBENCH_PATH) && CGO_ENABLED=0 GOOS=$(APMBENCH_GOOS) GOARCH=$(APMBENCH_GOARCH) go build .
6977

78+
.PHONY: moxy
79+
moxy:
80+
@echo "-> Building moxy..."
81+
@cd ../../tools && CGO_ENABLED=0 GOOS=$(MOXY_GOOS) GOARCH=$(MOXY_GOARCH) go build -o "../build" github.com/elastic/apm-perf/cmd/moxy
82+
83+
.PHONY: apm-server
84+
apm-server:
85+
@cd ../.. && make build/apm-server-$(APM_SERVER_GOOS)-$(APM_SERVER_GOARCH) && mv build/apm-server-$(APM_SERVER_GOOS)-$(APM_SERVER_GOARCH) build/apm-server
86+
7087
.PHONY: init
7188
init:
7289
@terraform init
@@ -110,13 +127,25 @@ index-benchmark-results: _default-gobench-vars
110127

111128
.PHONY: _default-gobench-vars
112129
_default-gobench-vars:
130+
ifeq ($(RUN_STANDALONE),true)
131+
$(eval GOBENCH_DEFAULT_TAGS = $(GOBENCH_DEFAULT_TAGS),apm_server_size=$(shell echo var.standalone_apm_server_instance_size | terraform console | tr -d '"'))
132+
$(eval GOBENCH_DEFAULT_TAGS = $(GOBENCH_DEFAULT_TAGS),moxy_size=$(shell echo var.standalone_moxy_instance_size | terraform console | tr -d '"'))
133+
$(eval GOBENCH_DEFAULT_TAGS = $(GOBENCH_DEFAULT_TAGS),build_sha=$(shell git rev-parse HEAD))
134+
$(eval GOBENCH_DEFAULT_TAGS = $(GOBENCH_DEFAULT_TAGS),bench_mode=standalone)
135+
else
113136
# TODO(marclop) Update code below to use a foor loop, rather than copying the lines.
114137
$(eval GOBENCH_DEFAULT_TAGS = $(GOBENCH_DEFAULT_TAGS),apm_server_size=$(shell echo var.apm_server_size | terraform console | tr -d '"'))
115138
$(eval GOBENCH_DEFAULT_TAGS = $(GOBENCH_DEFAULT_TAGS),elasticsearch_size=$(shell echo var.elasticsearch_size | terraform console | tr -d '"'))
116139
$(eval GOBENCH_DEFAULT_TAGS = $(GOBENCH_DEFAULT_TAGS),stack_version=$(shell echo var.stack_version | terraform console | tr -d '"'))
117140
$(eval GOBENCH_DEFAULT_TAGS = $(GOBENCH_DEFAULT_TAGS),apm_server_zone_count=$(shell echo var.apm_server_zone_count | terraform console | tr -d '"'))
118141
$(eval GOBENCH_DEFAULT_TAGS = $(GOBENCH_DEFAULT_TAGS),elasticsearch_zone_count=$(shell echo var.elasticsearch_zone_count | terraform console | tr -d '"'))
119142
$(eval GOBENCH_DEFAULT_TAGS = $(GOBENCH_DEFAULT_TAGS),build_sha=$(shell curl -sL -H "Authorization: Bearer $(shell terraform output -raw apm_secret_token )" $(shell terraform output -raw apm_server_url ) | jq -r '.build_sha'))
143+
$(eval GOBENCH_DEFAULT_TAGS = $(GOBENCH_DEFAULT_TAGS),bench_mode=cloud)
144+
endif
145+
146+
.PHONY: cat-apm-server-logs
147+
cat-apm-server-logs:
148+
@ssh $(SSH_OPTS) -i $(SSH_KEY) $(SSH_USER)@$(APM_SERVER_IP) "cat /var/log/apm-server/*"
120149

121150
$(SSH_KEY):
122151
@ssh-keygen -t rsa -b 4096 -C "$(USER)@elastic.co" -N "" -f $(SSH_KEY)
@@ -172,4 +201,4 @@ elastic_agent_docker_image: build_elastic_agent_docker_image
172201
build_elastic_agent_docker_image:
173202
@env BASE_IMAGE=${ELASTIC_AGENT_DOCKER_IMAGE}:${ELASTIC_AGENT_IMAGE_TAG} GOARCH=amd64 \
174203
bash ${REPO_ROOT}/testing/docker/elastic-agent/build.sh \
175-
-t ${CI_ELASTIC_AGENT_DOCKER_IMAGE}:${CUSTOM_IMAGE_TAG}
204+
-t ${CI_ELASTIC_AGENT_DOCKER_IMAGE}:${CUSTOM_IMAGE_TAG}

testing/benchmark/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ overridden automatically, you need to remove it manually if present.
8989
#### Override docker image tag
9090

9191
It is possible to override the tag of the docker image that is run in the remote ESS deployment. You can
92-
specify any of the avilable tags (such as `8.3.0-SNAPSHOT` or a more specific tag `8.3.0-c655cda8-SNAPSHOT`).
92+
specify any of the available tags (such as `8.3.0-SNAPSHOT` or a more specific tag `8.3.0-c655cda8-SNAPSHOT`).
9393
Alternatively, you can run `make docker-override-committed-version` in your shell, to have use the committed
9494
tags in the `docker-compose.yml` file in the repository root.
9595

0 commit comments

Comments
 (0)