Skip to content

Commit a68b0b8

Browse files
david-lunatrentm
andauthored
feat: add support for express v5 (#4581)
Co-authored-by: Trent Mick <[email protected]>
1 parent 221e042 commit a68b0b8

30 files changed

+1688
-489
lines changed

.tav.yml

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -186,44 +186,51 @@ graphql:
186186
commands: node test/instrumentation/modules/graphql.test.js
187187

188188
express:
189-
versions:
190-
mode: latest-minors
191-
include: '>=4 <5'
192-
commands:
193-
- node test/instrumentation/modules/express/basic.test.js
194-
- node test/instrumentation/modules/express/capture-exceptions-off.test.js
195-
- node test/instrumentation/modules/express/capture-exceptions-on.test.js
196-
- node test/instrumentation/modules/express/set-framework.test.js
189+
- versions:
190+
mode: latest-minors
191+
include: '>=5 <6'
192+
node: '>=18'
193+
commands:
194+
- node test/instrumentation/modules/express/basic.test.js
195+
- node test/instrumentation/modules/express/capture-exceptions-off.test.js
196+
- node test/instrumentation/modules/express/capture-exceptions-on.test.js
197+
- node test/instrumentation/modules/express/set-framework.test.js
198+
- versions:
199+
mode: latest-minors
200+
include: '>=4 <5'
201+
commands:
202+
- node test/instrumentation/modules/express/basic.test.js
203+
- node test/instrumentation/modules/express/capture-exceptions-off.test.js
204+
- node test/instrumentation/modules/express/capture-exceptions-on.test.js
205+
- node test/instrumentation/modules/express/set-framework.test.js
197206

198207
apollo-server-express:
199-
# We want this version range:
200-
# versions: '>=2.9.16 <2.2 || >= 2.3.2 <3'
201-
# but only the latest MAJOR.MINOR.x to reduce the test matrix.
202-
#
203-
# Maintenance note: This should be updated for newer MAJOR.MINOR releases.
204-
- versions: '2.9.16 || 2.10.1 || 2.11.0 || 2.12.0 || 2.13.1 || 2.14.5 || 2.15.1 || 2.16.1 || 2.17.0 || 2.18.2 || 2.19.2 || 2.20.0 || 2.21.2 || 2.22.2 || 2.23.0 || 2.24.1 || 2.25.0 || >2.25.x <3'
205-
peerDependencies: graphql@^14.0.0
208+
- versions:
209+
include: '>=2.9.16 <3'
210+
mode: latest-minors
211+
peerDependencies:
212+
- graphql@^14.0.0
213+
- express@^4.17.1
206214
node: '>=6'
207215
commands: node test/instrumentation/modules/apollo-server-express.test.js
208216
# We want this version range (2.12.0 was the first release of
209-
# apollo-server-express after graphql@15 was released):
210-
# versions: '>=2.12.0 <3'
211-
# but only the latest MAJOR.MINOR.x to reduce the test matrix.
212-
#
213-
# Maintenance note: This should be updated for newer MAJOR.MINOR releases.
214-
- versions: '2.15.1 || 2.16.1 || 2.17.0 || 2.18.2 || 2.19.2 || 2.20.0 || 2.21.2 || 2.22.2 || 2.23.0 || 2.24.1 || 2.25.0 || >2.25.x <3'
215-
peerDependencies: graphql@^15.0.0
217+
# apollo-server-express after graphql@15 was released)
218+
- versions:
219+
include: '>=2.12.0 <3'
220+
mode: latest-minors
221+
peerDependencies:
222+
- graphql@^15.0.0
223+
- express@^4.17.1
216224
# Per https://github.com/graphql/graphql-js/releases/tag/v15.0.0
217225
# graphql v15 supports node v8 as a minimum.
218226
node: '>=8'
219227
commands: node test/instrumentation/modules/apollo-server-express.test.js
220-
# We want this version range:
221-
# versions: '^3.0.0'
222-
# but only test the latest MAJOR.MINOR.x to reduce the test matrix.
223-
#
224-
# Maintenance note: This should be updated for newer MAJOR.MINOR releases.
225-
- versions: '3.0.2 || 3.1.2 || 3.2.0 || 3.3.0 || 3.4.1 || 3.5.0 || 3.6.8 || 3.7.0 || 3.8.2 || 3.9.0 || ^3.10.2'
226-
peerDependencies: graphql@^15.0.0
228+
- versions:
229+
include: '>=3.0.0 <4'
230+
mode: latest-minors
231+
peerDependencies:
232+
- graphql@^15.0.0
233+
- express@^4.17.1
227234
commands: node test/instrumentation/modules/apollo-server-express.test.js
228235

229236
express-queue:
@@ -464,6 +471,7 @@ finalhandler:
464471
- versions:
465472
mode: max-3
466473
include: '>=1 <2'
474+
peerDependencies: 'express@^4.17.1'
467475
node: '>=0.8'
468476
commands: node test/instrumentation/modules/finalhandler.test.js
469477
- versions:

docs/reference/esm.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Automatic instrumentation of ES modules is currently limited as described here.
7979
| `@aws-sdk/client-sns` | >=3.15.0 <4 | | |
8080
| `@aws-sdk/client-sqs` | >=3.15.0 <4 | | |
8181
| `cassandra-driver` | >=3.0.0 <5 | | |
82-
| `express` | ^4.0.0 | | |
82+
| `express` | >=4.0.0 <6 | | |
8383
| `fastify` | >=3.5.0 | | |
8484
| `http` | | See [Supported Node.js versions](#esm-compat-node) above. | |
8585
| `https` | | See [Supported Node.js versions](#esm-compat-node) above. | |

docs/reference/supported-technologies.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Though you can use Elastic APM [with any Node.js framework](/reference/custom-st
4242
| --- | --- | --- |
4343
| [AWS Lambda](/reference/lambda.md) | N/A | |
4444
| [Azure Functions](/reference/azure-functions.md) | v3, v4 | [Node.js programming model v3 and v4](https://learn.microsoft.com/en-us/azure/azure-functions/functions-node-upgrade-v4) |
45-
| [Express](/reference/express.md) | ^4.0.0 | |
45+
| [Express](/reference/express.md) | >=4.0.0 <6.0.0 | |
4646
| [Fastify](/reference/fastify.md) | >=1.0.0 | See also [Fastify’s own LTS documentation](https://www.fastify.io/docs/latest/Reference/LTS/) |
4747
| [@hapi/hapi](/reference/hapi.md) | >=17.9.0 <22.0.0 | |
4848
| [Koa](/reference/koa.md) via koa-router or @koa/router | >=5.2.0 <14.0.0 | Koa doesn’t have a built in router, so we can’t support Koa directly since we rely on router information for full support. We currently support the most popular Koa router called [koa-router](https://github.com/koajs/koa-router). |

docs/release-notes/index.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ To check for security updates, go to [Security announcements for the Elastic sta
2020

2121
% ### Fixes [next-fixes]
2222

23+
## Next [next]
24+
**Release date:** Month day, year
25+
26+
### Features and enhancements [next-features-enhancements]
27+
28+
* Add support for `express` v5. ([#4581](https://github.com/elastic/apm-agent-nodejs/pull/4581))
29+
30+
### Fixes [next-fixes]
31+
2332
## 4.12.0 [4-12-0]
2433
**Release date:** April 24, 2025
2534

lib/instrumentation/modules/express.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,19 @@ module.exports = function (express, agent, { version, enabled }) {
1717

1818
agent.setFramework({ name: 'express', version, overwrite: false });
1919

20-
if (!semver.satisfies(version, '^4.0.0')) {
20+
if (!semver.satisfies(version, '>=4.0.0 <6')) {
21+
agent.logger.debug('cannot instrument express version %s', version);
22+
return express;
23+
}
24+
25+
if (
26+
semver.satisfies(version, '>5') &&
27+
semver.satisfies(process.version, '<18')
28+
) {
2129
agent.logger.debug(
22-
'express version %s not supported - aborting...',
30+
'express version %s not supported for node version %s, skipping express instrumentation',
2331
version,
32+
process.version,
2433
);
2534
return express;
2635
}

0 commit comments

Comments
 (0)