Skip to content

Commit c44a3bd

Browse files
authored
chore: clarify the latest major version of the instrumentation module for some instrumentations (#4837)
In docs, instrumentation, and tests, the major version of the target module being instrumented was not specified. There should be no functional change for any current releases of modules with this change. In other words, any changes to actual instrumentations is capping the major version supported at the *currently released* major version. Closes: #4803
1 parent 715320e commit c44a3bd

File tree

8 files changed

+69
-17
lines changed

8 files changed

+69
-17
lines changed

.tav.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,9 @@ koa-router:
255255
commands: node test/instrumentation/modules/koa-router/new-name.test.js
256256

257257
elasticsearch:
258-
versions: '>=8.0.0'
258+
versions:
259+
mode: max-5
260+
include: '>=8.0.0 <17'
259261
commands: node test/instrumentation/modules/elasticsearch.test.js
260262

261263
# @elastic/elasticsearch
@@ -308,7 +310,7 @@ handlebars:
308310
pug:
309311
- versions: '0.1.0 || >2.0.0 <3.0.0'
310312
commands: node test/instrumentation/modules/pug.test.js
311-
- versions: '>=3.0.0'
313+
- versions: '>=3.0.0 <4'
312314
node: '>8'
313315
commands: node test/instrumentation/modules/pug.test.js
314316

@@ -483,7 +485,7 @@ finalhandler:
483485
commands: node test/instrumentation/modules/finalhandler.test.js
484486

485487
memcached:
486-
versions: '>=2.2.0'
488+
versions: '>=2.2.0 <3'
487489
commands: node test/instrumentation/modules/memcached.test.js
488490

489491
aws-sdk:

docs/reference/supported-technologies.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Though you can use Elastic APM [with any Node.js framework](/reference/custom-st
4949
| [AWS Lambda](/reference/lambda.md) | N/A | |
5050
| [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) |
5151
| [Express](/reference/express.md) | >=4.0.0 <6.0.0 | |
52-
| [Fastify](/reference/fastify.md) | >=2.0.0 | See also [Fastify’s own LTS documentation](https://www.fastify.io/docs/latest/Reference/LTS/) |
52+
| [Fastify](/reference/fastify.md) | >=2.0.0 <6 | See also [Fastify’s own LTS documentation](https://www.fastify.io/docs/latest/Reference/LTS/) |
5353
| [@hapi/hapi](/reference/hapi.md) | >=17.9.0 <22.0.0 | |
5454
| [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). |
5555
| [Restify](/reference/restify.md) | >=5.2.0 <12.0.0 | |
@@ -88,21 +88,21 @@ The Node.js agent will automatically instrument the following modules to give yo
8888
| [@aws-sdk/client-sqs](https://www.npmjs.com/package/@aws-sdk/client-s3) | >=3.15.0 <4 | Will instrument SQS send/receive/delete messages |
8989
| [@aws-sdk/client-dynamodb](https://www.npmjs.com/package/@aws-sdk/client-dynamodb) | >=3.15.0 <4 | Will instrument all DynamoDB methods |
9090
| [cassandra-driver](https://www.npmjs.com/package/cassandra-driver) | >=3.0.0 <5 | Will instrument all queries |
91-
| [elasticsearch](https://www.npmjs.com/package/elasticsearch) | >=8.0.0 | Will instrument all queries |
92-
| [@elastic/elasticsearch](https://www.npmjs.com/package/@elastic/elasticsearch) | >=7.0.0 <9.0.0 | Will instrument all queries |
91+
| [elasticsearch](https://www.npmjs.com/package/elasticsearch) | >=8.0.0 <17 | Will instrument all queries |
92+
| [@elastic/elasticsearch](https://www.npmjs.com/package/@elastic/elasticsearch) | >=7.0.0 <10.0.0 | Will instrument all queries |
9393
| [graphql](https://www.npmjs.com/package/graphql) | >=0.7.0 <17 | Will instrument all queries |
94-
| [handlebars](https://www.npmjs.com/package/handlebars) | * | Will instrument compile and render calls |
95-
| [jade](https://www.npmjs.com/package/jade) | >=0.5.6 | Will instrument compile and render calls; Deprecated. No longer tested. Use pug. |
96-
| [pug](https://www.npmjs.com/package/pug) | >=0.1.0 | Will instrument compile and render calls |
94+
| [handlebars](https://www.npmjs.com/package/handlebars) | >=1 <5 | Will instrument compile and render calls |
95+
| [jade](https://www.npmjs.com/package/jade) | >=0.5.6 <2 | Will instrument compile and render calls; Deprecated. No longer tested. Use pug. |
96+
| [pug](https://www.npmjs.com/package/pug) | >=0.1.0 <4 | Will instrument compile and render calls |
9797
| [ioredis](https://www.npmjs.com/package/ioredis) | >=2.0.0 <6.0.0 | Will instrument all queries |
98-
| [memcached](https://www.npmjs.com/package/memcached) | >=2.2.0 | Will instrument all commands. |
98+
| [memcached](https://www.npmjs.com/package/memcached) | >=2.2.0 <3 | Will instrument all commands. |
9999
| [mongodb-core](https://www.npmjs.com/package/mongodb-core) | >=1.2.19 <4 | Will instrument all queries.A lot of higher level MongoDB modules use mongodb-core,so those should be supported as well. |
100100
| [mongodb](https://www.npmjs.com/package/mongodb) | >=2.0.0 <3.3.0 | Supported via mongodb-core |
101101
| [mongodb](https://www.npmjs.com/package/mongodb) | >=3.3.0 <7 | Will instrument all queries |
102102
| [mongojs](https://www.npmjs.com/package/mongojs) | >=1.0.0 <2.7.0 | Supported via mongodb-core |
103103
| [mongoose](https://www.npmjs.com/package/mongoose) | >=4.0.0 <5.7.0 | Supported via mongodb-core |
104104
| [mongoose](https://www.npmjs.com/package/mongoose) | >=5.7.0 <8 | Supported via mongodb |
105-
| [mysql](https://www.npmjs.com/package/mysql) | ^2.0.0 | Will instrument all queries |
105+
| [mysql](https://www.npmjs.com/package/mysql) | >=2.0.0 <3 | Will instrument all queries |
106106
| [mysql2](https://www.npmjs.com/package/mysql2) | >=1.0.0 <4.0.0 | Will instrument all queries |
107107
| [pg](https://www.npmjs.com/package/pg) | >=4.0.0 <9.0.0 | Will instrument all queries |
108108
| [redis](https://www.npmjs.com/package/redis) | >=2.0.0 <5.0.0 | Will instrument all queries |

lib/instrumentation/modules/elasticsearch.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
'use strict';
88

99
const { URL, URLSearchParams } = require('url');
10+
const semver = require('semver');
1011

1112
var shimmer = require('../shimmer');
1213
var { getDBDestination } = require('../context');
@@ -63,9 +64,17 @@ function getTargetUrlFromTransportConfig(config) {
6364
return null;
6465
}
6566

66-
module.exports = function (elasticsearch, agent, { enabled }) {
67+
module.exports = function (elasticsearch, agent, { version, enabled }) {
6768
if (!enabled) return elasticsearch;
6869

70+
if (!semver.satisfies(version, '>=8.0.0 <17')) {
71+
agent.logger.debug(
72+
'cannot instrument elasticsearch version %s, skipping elasticsearch instrumentation',
73+
version,
74+
);
75+
return elasticsearch;
76+
}
77+
6978
const ins = agent._instrumentation;
7079
const elasticsearchCaptureBodyUrlsRegExp =
7180
agent._conf.elasticsearchCaptureBodyUrlsRegExp;

lib/instrumentation/modules/fastify.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ module.exports = function (
4444
if (!enabled) {
4545
return modExports;
4646
}
47+
if (!semver.satisfies(version, '>=2.0.0 <6')) {
48+
agent.logger.debug(
49+
'cannot instrument fastify version %s, skipping fastify instrumentation',
50+
version,
51+
);
52+
return modExports;
53+
}
4754
if (isImportMod && !semver.satisfies(version, '>=3.5.0')) {
4855
// https://github.com/fastify/fastify/pull/2590
4956
agent.logger.debug(

lib/instrumentation/modules/handlebars.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,22 @@
66

77
'use strict';
88

9+
var semver = require('semver');
10+
911
var shimmer = require('../shimmer');
1012
var templateShared = require('../template-shared');
1113

12-
module.exports = function (handlebars, agent, { enabled }) {
14+
module.exports = function (handlebars, agent, { version, enabled }) {
1315
if (!enabled) return handlebars;
16+
17+
if (!semver.satisfies(version, '>=1 <5')) {
18+
agent.logger.debug(
19+
'cannot instrument handlebars version %s, skipping handlebars instrumentation',
20+
version,
21+
);
22+
return handlebars;
23+
}
24+
1425
agent.logger.debug('shimming handlebars.compile');
1526
shimmer.wrap(
1627
handlebars,

lib/instrumentation/modules/jade.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,22 @@
66

77
'use strict';
88

9+
var semver = require('semver');
10+
911
var shimmer = require('../shimmer');
1012
var templateShared = require('../template-shared');
1113

12-
module.exports = function (jade, agent, { enabled }) {
14+
module.exports = function (jade, agent, { version, enabled }) {
1315
if (!enabled) return jade;
16+
17+
if (!semver.satisfies(version, '>=0.5.6 <2')) {
18+
agent.logger.debug(
19+
'cannot instrument jade version %s, skipping jade instrumentation',
20+
version,
21+
);
22+
return jade;
23+
}
24+
1425
agent.logger.debug('shimming jade.compile');
1526
shimmer.wrap(jade, 'compile', templateShared.wrapCompile(agent, 'jade'));
1627

lib/instrumentation/modules/memcached.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ module.exports = function (memcached, agent, { version, enabled }) {
1515
if (!enabled) {
1616
return memcached;
1717
}
18-
if (!semver.satisfies(version, '>=2.2.0')) {
18+
19+
if (!semver.satisfies(version, '>=2.2.0 <3')) {
1920
agent.logger.debug(
20-
'Memcached version %s not supported - aborting...',
21+
'memcached version %s not supported, skipping memcached instrumentation',
2122
version,
2223
);
2324
return memcached;

lib/instrumentation/modules/pug.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,22 @@
66

77
'use strict';
88

9+
var semver = require('semver');
10+
911
var shimmer = require('../shimmer');
1012
var templateShared = require('../template-shared');
1113

12-
module.exports = function (pug, agent, { enabled }) {
14+
module.exports = function (pug, agent, { version, enabled }) {
1315
if (!enabled) return pug;
16+
17+
if (!semver.satisfies(version, '>=0.1.0 <4')) {
18+
agent.logger.debug(
19+
'cannot instrument pug version %s, skipping pug instrumentation',
20+
version,
21+
);
22+
return pug;
23+
}
24+
1425
agent.logger.debug('shimming pug.compile');
1526
shimmer.wrap(pug, 'compile', templateShared.wrapCompile(agent, 'pug'));
1627

0 commit comments

Comments
 (0)