Skip to content

Commit f7b1c3d

Browse files
committed
Merge remote-tracking branch 'upstream/main' into feature/test-opentelemetry-actions
* upstream/main: (148 commits) chore(deps): bump jsonwebtoken and @azure/msal-node (elastic#3087) fix bitrot.js dev-util to work for Next.js versions (elastic#3086) synchronize json schema specs (elastic#3082) chore(deps): bump json5 from 1.0.1 to 1.0.2 (elastic#3085) synchronize json schema specs (elastic#3078) chore(deps-dev): bump fastify from 4.10.2 to 4.11.0 (elastic#3083) chore(deps): bump next (elastic#3081) docs: fix header name with sampled flag (elastic#3069) 3.41.1 (elastic#3077) fix: span compression bug where a buffered span would not be sent when an incompressible sibling ended (elastic#3076) chore(deps-dev): bump wait-on from 6.0.1 to 7.0.1 (elastic#3075) chore(deps-dev): bump undici from 5.12.0 to 5.14.0 (elastic#3068) chore(deps-dev): bump got from 11.8.5 to 11.8.6 (elastic#3067) chore(deps-dev): bump koa from 2.13.4 to 2.14.1 (elastic#3066) chore(deps-dev): bump @hapi/hapi from 21.0.0 to 21.1.0 (elastic#3058) chore(deps-dev): bump @fastify/formbody from 7.3.0 to 7.4.0 (elastic#3057) 3.41.0 (elastic#3064) Support publishing a snapshot build for each commit to main (elastic#3050) fix: Add `tracestate` to the `TransactionOptions` TypeScript type (elastic#3063) fix: avoid IPv4 vs IPv6 ambiguity in default 'serverUrl' by using '127.0.0.1' rather than 'localhost' (elastic#3049) ...
2 parents f08e8af + 0408537 commit f7b1c3d

File tree

238 files changed

+13592
-8036
lines changed

Some content is hidden

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

238 files changed

+13592
-8036
lines changed

.ci/.jenkins_nightly_nodejs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
# made, these will stop and there will be no value in testing v17 nightlies.
1010
#
1111
NODEJS_VERSION:
12-
- "19"
12+
- "20"

.ci/.jenkins_nodejs.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
NODEJS_VERSION:
2-
# - "19" # Uncomment this when there are v19.x releases at https://nodejs.org/download/release/
2+
- "19"
33
- "18"
4-
# - "18.0" # Uncomment this when "18" is 18.1 or greater.
4+
- "18.0"
55
- "16"
66
- "16.0"
77
- "14"

.ci/.jenkins_rc_nodejs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# The node.js project *sometimes* produces "rc" builds leading up to a new
55
# release. They get uploaded to: https://nodejs.org/download/rc/
66
NODEJS_VERSION:
7+
- "19"
78
- "18"
89
- "16"
910
- "14"
10-
- "12"

.ci/.jenkins_tav.yml

+2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ TAV:
2626
- mongodb-core
2727
- mysql
2828
- mysql2
29+
- next
2930
- pg
3031
- pug
3132
- redis
3233
- restify
3334
- tedious
35+
- undici
3436
- ws

.ci/.jenkins_tav_nodejs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
NODEJS_VERSION:
2-
# - "19" # Uncomment this when there are v19.x releases at https://nodejs.org/en/about/releases/
2+
- "19"
33
- "18"
44
- "16"
55
- "14"

.ci/Jenkinsfile

+52-43
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@ pipeline {
88
BASE_DIR = "src/github.com/elastic/${env.REPO}"
99
PIPELINE_LOG_LEVEL='INFO'
1010
JOB_GCS_BUCKET = credentials('gcs-bucket')
11-
GITHUB_CHECK_ITS_NAME = 'Integration Tests'
12-
ITS_PIPELINE = 'apm-integration-tests-selector-mbp/main'
1311
GITHUB_CHECK = 'true'
1412
RELEASE_URL_MESSAGE = "(<https://github.com/elastic/${env.REPO}/releases/tag/${env.TAG_NAME}|${env.TAG_NAME}>)"
1513
SLACK_CHANNEL = '#apm-agent-node'
1614
NOTIFY_TO = '[email protected]'
1715
NPMRC_SECRET = 'secret/jenkins-ci/npmjs/elasticmachine'
1816
TOTP_SECRET = 'totp/code/npmjs-elasticmachine'
19-
BUILD_NODE_VERSION = 'v16.15.0'
17+
BUILD_NODE_VERSION = 'v16.15.1'
2018
DOCKER_REGISTRY = 'docker.elastic.co'
2119
DOCKER_SECRET = 'secret/apm-team/ci/docker-registry/prod'
2220
}
@@ -92,7 +90,7 @@ pipeline {
9290
def parallelTasks = [:]
9391
node['NODEJS_VERSION'].each{ version ->
9492
parallelTasks["Node.js-${version}"] = generateStep(version: version)
95-
parallelTasks["Node.js-${version}-async-hooks-false"] = generateStep(version: version, disableAsyncHooks: true)
93+
parallelTasks["Node.js-${version}-noasynchooks"] = generateStep(version: version, disableAsyncHooks: true)
9694
// TODO: to be enabled if required.
9795
// parallelTasks["Windows-Node.js-${version}"] = generateStepForWindows(version: version)
9896
}
@@ -193,18 +191,18 @@ pipeline {
193191
}
194192
}
195193
}
196-
stage('Nightly Test - No async hooks') {
194+
stage('Nightly Test - noasynchooks') {
197195
agent { label 'linux && immutable' }
198196
steps {
199-
withGithubNotify(context: 'Nightly No Async Hooks Test', tab: 'tests') {
197+
withGithubNotify(context: 'Nightly noasynchooks Test', tab: 'tests') {
200198
deleteDir()
201199
unstash 'source'
202200
dir("${BASE_DIR}"){
203201
script {
204202
def node = readYaml(file: '.ci/.jenkins_nightly_nodejs.yml')
205203
def parallelTasks = [:]
206204
node['NODEJS_VERSION'].each { version ->
207-
parallelTasks["Node.js-${version}-nightly-no-async-hooks"] = generateStep(version: version, buildType: 'nightly', disableAsyncHooks: true)
205+
parallelTasks["Node.js-${version}-nightly-noasynchooks"] = generateStep(version: version, buildType: 'nightly', disableAsyncHooks: true)
208206
}
209207
parallel(parallelTasks)
210208
}
@@ -231,18 +229,18 @@ pipeline {
231229
}
232230
}
233231
}
234-
stage('RC Test - No async hooks') {
232+
stage('RC Test - noasynchooks') {
235233
agent { label 'linux && immutable' }
236234
steps {
237-
withGithubNotify(context: 'RC No Async Hooks Test', tab: 'tests') {
235+
withGithubNotify(context: 'RC noasynchooks Test', tab: 'tests') {
238236
deleteDir()
239237
unstash 'source'
240238
dir("${BASE_DIR}"){
241239
script {
242240
def node = readYaml(file: '.ci/.jenkins_rc_nodejs.yml')
243241
def parallelTasks = [:]
244242
node['NODEJS_VERSION'].each { version ->
245-
parallelTasks["Node.js-${version}-rc-no-async-hooks"] = generateStep(version: version, buildType: 'rc', disableAsyncHooks: true)
243+
parallelTasks["Node.js-${version}-rc-noasynchooks"] = generateStep(version: version, buildType: 'rc', disableAsyncHooks: true)
246244
}
247245
parallel(parallelTasks)
248246
}
@@ -252,29 +250,39 @@ pipeline {
252250
}
253251
}
254252
}
255-
stage('Integration Tests') {
256-
agent none
257-
when {
258-
beforeAgent true
259-
allOf {
260-
not { tag pattern: 'v\\d+\\.\\d+\\.\\d+', comparator: 'REGEXP' }
261-
expression { return env.ONLY_DOCS == "false" }
262-
anyOf {
263-
changeRequest()
264-
expression { return !params.Run_As_Main_Branch }
265-
}
266-
}
253+
254+
/**
255+
Publish a snapshot. A "snapshot" is a packaging of the latest *unreleased* APM agent,
256+
published to a known GCS bucket for use in edge demo/test environments.
257+
*/
258+
stage('Publish snapshot') {
259+
options { skipDefaultCheckout() }
260+
environment {
261+
BUCKET_NAME = 'oblt-artifacts'
262+
DOCKER_REGISTRY = 'docker.elastic.co'
263+
DOCKER_REGISTRY_SECRET = 'secret/observability-team/ci/docker-registry/prod'
264+
GCS_ACCOUNT_SECRET = 'secret/observability-team/ci/snapshoty'
267265
}
266+
when { branch 'main' }
268267
steps {
269-
build(job: env.ITS_PIPELINE, propagate: false, wait: false,
270-
parameters: [string(name: 'INTEGRATION_TEST', value: 'Node.js'),
271-
string(name: 'BUILD_OPTS', value: "--nodejs-agent-package ${env.CHANGE_FORK?.trim() ?: 'elastic' }/${env.REPO}#${env.GIT_BASE_COMMIT} --opbeans-node-agent-branch ${env.GIT_BASE_COMMIT}"),
272-
string(name: 'GITHUB_CHECK_NAME', value: env.GITHUB_CHECK_ITS_NAME),
273-
string(name: 'GITHUB_CHECK_REPO', value: env.REPO),
274-
string(name: 'GITHUB_CHECK_SHA1', value: env.GIT_BASE_COMMIT)])
275-
githubNotify(context: "${env.GITHUB_CHECK_ITS_NAME}", description: "${env.GITHUB_CHECK_ITS_NAME} ...", status: 'PENDING', targetUrl: "${env.JENKINS_URL}search/?q=${env.ITS_PIPELINE.replaceAll('/','+')}")
268+
withGithubNotify(context: 'Publish snapshot packages') {
269+
deleteDir()
270+
unstash name: 'source'
271+
withNodeJSEnv(version: env.BUILD_NODE_VERSION) {
272+
dir(env.BASE_DIR) {
273+
sh(label: 'package snapshot', script: 'npm run package:snapshot')
274+
snapshoty(
275+
bucket: env.BUCKET_NAME,
276+
gcsAccountSecret: env.GCS_ACCOUNT_SECRET,
277+
dockerRegistry: env.DOCKER_REGISTRY,
278+
dockerSecret: env.DOCKER_REGISTRY_SECRET
279+
)
280+
}
281+
}
282+
}
276283
}
277284
}
285+
278286
stage('Release') {
279287
options { skipDefaultCheckout() }
280288
when {
@@ -371,7 +379,7 @@ pipeline {
371379
The result JSON files are also archive into Jenkins.
372380
*/
373381
stage('Benchmarks') {
374-
agent { label 'metal' }
382+
agent { label 'microbenchmarks-pool' }
375383
options { skipDefaultCheckout() }
376384
environment {
377385
HOME = "${env.WORKSPACE}"
@@ -424,22 +432,23 @@ def generateStep(Map params = [:]){
424432
def version = params?.version
425433
def tav = params.containsKey('tav') ? params.tav : ''
426434
def buildType = params.containsKey('buildType') ? params.buildType : 'release'
427-
def ELASTIC_APM_ASYNC_HOOKS = String.valueOf(!params.get('disableAsyncHooks', false))
435+
def contextManager = params.get('disableAsyncHooks', false) ? 'patch' : ''
428436
return {
429437
withNode(labels: 'linux && immutable', forceWorkspace: true, forceWorker: true) {
430-
withEnv(["VERSION=${version}", "ELASTIC_APM_ASYNC_HOOKS=${ELASTIC_APM_ASYNC_HOOKS}"]) {
438+
withEnv(["VERSION=${version}", "ELASTIC_APM_CONTEXT_MANAGER=${contextManager}"]) {
431439
deleteDir()
432440
unstash 'source'
433-
dir("${BASE_DIR}"){
434-
try {
435-
retryWithSleep(retries: 2, seconds: 5, backoff: true) {
436-
sh(label: "Run Tests", script: """.ci/scripts/test.sh -b "${buildType}" -t "${tav}" "${version}" """)
441+
// Grab the current docker context for helping to troubleshoot the docker containers using filebeat and metricbeat
442+
dockerContext(filebeatOutput: "docker-${version}-${buildType}.log", metricbeatOutput: "docker-${version}-${buildType}-metricbeat.log", archiveOnlyOnFail: true){
443+
dir("${BASE_DIR}"){
444+
try {
445+
retryWithSleep(retries: 2, seconds: 5, backoff: true) {
446+
sh(label: "Run Tests", script: """.ci/scripts/test.sh -b "${buildType}" -t "${tav}" "${version}" """)
447+
}
448+
} finally {
449+
junit(testResults: "test_output/*.junit.xml", allowEmptyResults: true, keepLongStdio: true)
450+
archiveArtifacts(artifacts: "test_output/*.tap", allowEmptyArchive: true)
437451
}
438-
} catch(e){
439-
error(e.toString())
440-
} finally {
441-
junit(testResults: "test_output/*.junit.xml", allowEmptyResults: true, keepLongStdio: true)
442-
archiveArtifacts(artifacts: "test_output/*.tap", allowEmptyArchive: true)
443452
}
444453
}
445454
}
@@ -516,15 +525,15 @@ def getSmartTAVContext() {
516525

517526
def generateStepForWindows(Map params = [:]){
518527
def version = params?.version
519-
def ELASTIC_APM_ASYNC_HOOKS = String.valueOf(!params.get('disableAsyncHooks', false))
528+
def contextManager = params.get('disableAsyncHooks', false) ? 'patch' : ''
520529
return {
521530
sh label: 'Prepare services', script: ".ci/scripts/windows/prepare-test.sh ${version}"
522531
def linuxIp = grabWorkerIP()
523532
withNode(labels: 'windows-2019-docker-immutable', forceWorkspace: true, forceWorker: true) {
524533
// When installing with choco the PATH might not be updated within the already connected worker.
525534
withEnv(["PATH=${PATH};C:\\Program Files\\nodejs",
526535
"VERSION=${version}",
527-
"ELASTIC_APM_ASYNC_HOOKS=${ELASTIC_APM_ASYNC_HOOKS}",
536+
"ELASTIC_APM_CONTEXT_MANAGER=${contextManager}",
528537
"CASSANDRA_HOST=${linuxIp}",
529538
"ES_HOST=${linuxIp}",
530539
"LOCALSTACK_HOST=${linuxIp}",

.ci/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ publish: validate-layer-name validate-aws-default-region
5858
--layer-name "$(ELASTIC_LAYER_NAME)" \
5959
--description "AWS Lambda Extension Layer for the Elastic APM Node.js Agent" \
6060
--license "Apache-2.0" \
61-
--compatible-runtimes nodejs16.x nodejs14.x nodejs12.x nodejs10.x \
61+
--compatible-runtimes nodejs18.x nodejs16.x nodejs14.x nodejs12.x nodejs10.x \
6262
--zip-file "fileb://./$(AWS_FOLDER)/elastic-apm-node-lambda-layer-$(BRANCH_NAME).zip"
6363

6464
# Grant public access to the given LAYER in the given AWS region

.ci/docker/docker-compose-node-edge-test.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ services:
99
- NODE_VERSION=${NODE_VERSION}
1010
- NODE_FULL_VERSION=${NODE_FULL_VERSION}
1111
- NVM_NODEJS_ORG_MIRROR=${NVM_NODEJS_ORG_MIRROR}
12-
- ELASTIC_APM_ASYNC_HOOKS=${ELASTIC_APM_ASYNC_HOOKS}
12+
- ELASTIC_APM_CONTEXT_MANAGER=${ELASTIC_APM_CONTEXT_MANAGER}
1313
working_dir: /app
1414
command: >
1515
/bin/bash -c ".ci/scripts/docker-test.sh"
@@ -27,7 +27,7 @@ services:
2727
NODE_VERSION: ${NODE_VERSION}
2828
NODE_FULL_VERSION: ${NODE_FULL_VERSION}
2929
NVM_NODEJS_ORG_MIRROR: ${NVM_NODEJS_ORG_MIRROR}
30-
ELASTIC_APM_ASYNC_HOOKS: ${ELASTIC_APM_ASYNC_HOOKS}
30+
ELASTIC_APM_CONTEXT_MANAGER: ${ELASTIC_APM_CONTEXT_MANAGER}
3131
TAV: ${TAV_MODULE}
3232
HOME: /tmp
3333
volumes:

.ci/docker/docker-compose-node-test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ services:
2323
LOCALSTACK_HOST: 'localstack'
2424
NODE_VERSION: ${NODE_VERSION}
2525
TAV: ${TAV_MODULE}
26-
ELASTIC_APM_ASYNC_HOOKS: ${ELASTIC_APM_ASYNC_HOOKS}
26+
ELASTIC_APM_CONTEXT_MANAGER: ${ELASTIC_APM_CONTEXT_MANAGER}
2727
HOME: /tmp
2828
PATH: /app/node_modules/.bin:./node_modules/.bin:/app/node_modules:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
2929
volumes:

.ci/docker/docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ services:
1919
retries: 30
2020

2121
mongodb:
22-
image: mongo
22+
image: mongo:5
2323
ports:
2424
- "27017:27017"
2525
volumes:

.ci/docker/node-edge-container/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ RUN apt-get -qq update \
1414
ARG NODE_VERSION
1515
ARG NODE_FULL_VERSION
1616
ARG NVM_NODEJS_ORG_MIRROR
17-
ARG ELASTIC_APM_ASYNC_HOOKS
17+
ARG ELASTIC_APM_CONTEXT_MANAGER
1818
ENV NODE_VERSION=${NODE_VERSION}
1919
ENV NODE_FULL_VERSION=${NODE_FULL_VERSION}
2020
ENV NVM_NODEJS_ORG_MIRROR=${NVM_NODEJS_ORG_MIRROR}
21-
ENV ELASTIC_APM_ASYNC_HOOKS=${ELASTIC_APM_ASYNC_HOOKS}
21+
ENV ELASTIC_APM_CONTEXT_MANAGER=${ELASTIC_APM_CONTEXT_MANAGER}
2222

2323
# nvm environment variables
2424
ENV NVM_VERSION v0.34.0

.ci/scripts/docker-test.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ npm_install() {
3131
local retries=2
3232
local count=0
3333

34-
until npm install; do
34+
until npm install --no-save; do
3535
exit=$?
3636
wait=$((2 ** $count))
3737
count=$(($count + 1))

.ci/scripts/test.sh

+2-4
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,9 @@ else
226226
DOCKER_COMPOSE_FILE=docker-compose-all.yml
227227
fi
228228

229-
ELASTIC_APM_ASYNC_HOOKS=${ELASTIC_APM_ASYNC_HOOKS:-true}
230-
231229
set +e
232230
NVM_NODEJS_ORG_MIRROR=${NVM_NODEJS_ORG_MIRROR} \
233-
ELASTIC_APM_ASYNC_HOOKS=${ELASTIC_APM_ASYNC_HOOKS} \
231+
ELASTIC_APM_CONTEXT_MANAGER=${ELASTIC_APM_CONTEXT_MANAGER} \
234232
NODE_VERSION=${NODE_VERSION} \
235233
NODE_FULL_VERSION=${NODE_FULL_VERSION} \
236234
TAV_MODULE=${TAV_MODULE} \
@@ -250,7 +248,7 @@ fi
250248

251249
set -e
252250
NVM_NODEJS_ORG_MIRROR=${NVM_NODEJS_ORG_MIRROR} \
253-
ELASTIC_APM_ASYNC_HOOKS=${ELASTIC_APM_ASYNC_HOOKS} \
251+
ELASTIC_APM_CONTEXT_MANAGER=${ELASTIC_APM_CONTEXT_MANAGER} \
254252
NODE_VERSION=${NODE_VERSION} \
255253
NODE_FULL_VERSION=${NODE_FULL_VERSION} \
256254
TAV_MODULE=${TAV_MODULE} \

.ci/snapshoty.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
3+
# Version of configuration to use
4+
version: '1.0'
5+
6+
# You can define a Google Cloud Account to use
7+
account:
8+
# Project id of the service account
9+
project: '${GCS_PROJECT}'
10+
# Private key id of the service account
11+
private_key_id: '${GCS_PRIVATE_KEY_ID}'
12+
# Private key of the service account
13+
private_key: '${GCS_PRIVATE_KEY}'
14+
# Email of the service account
15+
client_email: '${GCS_CLIENT_EMAIL}'
16+
# URI token
17+
token_uri: 'https://oauth2.googleapis.com/token'
18+
19+
# List of artifacts
20+
artifacts:
21+
# Path to use for artifacts discovery
22+
- path: './build/snapshot'
23+
# Files pattern to match
24+
files_pattern: 'elastic-apm-node-(?P<app_version>\d+\.\d+\.\d+)\.tgz'
25+
# File layout on GCS bucket
26+
output_pattern: '{project}/{jenkins_branch_name}/elastic-apm-node-{app_version}-{jenkins_git_commit_short}.tgz'
27+
# List of metadata processors to use.
28+
metadata:
29+
# Define static custom metadata
30+
- name: 'custom'
31+
data:
32+
project: 'apm-agent-nodejs'
33+
# Add git metadata
34+
- name: 'git'
35+
# Add jenkins metadata
36+
- name: 'jenkins'

.eslintrc.json

+6
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,18 @@
1111
"license-header/header": [ "error", "./dev-utils/license-header.js" ]
1212
},
1313
"ignorePatterns": [
14+
"/*.example.js", // a pattern for uncommited local dev files to avoid linting
1415
"/.nyc_output",
1516
"/build",
1617
"node_modules",
18+
"/examples/esbuild/dist",
19+
"/examples/typescript/dist",
20+
"/examples/nextjs",
1721
"/lib/opentelemetry-bridge/opentelemetry-core-mini",
1822
"/test/babel/out.js",
1923
"/test/lambda/fixtures/esbuild-bundled-handler/hello.js",
24+
"/test/instrumentation/modules/next/a-nextjs-app/pages",
25+
"/test/instrumentation/modules/next/a-nextjs-app/components",
2026
"/test/sourcemaps/fixtures/lib",
2127
"/test/sourcemaps/fixtures/src",
2228
"/test/stacktraces/fixtures/dist",

0 commit comments

Comments
 (0)