Skip to content

feat: add support for express v5 #4581

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 29 commits into from
May 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
d998e1d
feat: add support for express v5
david-luna Apr 24, 2025
8350649
chore: add node version check for express compatibility
david-luna Apr 24, 2025
311b7d8
tests: add version compat checks and update tav
david-luna Apr 24, 2025
c6e250a
fix: fix lint errors
david-luna Apr 24, 2025
31ca241
test: fix router access in tests
david-luna Apr 24, 2025
c16773e
tests: remove usage of express in cloud-metadata tests
david-luna Apr 25, 2025
02ec10f
Update lib/instrumentation/modules/express.js
david-luna Apr 25, 2025
2458ca1
Update lib/instrumentation/modules/express.js
david-luna Apr 25, 2025
96a3a21
chore: fix lint issues
david-luna Apr 25, 2025
49b7289
Merge branch 'main' into 4238-express-v5
david-luna Apr 25, 2025
0a5533e
docs: update express version range supported
david-luna Apr 25, 2025
bf1e727
test: add incompat check to missing tests
david-luna Apr 25, 2025
3568e32
test: use a different package to test patches
david-luna Apr 25, 2025
a8f1154
chore: add note in agent tests
david-luna Apr 25, 2025
32e651b
chore: fix typo
david-luna Apr 25, 2025
659ae3e
Update test/cloud-metadata/_lib.js
david-luna Apr 25, 2025
12c2db3
Update docs/reference/esm.md
david-luna Apr 25, 2025
549cfa9
Update docs/reference/supported-technologies.md
david-luna Apr 25, 2025
9450321
chore: replace express server in aws and http instrumentation tests
david-luna Apr 28, 2025
49edcbc
chore: fix lint issue
david-luna Apr 29, 2025
b902a47
Merge branch '4238-express-v5' of github.com:elastic/apm-agent-nodejs…
david-luna Apr 29, 2025
2c7f06c
chore: remove express from config test
david-luna Apr 29, 2025
b7bcf6d
chore: skip tests with express for lambda runtimes
david-luna Apr 29, 2025
1e3a675
chore: update tav.yml
david-luna Apr 29, 2025
712dd97
Merge branch 'main' into 4238-express-v5
david-luna Apr 30, 2025
ec53dfb
fix: fix pg test
david-luna Apr 30, 2025
5d4ece9
Update .tav.yml
david-luna Apr 30, 2025
8e91267
docs: fix docs
david-luna May 2, 2025
89265cb
Merge branch '4238-express-v5' of github.com:elastic/apm-agent-nodejs…
david-luna May 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 37 additions & 29 deletions .tav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,44 +186,51 @@ graphql:
commands: node test/instrumentation/modules/graphql.test.js

express:
versions:
mode: latest-minors
include: '>=4 <5'
commands:
- node test/instrumentation/modules/express/basic.test.js
- node test/instrumentation/modules/express/capture-exceptions-off.test.js
- node test/instrumentation/modules/express/capture-exceptions-on.test.js
- node test/instrumentation/modules/express/set-framework.test.js
- versions:
mode: latest-minors
include: '>=5 <6'
node: '>=18'
commands:
- node test/instrumentation/modules/express/basic.test.js
- node test/instrumentation/modules/express/capture-exceptions-off.test.js
- node test/instrumentation/modules/express/capture-exceptions-on.test.js
- node test/instrumentation/modules/express/set-framework.test.js
- versions:
mode: latest-minors
include: '>=4 <5'
commands:
- node test/instrumentation/modules/express/basic.test.js
- node test/instrumentation/modules/express/capture-exceptions-off.test.js
- node test/instrumentation/modules/express/capture-exceptions-on.test.js
- node test/instrumentation/modules/express/set-framework.test.js

apollo-server-express:
# We want this version range:
# versions: '>=2.9.16 <2.2 || >= 2.3.2 <3'
# but only the latest MAJOR.MINOR.x to reduce the test matrix.
#
# Maintenance note: This should be updated for newer MAJOR.MINOR releases.
- 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'
peerDependencies: graphql@^14.0.0
- versions:
include: '>=2.9.16 <3'
mode: latest-minors
peerDependencies:
- graphql@^14.0.0
- express@^4.17.1
node: '>=6'
commands: node test/instrumentation/modules/apollo-server-express.test.js
# We want this version range (2.12.0 was the first release of
# apollo-server-express after graphql@15 was released):
# versions: '>=2.12.0 <3'
# but only the latest MAJOR.MINOR.x to reduce the test matrix.
#
# Maintenance note: This should be updated for newer MAJOR.MINOR releases.
- 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'
peerDependencies: graphql@^15.0.0
# apollo-server-express after graphql@15 was released)
- versions:
include: '>=2.12.0 <3'
mode: latest-minors
peerDependencies:
- graphql@^15.0.0
- express@^4.17.1
# Per https://github.com/graphql/graphql-js/releases/tag/v15.0.0
# graphql v15 supports node v8 as a minimum.
node: '>=8'
commands: node test/instrumentation/modules/apollo-server-express.test.js
# We want this version range:
# versions: '^3.0.0'
# but only test the latest MAJOR.MINOR.x to reduce the test matrix.
#
# Maintenance note: This should be updated for newer MAJOR.MINOR releases.
- 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'
peerDependencies: graphql@^15.0.0
- versions:
include: '>=3.0.0 <4'
mode: latest-minors
peerDependencies:
- graphql@^15.0.0
- express@^4.17.1
commands: node test/instrumentation/modules/apollo-server-express.test.js

express-queue:
Expand Down Expand Up @@ -464,6 +471,7 @@ finalhandler:
- versions:
mode: max-3
include: '>=1 <2'
peerDependencies: 'express@^4.17.1'
node: '>=0.8'
commands: node test/instrumentation/modules/finalhandler.test.js
- versions:
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/esm.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Automatic instrumentation of ES modules is currently limited as described here.
| `@aws-sdk/client-sns` | >=3.15.0 <4 | | |
| `@aws-sdk/client-sqs` | >=3.15.0 <4 | | |
| `cassandra-driver` | >=3.0.0 <5 | | |
| `express` | ^4.0.0 | | |
| `express` | >=4.0.0 <6 | | |
| `fastify` | >=3.5.0 | | |
| `http` | | See [Supported Node.js versions](#esm-compat-node) above. | |
| `https` | | See [Supported Node.js versions](#esm-compat-node) above. | |
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/supported-technologies.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Though you can use Elastic APM [with any Node.js framework](/reference/custom-st
| --- | --- | --- |
| [AWS Lambda](/reference/lambda.md) | N/A | |
| [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) |
| [Express](/reference/express.md) | ^4.0.0 | |
| [Express](/reference/express.md) | >=4.0.0 <6.0.0 | |
| [Fastify](/reference/fastify.md) | >=1.0.0 | See also [Fastify’s own LTS documentation](https://www.fastify.io/docs/latest/Reference/LTS/) |
| [@hapi/hapi](/reference/hapi.md) | >=17.9.0 <22.0.0 | |
| [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). |
Expand Down
9 changes: 9 additions & 0 deletions docs/release-notes/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ To check for security updates, go to [Security announcements for the Elastic sta

% ### Fixes [next-fixes]

## Next [next]
**Release date:** Month day, year

### Features and enhancements [next-features-enhancements]

* Add support for `express` v5. ([#4581](https://github.com/elastic/apm-agent-nodejs/pull/4581))

### Fixes [next-fixes]

## 4.12.0 [4-12-0]
**Release date:** April 24, 2025

Expand Down
13 changes: 11 additions & 2 deletions lib/instrumentation/modules/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,19 @@ module.exports = function (express, agent, { version, enabled }) {

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

if (!semver.satisfies(version, '^4.0.0')) {
if (!semver.satisfies(version, '>=4.0.0 <6')) {
agent.logger.debug('cannot instrument express version %s', version);
return express;
}

if (
semver.satisfies(version, '>5') &&
semver.satisfies(process.version, '<18')
) {
agent.logger.debug(
'express version %s not supported - aborting...',
'express version %s not supported for node version %s, skipping express instrumentation',
version,
process.version,
);
return express;
}
Expand Down
Loading
Loading