From 65eedc44596cec7bc427d20facf71997ab527400 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Mon, 31 Jul 2023 16:28:00 -0700 Subject: [PATCH 01/18] 4.x This is a start at a major version bump, primarily to move the min supported Node.js to v14 (from v8.6). --- CHANGELOG4.asciidoc | 58 +++++++++++++++++++++++++++++++++++++++++++++ package.json | 5 ++-- 2 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 CHANGELOG4.asciidoc diff --git a/CHANGELOG4.asciidoc b/CHANGELOG4.asciidoc new file mode 100644 index 0000000000..cc17d35d2c --- /dev/null +++ b/CHANGELOG4.asciidoc @@ -0,0 +1,58 @@ +ifdef::env-github[] +NOTE: Release notes are best read in our documentation at +https://www.elastic.co/guide/en/apm/agent/nodejs/current/release-notes.html[elastic.co] +endif::[] + +//// +Notes: +1. When adding a changelog entry, if the "Unreleased" section doesn't yet exist, + please add the following under the "=== Node.js Agent version 3.x" header: + + ==== Unreleased + + [float] + ===== Breaking changes + + [float] + ===== Features + + [float] + ===== Bug fixes + + [float] + ===== Chores + +2. When making a release, change the "==== Unreleased" section header to: + + [[release-notes-x.x.x]] + ==== x.x.x - YYYY/MM/DD +//// + + +[[release-notes-4.x]] +=== Node.js Agent version 1.x + +==== Unreleased + +[float] +===== Breaking changes + +* Set the new minimum supported Node.js to version 14. + Users of earlier Node.js versions can use elastic-apm-node v3.x, which + supports back to Node.js v8.6. + +[float] +===== Features + +[float] +===== Bug fixes + +[float] +===== Chores + + +[[release-notes-3.x]] +=== Node.js Agent version 3.x + +XXX This CHANGELOG4 file will be merged into CHANGELOG.asciidoc before merging to main. + diff --git a/package.json b/package.json index b4ef9f940c..e9d8bb25da 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "name": "elastic-apm-node", - "version": "3.48.0", + "version": "4.0.0-dev", + "private": true, "description": "The official Elastic APM agent for Node.js", "main": "index.js", "types": "index.d.ts", @@ -49,7 +50,7 @@ "url": "git://github.com/elastic/apm-agent-nodejs.git" }, "engines": { - "node": ">=8.6.0" + "node": ">=14" }, "keywords": [ "opbeat", From c6855a5e3aeade13478616eb4f665c27c4cfec89 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Mon, 31 Jul 2023 16:35:13 -0700 Subject: [PATCH 02/18] update package-lock vers; drop testing for anything before 14.0; drop testing for contextManager=patch --- .github/workflows/test.yml | 9 --------- CHANGELOG4.asciidoc | 31 ------------------------------- package-lock.json | 6 +++--- 3 files changed, 3 insertions(+), 43 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cb5ca7176d..646bc0dc93 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -134,13 +134,6 @@ jobs: - '16.0' - '14' - '14.0' - - '12' - - '12.0' - - '10' - - '10.0' - - '8' - - '8.6' - contextManager: [ 'patch', '' ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -152,8 +145,6 @@ jobs: - run: npm ls --all || true - name: npm test run: npm test - env: - ELASTIC_APM_CONTEXT_MANAGER: ${{ matrix.contextManager }} - uses: inception-health/otel-upload-test-artifact-action@v1 if: always() continue-on-error: true diff --git a/CHANGELOG4.asciidoc b/CHANGELOG4.asciidoc index cc17d35d2c..e834b2b6eb 100644 --- a/CHANGELOG4.asciidoc +++ b/CHANGELOG4.asciidoc @@ -1,34 +1,3 @@ -ifdef::env-github[] -NOTE: Release notes are best read in our documentation at -https://www.elastic.co/guide/en/apm/agent/nodejs/current/release-notes.html[elastic.co] -endif::[] - -//// -Notes: -1. When adding a changelog entry, if the "Unreleased" section doesn't yet exist, - please add the following under the "=== Node.js Agent version 3.x" header: - - ==== Unreleased - - [float] - ===== Breaking changes - - [float] - ===== Features - - [float] - ===== Bug fixes - - [float] - ===== Chores - -2. When making a release, change the "==== Unreleased" section header to: - - [[release-notes-x.x.x]] - ==== x.x.x - YYYY/MM/DD -//// - - [[release-notes-4.x]] === Node.js Agent version 1.x diff --git a/package-lock.json b/package-lock.json index b27ab90008..c0d124aafd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "elastic-apm-node", - "version": "3.48.0", + "version": "4.0.0-dev", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "elastic-apm-node", - "version": "3.48.0", + "version": "4.0.0-dev", "license": "BSD-2-Clause", "dependencies": { "@elastic/ecs-pino-format": "^1.2.0", @@ -133,7 +133,7 @@ "ws": "^7.2.1" }, "engines": { - "node": ">=8.6.0" + "node": ">=14" } }, "node_modules/@ampproject/remapping": { From 03954bf39bd7f1170def0552fa6b843db4b37f1c Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Mon, 31 Jul 2023 16:38:55 -0700 Subject: [PATCH 03/18] drop node v10 and v8 *TAV* testing --- .ci/tav.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.ci/tav.json b/.ci/tav.json index 2e2d90234c..cc84522b0c 100644 --- a/.ci/tav.json +++ b/.ci/tav.json @@ -1,6 +1,5 @@ { - "// todo": "We want versions=['20','19','18','16','14','12','10','8'], but versions*modules needs to be <256 for the GH Actions jobs limit", - "versions": [ "20", "18", "16", "14", "12", "10", "8" ], + "versions": [ "20", "19", "18", "16", "14" ], "modules": [ "@apollo/server", "@aws-sdk/client-s3", From 3034943140664d2254d990eeabd5ae4aa358d6d6 Mon Sep 17 00:00:00 2001 From: David Luna Date: Tue, 1 Aug 2023 16:37:01 +0200 Subject: [PATCH 04/18] chore: add min version in TAV matrix --- .ci/tav.json | 68 +++++++++++++++---------------- .github/workflows/tav-command.yml | 25 ++++++++---- 2 files changed, 52 insertions(+), 41 deletions(-) diff --git a/.ci/tav.json b/.ci/tav.json index cc84522b0c..596f63f6db 100644 --- a/.ci/tav.json +++ b/.ci/tav.json @@ -1,38 +1,38 @@ { - "versions": [ "20", "19", "18", "16", "14" ], + "versions": [ 20, 19, 18, 16, 14 ], "modules": [ - "@apollo/server", - "@aws-sdk/client-s3", - "@elastic/elasticsearch", - "@hapi/hapi", - "@opentelemetry/api", - "@opentelemetry/sdk-metrics", - "apollo-server-express", - "aws-sdk", - "cassandra-driver", - "elasticsearch", - "express", - "express-queue", - "fastify", - "finalhandler", - "generic-pool", - "graphql", - "ioredis", - "knex", - "memcached", - "mongodb", - "mongodb-core", - "mysql", - "mysql2", - "next", - "pg", - "redis", - "restify", - "tedious", - "undici", - "ws", - "@koa/router,koa-router", - "handlebars,pug", - "bluebird,got" + {"name": "@apollo/server", "minVersion": 18 }, + {"name": "@aws-sdk/client-s3", "minVersion": 18 }, + {"name": "@elastic/elasticsearch", "minVersion": 18 }, + {"name": "@hapi/hapi", "minVersion": 18 }, + {"name": "@opentelemetry/api", "minVersion": 18 }, + {"name": "@opentelemetry/sdk-metrics", "minVersion": 18 }, + {"name": "apollo-server-express", "minVersion": 18 }, + {"name": "aws-sdk", "minVersion": 18 }, + {"name": "cassandra-driver", "minVersion": 18 }, + {"name": "elasticsearch", "minVersion": 18 }, + {"name": "express", "minVersion": 18 }, + {"name": "express-queue", "minVersion": 18 }, + {"name": "fastify", "minVersion": 18 }, + {"name": "finalhandler", "minVersion": 18 }, + {"name": "generic-pool", "minVersion": 18 }, + {"name": "graphql", "minVersion": 18 }, + {"name": "ioredis", "minVersion": 18 }, + {"name": "knex", "minVersion": 18 }, + {"name": "memcached", "minVersion": 18 }, + {"name": "mongodb", "minVersion": 18 }, + {"name": "mongodb-core", "minVersion": 18 }, + {"name": "mysql", "minVersion": 18 }, + {"name": "mysql2", "minVersion": 18 }, + {"name": "next", "minVersion": 18 }, + {"name": "pg", "minVersion": 18 }, + {"name": "redis", "minVersion": 18 }, + {"name": "restify", "minVersion": 18 }, + {"name": "tedious", "minVersion": 18 }, + {"name": "undici", "minVersion": 18 }, + {"name": "ws", "minVersion": 18 }, + {"name": "@koa/router,koa-router", "minVersion": 18 }, + {"name": "handlebars,pug", "minVersion": 18 }, + {"name": "bluebird,got", "minVersion": 18 } ] } diff --git a/.github/workflows/tav-command.yml b/.github/workflows/tav-command.yml index 8fd2a822f4..810c1738ab 100644 --- a/.github/workflows/tav-command.yml +++ b/.github/workflows/tav-command.yml @@ -19,8 +19,8 @@ jobs: permissions: pull-requests: write outputs: - versions: ${{ steps.transform.outputs.versions }} - modules: ${{ steps.transform.outputs.modules }} + permutations: ${{ steps.transform.outputs.permutations }} + count: ${{ steps.transform.outputs.count }} steps: - name: Is comment allowed? uses: actions/github-script@v6 @@ -79,8 +79,19 @@ jobs: versions = match[3].split(',') } } - core.setOutput('modules', modules) - core.setOutput('versions', versions) + + const permutations = [] + for (const mod of modules) { + for (const nv of versions) { + if (mod.minVersion && nv >= mod.minVersion) { + permutations.push(`${mod.name} ${nv}`); + } else if (typeof mod === 'string') { + permutations.push(`${mod} ${nv}`); + } + } + } + core.setOutput('permutations', permutations) + core.setOutput('count', [permutations.length]) test-tav: needs: command-validation @@ -90,14 +101,14 @@ jobs: max-parallel: 15 fail-fast: false matrix: - node: ${{ fromJSON(needs.command-validation.outputs.versions) }} - module: ${{ fromJSON(needs.command-validation.outputs.modules) }} + count: ${{ fromJSON(needs.command-validation.outputs.count) }} + moduleAndNode: ${{ fromJSON(needs.command-validation.outputs.permutations) }} steps: - uses: actions/checkout@v3 with: ref: ${{ github.event.pull_request.head.sha }} - - run: .ci/scripts/test.sh -b "release" -t "${{ matrix.module }}" "${{ matrix.node }}" + - run: .ci/scripts/test.sh -b "release" -t ${{ matrix.moduleAndNode }} env: ELASTIC_APM_CONTEXT_MANAGER: '' From 99e15965bc9b6d4287e49d29e0e5fa3e3425f102 Mon Sep 17 00:00:00 2001 From: David Luna Date: Tue, 1 Aug 2023 16:54:07 +0200 Subject: [PATCH 05/18] chore: swap matrix inputs --- .github/workflows/tav-command.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tav-command.yml b/.github/workflows/tav-command.yml index 810c1738ab..2a23e84f5f 100644 --- a/.github/workflows/tav-command.yml +++ b/.github/workflows/tav-command.yml @@ -101,8 +101,8 @@ jobs: max-parallel: 15 fail-fast: false matrix: - count: ${{ fromJSON(needs.command-validation.outputs.count) }} moduleAndNode: ${{ fromJSON(needs.command-validation.outputs.permutations) }} + count: ${{ fromJSON(needs.command-validation.outputs.count) }} steps: - uses: actions/checkout@v3 From e1cd52c2f14388303096b3d167c6e264b15358f1 Mon Sep 17 00:00:00 2001 From: David Luna Date: Tue, 1 Aug 2023 17:14:48 +0200 Subject: [PATCH 06/18] chore: better calculation of min versions --- .github/workflows/tav-command.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tav-command.yml b/.github/workflows/tav-command.yml index 2a23e84f5f..b64689e148 100644 --- a/.github/workflows/tav-command.yml +++ b/.github/workflows/tav-command.yml @@ -72,11 +72,11 @@ jobs: } if (match[1]) { if (match[1] !== 'all') { - modules = match[1].split(',') + modules = match[1].split(',').map((name) => modules.find((m) => m.name === name)) } } if (match[3]) { - versions = match[3].split(',') + versions = match[3].split(',').map(Number) } } @@ -84,9 +84,9 @@ jobs: for (const mod of modules) { for (const nv of versions) { if (mod.minVersion && nv >= mod.minVersion) { - permutations.push(`${mod.name} ${nv}`); + permutations.push(`${mod.name} ${nv}`) } else if (typeof mod === 'string') { - permutations.push(`${mod} ${nv}`); + permutations.push(`${mod} ${nv}`) } } } From 1932af7d99b4f08c09650586813de2aff38c1aac Mon Sep 17 00:00:00 2001 From: David Luna Date: Tue, 1 Aug 2023 17:38:23 +0200 Subject: [PATCH 07/18] chore: guard for packages and versions --- .github/workflows/tav-command.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/tav-command.yml b/.github/workflows/tav-command.yml index b64689e148..d5723e36bf 100644 --- a/.github/workflows/tav-command.yml +++ b/.github/workflows/tav-command.yml @@ -80,6 +80,18 @@ jobs: } } + const badModuleIndex = modules.findIndex((m) => !m) + const badVersionIndex = versions.findIndex((v) => isNaN(v)) + + if (badModuleIndex !== -1) { + core.setFailed(`Incorrect modules list, please review it'`) + return + } + if (badVersionIndex !== -1) { + core.setFailed(`Incorrect versions list, please review it'`) + return + } + const permutations = [] for (const mod of modules) { for (const nv of versions) { From 1b0969fd0f1737b038b1b62bcb069c66c3381a78 Mon Sep 17 00:00:00 2001 From: David Luna Date: Wed, 2 Aug 2023 11:17:36 +0200 Subject: [PATCH 08/18] chore: fix other YML files --- .ci/tav.json | 68 +++++++++++++++---------------- .github/workflows/tav-command.yml | 53 +++++++++++++----------- .github/workflows/tav.yml | 23 +++++++---- .github/workflows/test.yml | 9 ++++ CHANGELOG4.asciidoc | 27 ------------ 5 files changed, 89 insertions(+), 91 deletions(-) delete mode 100644 CHANGELOG4.asciidoc diff --git a/.ci/tav.json b/.ci/tav.json index 596f63f6db..0ca4df744d 100644 --- a/.ci/tav.json +++ b/.ci/tav.json @@ -1,38 +1,38 @@ { - "versions": [ 20, 19, 18, 16, 14 ], + "versions": [ 20, 19, 18, 16, 14, 12, 10, 8 ], "modules": [ - {"name": "@apollo/server", "minVersion": 18 }, - {"name": "@aws-sdk/client-s3", "minVersion": 18 }, - {"name": "@elastic/elasticsearch", "minVersion": 18 }, - {"name": "@hapi/hapi", "minVersion": 18 }, - {"name": "@opentelemetry/api", "minVersion": 18 }, - {"name": "@opentelemetry/sdk-metrics", "minVersion": 18 }, - {"name": "apollo-server-express", "minVersion": 18 }, - {"name": "aws-sdk", "minVersion": 18 }, - {"name": "cassandra-driver", "minVersion": 18 }, - {"name": "elasticsearch", "minVersion": 18 }, - {"name": "express", "minVersion": 18 }, - {"name": "express-queue", "minVersion": 18 }, - {"name": "fastify", "minVersion": 18 }, - {"name": "finalhandler", "minVersion": 18 }, - {"name": "generic-pool", "minVersion": 18 }, - {"name": "graphql", "minVersion": 18 }, - {"name": "ioredis", "minVersion": 18 }, - {"name": "knex", "minVersion": 18 }, - {"name": "memcached", "minVersion": 18 }, - {"name": "mongodb", "minVersion": 18 }, - {"name": "mongodb-core", "minVersion": 18 }, - {"name": "mysql", "minVersion": 18 }, - {"name": "mysql2", "minVersion": 18 }, - {"name": "next", "minVersion": 18 }, - {"name": "pg", "minVersion": 18 }, - {"name": "redis", "minVersion": 18 }, - {"name": "restify", "minVersion": 18 }, - {"name": "tedious", "minVersion": 18 }, - {"name": "undici", "minVersion": 18 }, - {"name": "ws", "minVersion": 18 }, - {"name": "@koa/router,koa-router", "minVersion": 18 }, - {"name": "handlebars,pug", "minVersion": 18 }, - {"name": "bluebird,got", "minVersion": 18 } + {"name": "@apollo/server", "minVersion": 19 }, + {"name": "@aws-sdk/client-s3", "minVersion": 19 }, + {"name": "@elastic/elasticsearch", "minVersion": 19 }, + {"name": "@hapi/hapi", "minVersion": 19 }, + {"name": "@opentelemetry/api", "minVersion": 19 }, + {"name": "@opentelemetry/sdk-metrics", "minVersion": 19 }, + {"name": "apollo-server-express", "minVersion": 19 }, + {"name": "aws-sdk", "minVersion": 19 }, + {"name": "cassandra-driver", "minVersion": 19 }, + {"name": "elasticsearch", "minVersion": 19 }, + {"name": "express", "minVersion": 19 }, + {"name": "express-queue", "minVersion": 19 }, + {"name": "fastify", "minVersion": 19 }, + {"name": "finalhandler", "minVersion": 19 }, + {"name": "generic-pool", "minVersion": 19 }, + {"name": "graphql", "minVersion": 19 }, + {"name": "ioredis", "minVersion": 19 }, + {"name": "knex", "minVersion": 19 }, + {"name": "memcached", "minVersion": 19 }, + {"name": "mongodb", "minVersion": 19 }, + {"name": "mongodb-core", "minVersion": 19 }, + {"name": "mysql", "minVersion": 19 }, + {"name": "mysql2", "minVersion": 19 }, + {"name": "next", "minVersion": 19 }, + {"name": "pg", "minVersion": 19 }, + {"name": "redis", "minVersion": 19 }, + {"name": "restify", "minVersion": 19 }, + {"name": "tedious", "minVersion": 19 }, + {"name": "undici", "minVersion": 19 }, + {"name": "ws", "minVersion": 19 }, + {"name": "@koa/router,koa-router", "minVersion": 19 }, + {"name": "handlebars,pug", "minVersion": 19 }, + {"name": "bluebird,got", "minVersion": 19 } ] } diff --git a/.github/workflows/tav-command.yml b/.github/workflows/tav-command.yml index d5723e36bf..15f6d9cda5 100644 --- a/.github/workflows/tav-command.yml +++ b/.github/workflows/tav-command.yml @@ -20,7 +20,6 @@ jobs: pull-requests: write outputs: permutations: ${{ steps.transform.outputs.permutations }} - count: ${{ steps.transform.outputs.count }} steps: - name: Is comment allowed? uses: actions/github-script@v6 @@ -63,6 +62,9 @@ jobs: return } const comment = context.payload.review.body + const resolvedModules = [] + const resolvedVersions = [] + let inputNames, inputVersions if (comment !== '/test tav') { const regex = /\/test tav ([^\s]+)(\s*)([^\s]*)/ const match = comment.match(regex) @@ -72,38 +74,44 @@ jobs: } if (match[1]) { if (match[1] !== 'all') { - modules = match[1].split(',').map((name) => modules.find((m) => m.name === name)) + inputNames = match[1].split(',') + for (const name of inputNames) { + const mod = modules.find((m) => m.name === name) + if (mod) { + resolvedModules.push(mod) + } else { + core.setFailed(`Incorrect module name ${name}, please review it'`) + return + } + } + } else { + resolvedModules.push(...modules) } } if (match[3]) { - versions = match[3].split(',').map(Number) + inputVersions = match[3].split(',').map(Number) + if (inputVersions.some((v) => isNaN(v))) { + core.setFailed(`Incorrect versions list ${match[3]}, please review it'`) + return + } + } else { + resolvedVersions.push(...versions) } } - const badModuleIndex = modules.findIndex((m) => !m) - const badVersionIndex = versions.findIndex((v) => isNaN(v)) - - if (badModuleIndex !== -1) { - core.setFailed(`Incorrect modules list, please review it'`) - return - } - if (badVersionIndex !== -1) { - core.setFailed(`Incorrect versions list, please review it'`) - return - } - const permutations = [] - for (const mod of modules) { - for (const nv of versions) { + for (const mod of resolvedModules) { + for (const nv of resolvedVersions) { if (mod.minVersion && nv >= mod.minVersion) { permutations.push(`${mod.name} ${nv}`) - } else if (typeof mod === 'string') { - permutations.push(`${mod} ${nv}`) } } } + if (permutations.length > 256) { + core.setFailed(`Matrix size (${permutations.length}) is bigger than the limit (256)`) + return + } core.setOutput('permutations', permutations) - core.setOutput('count', [permutations.length]) test-tav: needs: command-validation @@ -113,14 +121,13 @@ jobs: max-parallel: 15 fail-fast: false matrix: - moduleAndNode: ${{ fromJSON(needs.command-validation.outputs.permutations) }} - count: ${{ fromJSON(needs.command-validation.outputs.count) }} + module_and_node: ${{ fromJSON(needs.command-validation.outputs.permutations) }} steps: - uses: actions/checkout@v3 with: ref: ${{ github.event.pull_request.head.sha }} - - run: .ci/scripts/test.sh -b "release" -t ${{ matrix.moduleAndNode }} + - run: .ci/scripts/test.sh -b "release" -t ${{ matrix.module_and_node }} env: ELASTIC_APM_CONTEXT_MANAGER: '' diff --git a/.github/workflows/tav.yml b/.github/workflows/tav.yml index 4c40916c6c..f4a9c07d6b 100644 --- a/.github/workflows/tav.yml +++ b/.github/workflows/tav.yml @@ -24,8 +24,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 5 outputs: - versions: ${{ steps.transform.outputs.versions }} - modules: ${{ steps.transform.outputs.modules }} + permutations: ${{ steps.transform.outputs.permutations }} steps: - uses: actions/checkout@v3 @@ -43,8 +42,19 @@ jobs: core.setFailed(`Error loading './.ci/tav.json': ${err}`) return } - core.setOutput('modules', matrix.modules) - core.setOutput('versions', matrix.versions) + const permutations = [] + for (const mod of matrix.modules) { + for (const nv of matrix.versions) { + if (mod.minVersion && nv >= mod.minVersion) { + permutations.push(`${mod.name} ${nv}`) + } + } + } + if (permutations.length > 256) { + core.setFailed(`Matrix size (${permutations.length}) is bigger than the limit (256)`) + return + } + core.setOutput('permutations', permutations) test-tav: needs: prepare-matrix @@ -57,10 +67,9 @@ jobs: # A job matrix limit is 256. We do some grouping of TAV modules to # stay under that limit. # https://docs.github.com/en/actions/learn-github-actions/usage-limits-billing-and-administration - node: ${{ fromJSON(needs.prepare-matrix.outputs.versions) }} - module: ${{ fromJSON(needs.prepare-matrix.outputs.modules) }} + module_and_node: ${{ fromJSON(needs.prepare-matrix.outputs.permutations) }} steps: - uses: actions/checkout@v3 - - run: .ci/scripts/test.sh -b "release" -t "${{ matrix.module }}" "${{ matrix.node }}" + - run: .ci/scripts/test.sh -b "release" -t ${{ matrix.module_and_node }} env: ELASTIC_APM_CONTEXT_MANAGER: '' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 646bc0dc93..cb5ca7176d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -134,6 +134,13 @@ jobs: - '16.0' - '14' - '14.0' + - '12' + - '12.0' + - '10' + - '10.0' + - '8' + - '8.6' + contextManager: [ 'patch', '' ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -145,6 +152,8 @@ jobs: - run: npm ls --all || true - name: npm test run: npm test + env: + ELASTIC_APM_CONTEXT_MANAGER: ${{ matrix.contextManager }} - uses: inception-health/otel-upload-test-artifact-action@v1 if: always() continue-on-error: true diff --git a/CHANGELOG4.asciidoc b/CHANGELOG4.asciidoc deleted file mode 100644 index e834b2b6eb..0000000000 --- a/CHANGELOG4.asciidoc +++ /dev/null @@ -1,27 +0,0 @@ -[[release-notes-4.x]] -=== Node.js Agent version 1.x - -==== Unreleased - -[float] -===== Breaking changes - -* Set the new minimum supported Node.js to version 14. - Users of earlier Node.js versions can use elastic-apm-node v3.x, which - supports back to Node.js v8.6. - -[float] -===== Features - -[float] -===== Bug fixes - -[float] -===== Chores - - -[[release-notes-3.x]] -=== Node.js Agent version 3.x - -XXX This CHANGELOG4 file will be merged into CHANGELOG.asciidoc before merging to main. - From 7ea1bedfae6f9e659ef2573e581407a442e97c49 Mon Sep 17 00:00:00 2001 From: David Luna Date: Wed, 2 Aug 2023 11:21:03 +0200 Subject: [PATCH 09/18] chore: fix package files --- package-lock.json | 6 +++--- package.json | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index c0d124aafd..b27ab90008 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "elastic-apm-node", - "version": "4.0.0-dev", + "version": "3.48.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "elastic-apm-node", - "version": "4.0.0-dev", + "version": "3.48.0", "license": "BSD-2-Clause", "dependencies": { "@elastic/ecs-pino-format": "^1.2.0", @@ -133,7 +133,7 @@ "ws": "^7.2.1" }, "engines": { - "node": ">=14" + "node": ">=8.6.0" } }, "node_modules/@ampproject/remapping": { diff --git a/package.json b/package.json index 67386e212f..de3dd0ac57 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,6 @@ { "name": "elastic-apm-node", - "version": "4.0.0-dev", - "private": true, + "version": "3.48.0", "description": "The official Elastic APM agent for Node.js", "main": "index.js", "types": "index.d.ts", @@ -51,7 +50,7 @@ "url": "git://github.com/elastic/apm-agent-nodejs.git" }, "engines": { - "node": ">=14" + "node": ">=8.6.0" }, "keywords": [ "opbeat", From 38b5e501b100bc23407ebad79486b12215f26baa Mon Sep 17 00:00:00 2001 From: David Luna Date: Wed, 2 Aug 2023 11:44:33 +0200 Subject: [PATCH 10/18] chore: update lint:tav --- dev-utils/lint-tav-json.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/dev-utils/lint-tav-json.js b/dev-utils/lint-tav-json.js index ec9685a11a..f990cccb27 100755 --- a/dev-utils/lint-tav-json.js +++ b/dev-utils/lint-tav-json.js @@ -35,7 +35,7 @@ function main(argv) { const tavYmlPaths = glob.sync('**/.tav.yml', { ignore: ['**/node_modules/**'], }); - // console.log('tavYmlPaths:', tavYmlPaths) + // console.log('tavYmlPaths:', tavYmlPaths); tavYmlPaths.forEach((p) => { const tavCfg = yaml.load(fs.readFileSync(p, 'utf8')); Object.keys(tavCfg).forEach((k) => { @@ -43,25 +43,35 @@ function main(argv) { moduleNamesFromYaml.add(v.name || k); }); }); - // console.log('moduleNamesFromYaml: ', moduleNamesFromYaml) + // console.log('moduleNamesFromYaml: ', moduleNamesFromYaml); // Find module names in ".ci/tav.json". const moduleNamesFromJson = new Set(); const tavJson = JSON.parse(fs.readFileSync(path.join(TOP, TAV_JSON_PATH))); tavJson.modules.forEach((m) => { - m.split(',').forEach((moduleName) => { + m.name.split(',').forEach((moduleName) => { moduleNamesFromJson.add(moduleName); }); }); - // console.log('moduleNamesFromJson: ', moduleNamesFromJson) + const matrix = []; + for (const mod of tavJson.modules) { + mod.name.split(',').forEach((moduleName) => { + moduleNamesFromJson.add(moduleName); + }); + for (const nv of tavJson.versions) { + if (mod.minVersion && nv >= mod.minVersion) { + matrix.push(`${mod.name} ${nv}`); + } + } + } + // console.log('moduleNamesFromJson: ', moduleNamesFromJson); // Matrix 256 limit. - const matrixSize = tavJson.versions.length * tavJson.modules.length; - if (matrixSize > 256) { + if (matrix.length > 256) { console.error( 'lint-tav-json: #versions * #modules from "%s" is >256, which exceeds the GH Actions workflow matrix limit: %d', TAV_JSON_PATH, - matrixSize, + matrix.length, ); numErrors += 1; } From c625bf8c4686f31295ba297c61c9f003edd7ce18 Mon Sep 17 00:00:00 2001 From: David Luna Date: Wed, 2 Aug 2023 12:20:29 +0200 Subject: [PATCH 11/18] chore: add inputVersions to matrix --- .github/workflows/tav-command.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tav-command.yml b/.github/workflows/tav-command.yml index 15f6d9cda5..d68a3c3b15 100644 --- a/.github/workflows/tav-command.yml +++ b/.github/workflows/tav-command.yml @@ -94,6 +94,7 @@ jobs: core.setFailed(`Incorrect versions list ${match[3]}, please review it'`) return } + resolvedVersions.push(...inputVersions) } else { resolvedVersions.push(...versions) } From 7fa1605e24acab7a81acd562e8e5878b00130233 Mon Sep 17 00:00:00 2001 From: David Luna Date: Wed, 2 Aug 2023 13:56:29 +0200 Subject: [PATCH 12/18] chore: update min versions in matrix --- .ci/tav.json | 66 ++++++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/.ci/tav.json b/.ci/tav.json index 0ca4df744d..31008ac646 100644 --- a/.ci/tav.json +++ b/.ci/tav.json @@ -1,38 +1,38 @@ { "versions": [ 20, 19, 18, 16, 14, 12, 10, 8 ], "modules": [ - {"name": "@apollo/server", "minVersion": 19 }, - {"name": "@aws-sdk/client-s3", "minVersion": 19 }, - {"name": "@elastic/elasticsearch", "minVersion": 19 }, - {"name": "@hapi/hapi", "minVersion": 19 }, - {"name": "@opentelemetry/api", "minVersion": 19 }, - {"name": "@opentelemetry/sdk-metrics", "minVersion": 19 }, - {"name": "apollo-server-express", "minVersion": 19 }, - {"name": "aws-sdk", "minVersion": 19 }, - {"name": "cassandra-driver", "minVersion": 19 }, - {"name": "elasticsearch", "minVersion": 19 }, - {"name": "express", "minVersion": 19 }, - {"name": "express-queue", "minVersion": 19 }, - {"name": "fastify", "minVersion": 19 }, - {"name": "finalhandler", "minVersion": 19 }, - {"name": "generic-pool", "minVersion": 19 }, - {"name": "graphql", "minVersion": 19 }, - {"name": "ioredis", "minVersion": 19 }, - {"name": "knex", "minVersion": 19 }, - {"name": "memcached", "minVersion": 19 }, - {"name": "mongodb", "minVersion": 19 }, - {"name": "mongodb-core", "minVersion": 19 }, - {"name": "mysql", "minVersion": 19 }, - {"name": "mysql2", "minVersion": 19 }, - {"name": "next", "minVersion": 19 }, - {"name": "pg", "minVersion": 19 }, - {"name": "redis", "minVersion": 19 }, - {"name": "restify", "minVersion": 19 }, - {"name": "tedious", "minVersion": 19 }, - {"name": "undici", "minVersion": 19 }, - {"name": "ws", "minVersion": 19 }, - {"name": "@koa/router,koa-router", "minVersion": 19 }, - {"name": "handlebars,pug", "minVersion": 19 }, - {"name": "bluebird,got", "minVersion": 19 } + {"name": "@apollo/server", "minVersion": 14 }, + {"name": "@aws-sdk/client-s3", "minVersion": 14 }, + {"name": "@elastic/elasticsearch", "minVersion": 10 }, + {"name": "@hapi/hapi", "minVersion": 8 }, + {"name": "@opentelemetry/api", "minVersion": 14 }, + {"name": "@opentelemetry/sdk-metrics", "minVersion": 14 }, + {"name": "apollo-server-express", "minVersion": 8 }, + {"name": "aws-sdk", "minVersion": 8 }, + {"name": "cassandra-driver", "minVersion": 8 }, + {"name": "elasticsearch", "minVersion": 8 }, + {"name": "express", "minVersion": 8 }, + {"name": "express-queue", "minVersion": 8 }, + {"name": "fastify", "minVersion": 8 }, + {"name": "finalhandler", "minVersion": 8 }, + {"name": "generic-pool", "minVersion": 8 }, + {"name": "graphql", "minVersion": 8 }, + {"name": "ioredis", "minVersion": 8 }, + {"name": "knex", "minVersion": 8 }, + {"name": "memcached", "minVersion": 8 }, + {"name": "mongodb", "minVersion": 8 }, + {"name": "mongodb-core", "minVersion": 8 }, + {"name": "mysql", "minVersion": 8 }, + {"name": "mysql2", "minVersion": 8 }, + {"name": "next", "minVersion": 14 }, + {"name": "pg", "minVersion": 8 }, + {"name": "redis", "minVersion": 8 }, + {"name": "restify", "minVersion": 14 }, + {"name": "tedious", "minVersion": 8 }, + {"name": "undici", "minVersion": 8 }, + {"name": "ws", "minVersion": 8 }, + {"name": "@koa/router,koa-router", "minVersion": 8 }, + {"name": "handlebars,pug", "minVersion": 8 }, + {"name": "bluebird,got", "minVersion": 8 } ] } From 16f80a480868443fcb7b0f538993b9d9cfa524f4 Mon Sep 17 00:00:00 2001 From: David Luna Date: Wed, 2 Aug 2023 15:43:53 +0200 Subject: [PATCH 13/18] chore: fix matrix calculation --- .github/workflows/tav-command.yml | 91 ++++++++++++++++++------------- 1 file changed, 53 insertions(+), 38 deletions(-) diff --git a/.github/workflows/tav-command.yml b/.github/workflows/tav-command.yml index d68a3c3b15..38ff8dd825 100644 --- a/.github/workflows/tav-command.yml +++ b/.github/workflows/tav-command.yml @@ -54,60 +54,75 @@ jobs: let modules, versions try { - const matrix = JSON.parse(fs.readFileSync('./.ci/tav.json')) + const matrix = JSON.parse(fs.readFileSync('./.ci/tav.json')); versions = matrix.versions modules = matrix.modules } catch (err) { core.setFailed(`Error loading './.ci/tav.json': ${err}`) return } - const comment = context.payload.review.body - const resolvedModules = [] - const resolvedVersions = [] - let inputNames, inputVersions - if (comment !== '/test tav') { - const regex = /\/test tav ([^\s]+)(\s*)([^\s]*)/ - const match = comment.match(regex) - if (!match) { - core.setFailed(`Incorrect comment, please use /test tav(\\s(module1,...,moduleN)?(\\s)?(node1,...,nodeN)?)?'`) - return - } - if (match[1]) { - if (match[1] !== 'all') { - inputNames = match[1].split(',') - for (const name of inputNames) { - const mod = modules.find((m) => m.name === name) - if (mod) { - resolvedModules.push(mod) - } else { - core.setFailed(`Incorrect module name ${name}, please review it'`) - return - } + + const getPermutations = (mods, vers) => { + const permutations = [] + for (const mod of mods) { + for (const nv of vers) { + if (mod.minVersion && nv >= mod.minVersion) { + permutations.push(`${mod.name} ${nv}`) } - } else { - resolvedModules.push(...modules) } } - if (match[3]) { - inputVersions = match[3].split(',').map(Number) - if (inputVersions.some((v) => isNaN(v))) { - core.setFailed(`Incorrect versions list ${match[3]}, please review it'`) - return - } - resolvedVersions.push(...inputVersions) + return permutations + } + + const comment = context.payload.review.body + if (comment === '/test tav') { + const permutations = getPermutations(modules, versions) + if (permutations.length > 256) { + core.setFailed(`Matrix size (${permutations.length}) is bigger than the limit (256)`) } else { - resolvedVersions.push(...versions) + core.setOutput('permutations', permutations) } + return } - const permutations = [] - for (const mod of resolvedModules) { - for (const nv of resolvedVersions) { - if (mod.minVersion && nv >= mod.minVersion) { - permutations.push(`${mod.name} ${nv}`) + const regex = /\/test tav ([^\s]+)(\s*)([^\s]*)/ + const match = comment.match(regex) + if (!match) { + core.setFailed(`Incorrect comment, please use /test tav(\\s(module1,...,moduleN)?(\\s)?(node1,...,nodeN)?)?'`) + return + } + + const resolvedModules = [] + const resolvedVersions = [] + let inputNames, inputVersions + if (match[1]) { + if (match[1] === 'all') { + resolvedModules.push(...modules) + } else { + inputNames = match[1].split(',') + for (const name of inputNames) { + const mod = modules.find((m) => m.name === name) + if (mod) { + resolvedModules.push(mod) + } else { + core.setFailed(`Incorrect module name ${name}, please review it'`) + return + } } } } + if (match[3]) { + inputVersions = match[3].split(',').map(Number) + if (inputVersions.some((v) => isNaN(v))) { + core.setFailed(`Incorrect versions list ${match[3]}, please review it'`) + return + } + resolvedVersions.push(...inputVersions) + } else { + resolvedVersions.push(...versions) + } + + const permutations = getPermutations(resolvedModules, resolvedVersions) if (permutations.length > 256) { core.setFailed(`Matrix size (${permutations.length}) is bigger than the limit (256)`) return From b100d90ce93cd46029c9c5a3546da30db67db3de Mon Sep 17 00:00:00 2001 From: David Luna Date: Wed, 2 Aug 2023 16:17:48 +0200 Subject: [PATCH 14/18] docs: update changelog --- CHANGELOG.asciidoc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index a75dc0058d..6d2340feff 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -59,6 +59,9 @@ Notes: [float] ===== Chores +* Add min node verison in `tav.json` to generate lighter matrix for TAV commands. + ({pull}3531[#3531]) + * Inline the `elastic-apm-http-client` package code into this repo. ({issues}3506[#3506]) From 922a9924c7d06ea6943d1a303eaa7e0e863cb5a8 Mon Sep 17 00:00:00 2001 From: David Luna Date: Thu, 3 Aug 2023 10:12:28 +0200 Subject: [PATCH 15/18] Update .github/workflows/tav-command.yml Co-authored-by: Trent Mick --- .github/workflows/tav-command.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tav-command.yml b/.github/workflows/tav-command.yml index 38ff8dd825..28b0b168b0 100644 --- a/.github/workflows/tav-command.yml +++ b/.github/workflows/tav-command.yml @@ -105,7 +105,7 @@ jobs: if (mod) { resolvedModules.push(mod) } else { - core.setFailed(`Incorrect module name ${name}, please review it'`) + core.setFailed(`Incorrect module name ${name}, please review it`) return } } From 8d74f8f301fe2ccd1af9c6adfcb86cb6cd240a56 Mon Sep 17 00:00:00 2001 From: David Luna Date: Thu, 3 Aug 2023 10:12:41 +0200 Subject: [PATCH 16/18] Update .github/workflows/tav-command.yml Co-authored-by: Trent Mick --- .github/workflows/tav-command.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tav-command.yml b/.github/workflows/tav-command.yml index 28b0b168b0..9d43bcf4e4 100644 --- a/.github/workflows/tav-command.yml +++ b/.github/workflows/tav-command.yml @@ -114,7 +114,7 @@ jobs: if (match[3]) { inputVersions = match[3].split(',').map(Number) if (inputVersions.some((v) => isNaN(v))) { - core.setFailed(`Incorrect versions list ${match[3]}, please review it'`) + core.setFailed(`Incorrect versions list ${match[3]}, please review it`) return } resolvedVersions.push(...inputVersions) From 2eafba664b6d90fd093450ee4e3030d1bd2881b8 Mon Sep 17 00:00:00 2001 From: David Luna Date: Thu, 3 Aug 2023 10:21:07 +0200 Subject: [PATCH 17/18] chore: add comment in tav.json --- .ci/tav.json | 67 ++++++++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/.ci/tav.json b/.ci/tav.json index 31008ac646..5117bfbeb3 100644 --- a/.ci/tav.json +++ b/.ci/tav.json @@ -1,38 +1,39 @@ { "versions": [ 20, 19, 18, 16, 14, 12, 10, 8 ], + "// modules": "list of instrumented modules with the min Node version supported", "modules": [ - {"name": "@apollo/server", "minVersion": 14 }, - {"name": "@aws-sdk/client-s3", "minVersion": 14 }, - {"name": "@elastic/elasticsearch", "minVersion": 10 }, - {"name": "@hapi/hapi", "minVersion": 8 }, - {"name": "@opentelemetry/api", "minVersion": 14 }, - {"name": "@opentelemetry/sdk-metrics", "minVersion": 14 }, - {"name": "apollo-server-express", "minVersion": 8 }, - {"name": "aws-sdk", "minVersion": 8 }, - {"name": "cassandra-driver", "minVersion": 8 }, - {"name": "elasticsearch", "minVersion": 8 }, - {"name": "express", "minVersion": 8 }, - {"name": "express-queue", "minVersion": 8 }, - {"name": "fastify", "minVersion": 8 }, - {"name": "finalhandler", "minVersion": 8 }, - {"name": "generic-pool", "minVersion": 8 }, - {"name": "graphql", "minVersion": 8 }, - {"name": "ioredis", "minVersion": 8 }, - {"name": "knex", "minVersion": 8 }, - {"name": "memcached", "minVersion": 8 }, - {"name": "mongodb", "minVersion": 8 }, - {"name": "mongodb-core", "minVersion": 8 }, - {"name": "mysql", "minVersion": 8 }, - {"name": "mysql2", "minVersion": 8 }, - {"name": "next", "minVersion": 14 }, - {"name": "pg", "minVersion": 8 }, - {"name": "redis", "minVersion": 8 }, - {"name": "restify", "minVersion": 14 }, - {"name": "tedious", "minVersion": 8 }, - {"name": "undici", "minVersion": 8 }, - {"name": "ws", "minVersion": 8 }, - {"name": "@koa/router,koa-router", "minVersion": 8 }, - {"name": "handlebars,pug", "minVersion": 8 }, - {"name": "bluebird,got", "minVersion": 8 } + { "name": "@apollo/server", "minVersion": 14 }, + { "name": "@aws-sdk/client-s3", "minVersion": 14 }, + { "name": "@elastic/elasticsearch", "minVersion": 10 }, + { "name": "@hapi/hapi", "minVersion": 8 }, + { "name": "@opentelemetry/api", "minVersion": 14 }, + { "name": "@opentelemetry/sdk-metrics", "minVersion": 14 }, + { "name": "apollo-server-express", "minVersion": 8 }, + { "name": "aws-sdk", "minVersion": 8 }, + { "name": "cassandra-driver", "minVersion": 8 }, + { "name": "elasticsearch", "minVersion": 8 }, + { "name": "express", "minVersion": 8 }, + { "name": "express-queue", "minVersion": 8 }, + { "name": "fastify", "minVersion": 8 }, + { "name": "finalhandler", "minVersion": 8 }, + { "name": "generic-pool", "minVersion": 8 }, + { "name": "graphql", "minVersion": 8 }, + { "name": "ioredis", "minVersion": 8 }, + { "name": "knex", "minVersion": 8 }, + { "name": "memcached", "minVersion": 8 }, + { "name": "mongodb", "minVersion": 8 }, + { "name": "mongodb-core", "minVersion": 8 }, + { "name": "mysql", "minVersion": 8 }, + { "name": "mysql2", "minVersion": 8 }, + { "name": "next", "minVersion": 14 }, + { "name": "pg", "minVersion": 8 }, + { "name": "redis", "minVersion": 8 }, + { "name": "restify", "minVersion": 14 }, + { "name": "tedious", "minVersion": 8 }, + { "name": "undici", "minVersion": 8 }, + { "name": "ws", "minVersion": 8 }, + { "name": "@koa/router,koa-router", "minVersion": 8 }, + { "name": "handlebars,pug", "minVersion": 8 }, + { "name": "bluebird,got", "minVersion": 8 } ] } From f1079818d51e6ecda580dfa4cc06499b0f9abac2 Mon Sep 17 00:00:00 2001 From: David Luna Date: Thu, 3 Aug 2023 10:24:45 +0200 Subject: [PATCH 18/18] chore: add comment in tav.json --- .ci/tav.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.ci/tav.json b/.ci/tav.json index 5117bfbeb3..8f2eff9e17 100644 --- a/.ci/tav.json +++ b/.ci/tav.json @@ -1,6 +1,9 @@ { "versions": [ 20, 19, 18, 16, 14, 12, 10, 8 ], - "// modules": "list of instrumented modules with the min Node version supported", + "// modules": [ + "List of instrumented modules with the min Node version supported.", + "minVersion for each module should be kept in sync with .tav.yml" + ], "modules": [ { "name": "@apollo/server", "minVersion": 14 }, { "name": "@aws-sdk/client-s3", "minVersion": 14 },