Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 5 additions & 3 deletions .tav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@ koa-router:
commands: node test/instrumentation/modules/koa-router/new-name.test.js

elasticsearch:
versions: '>=8.0.0'
versions:
mode: max-5
include: '>=8.0.0 <17'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change massively reduces the number of versions tested:

% TAV=elasticsearch npx tav --dry-run --verbose | rg matching
-- 54 package versions matching filter: 8.0.1, 8.1.0, 8.2.0, 9.0.0, 9.0.1, 9.0.2, 10.0.0, 10.0.1, 10.1.0, 10.1.1, 10.1.2, 10.1.3, 11.0.0, 11.0.1, 12.0.0, 12.0.1, 12.1.0, 12.1.1, 12.1.2, 12.1.3, 13.0.0, 13.0.1, 13.1.0, 13.1.1, 13.1.2, 13.2.0, 13.3.0, 13.3.1, 14.0.0, 14.1.0, 14.2.0, 14.2.1, 14.2.2, 15.0.0, 15.1.0, 15.1.1, 15.2.0, 15.3.0, 15.3.1, 15.4.0, 15.4.1, 15.5.0, 16.0.0, 16.1.0, 16.1.1, 16.2.0, 16.3.0, 16.4.0, 16.5.0, 16.6.0, 16.7.0, 16.7.1, 16.7.2, 16.7.3
[16:04:13 trentm@peach:~/el/apm-agent-nodejs6 (git:trentm-cap-major-ver-for-instrs)]
% TAV=elasticsearch npx tav --dry-run --verbose | rg matching
-- 5 package versions matching filter: 8.0.1, 12.1.0, 15.0.0, 16.7.1, 16.7.3

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We skip some major releases but I think we're fine.

commands: node test/instrumentation/modules/elasticsearch.test.js

# @elastic/elasticsearch
Expand Down Expand Up @@ -308,7 +310,7 @@ handlebars:
pug:
- versions: '0.1.0 || >2.0.0 <3.0.0'
commands: node test/instrumentation/modules/pug.test.js
- versions: '>=3.0.0'
- versions: '>=3.0.0 <4'
node: '>8'
commands: node test/instrumentation/modules/pug.test.js

Expand Down Expand Up @@ -483,7 +485,7 @@ finalhandler:
commands: node test/instrumentation/modules/finalhandler.test.js

memcached:
versions: '>=2.2.0'
versions: '>=2.2.0 <3'
commands: node test/instrumentation/modules/memcached.test.js

aws-sdk:
Expand Down
16 changes: 8 additions & 8 deletions docs/reference/supported-technologies.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,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 <6.0.0 | |
| [Fastify](/reference/fastify.md) | >=2.0.0 | See also [Fastify’s own LTS documentation](https://www.fastify.io/docs/latest/Reference/LTS/) |
| [Fastify](/reference/fastify.md) | >=2.0.0 <6 | 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). |
| [Restify](/reference/restify.md) | >=5.2.0 <12.0.0 | |
Expand Down Expand Up @@ -88,21 +88,21 @@ The Node.js agent will automatically instrument the following modules to give yo
| [@aws-sdk/client-sqs](https://www.npmjs.com/package/@aws-sdk/client-s3) | >=3.15.0 <4 | Will instrument SQS send/receive/delete messages |
| [@aws-sdk/client-dynamodb](https://www.npmjs.com/package/@aws-sdk/client-dynamodb) | >=3.15.0 <4 | Will instrument all DynamoDB methods |
| [cassandra-driver](https://www.npmjs.com/package/cassandra-driver) | >=3.0.0 <5 | Will instrument all queries |
| [elasticsearch](https://www.npmjs.com/package/elasticsearch) | >=8.0.0 | Will instrument all queries |
| [@elastic/elasticsearch](https://www.npmjs.com/package/@elastic/elasticsearch) | >=7.0.0 <9.0.0 | Will instrument all queries |
| [elasticsearch](https://www.npmjs.com/package/elasticsearch) | >=8.0.0 <17 | Will instrument all queries |
| [@elastic/elasticsearch](https://www.npmjs.com/package/@elastic/elasticsearch) | >=7.0.0 <10.0.0 | Will instrument all queries |
| [graphql](https://www.npmjs.com/package/graphql) | >=0.7.0 <17 | Will instrument all queries |
| [handlebars](https://www.npmjs.com/package/handlebars) | * | Will instrument compile and render calls |
| [jade](https://www.npmjs.com/package/jade) | >=0.5.6 | Will instrument compile and render calls; Deprecated. No longer tested. Use pug. |
| [pug](https://www.npmjs.com/package/pug) | >=0.1.0 | Will instrument compile and render calls |
| [handlebars](https://www.npmjs.com/package/handlebars) | >=1 <5 | Will instrument compile and render calls |
| [jade](https://www.npmjs.com/package/jade) | >=0.5.6 <2 | Will instrument compile and render calls; Deprecated. No longer tested. Use pug. |
| [pug](https://www.npmjs.com/package/pug) | >=0.1.0 <4 | Will instrument compile and render calls |
| [ioredis](https://www.npmjs.com/package/ioredis) | >=2.0.0 <6.0.0 | Will instrument all queries |
| [memcached](https://www.npmjs.com/package/memcached) | >=2.2.0 | Will instrument all commands. |
| [memcached](https://www.npmjs.com/package/memcached) | >=2.2.0 <3 | Will instrument all commands. |
| [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. |
| [mongodb](https://www.npmjs.com/package/mongodb) | >=2.0.0 <3.3.0 | Supported via mongodb-core |
| [mongodb](https://www.npmjs.com/package/mongodb) | >=3.3.0 <7 | Will instrument all queries |
| [mongojs](https://www.npmjs.com/package/mongojs) | >=1.0.0 <2.7.0 | Supported via mongodb-core |
| [mongoose](https://www.npmjs.com/package/mongoose) | >=4.0.0 <5.7.0 | Supported via mongodb-core |
| [mongoose](https://www.npmjs.com/package/mongoose) | >=5.7.0 <8 | Supported via mongodb |
| [mysql](https://www.npmjs.com/package/mysql) | ^2.0.0 | Will instrument all queries |
| [mysql](https://www.npmjs.com/package/mysql) | >=2.0.0 <3 | Will instrument all queries |
| [mysql2](https://www.npmjs.com/package/mysql2) | >=1.0.0 <4.0.0 | Will instrument all queries |
| [pg](https://www.npmjs.com/package/pg) | >=4.0.0 <9.0.0 | Will instrument all queries |
| [redis](https://www.npmjs.com/package/redis) | >=2.0.0 <5.0.0 | Will instrument all queries |
Expand Down
11 changes: 10 additions & 1 deletion lib/instrumentation/modules/elasticsearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
'use strict';

const { URL, URLSearchParams } = require('url');
const semver = require('semver');

var shimmer = require('../shimmer');
var { getDBDestination } = require('../context');
Expand Down Expand Up @@ -63,9 +64,17 @@ function getTargetUrlFromTransportConfig(config) {
return null;
}

module.exports = function (elasticsearch, agent, { enabled }) {
module.exports = function (elasticsearch, agent, { version, enabled }) {
if (!enabled) return elasticsearch;

if (!semver.satisfies(version, '>=8.0.0 <17')) {
agent.logger.debug(
'cannot instrument elasticsearch version %s, skipping elasticsearch instrumentation',
version,
);
return elasticsearch;
}

const ins = agent._instrumentation;
const elasticsearchCaptureBodyUrlsRegExp =
agent._conf.elasticsearchCaptureBodyUrlsRegExp;
Expand Down
7 changes: 7 additions & 0 deletions lib/instrumentation/modules/fastify.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ module.exports = function (
if (!enabled) {
return modExports;
}
if (!semver.satisfies(version, '>=2.0.0 <6')) {
agent.logger.debug(
'cannot instrument fastify version %s, skipping fastify instrumentation',
version,
);
return modExports;
}
if (isImportMod && !semver.satisfies(version, '>=3.5.0')) {
// https://github.com/fastify/fastify/pull/2590
agent.logger.debug(
Expand Down
13 changes: 12 additions & 1 deletion lib/instrumentation/modules/handlebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,22 @@

'use strict';

var semver = require('semver');

var shimmer = require('../shimmer');
var templateShared = require('../template-shared');

module.exports = function (handlebars, agent, { enabled }) {
module.exports = function (handlebars, agent, { version, enabled }) {
if (!enabled) return handlebars;

if (!semver.satisfies(version, '>=1 <5')) {
agent.logger.debug(
'cannot instrument handlebars version %s, skipping handlebars instrumentation',
version,
);
return handlebars;
}

agent.logger.debug('shimming handlebars.compile');
shimmer.wrap(
handlebars,
Expand Down
13 changes: 12 additions & 1 deletion lib/instrumentation/modules/jade.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,22 @@

'use strict';

var semver = require('semver');

var shimmer = require('../shimmer');
var templateShared = require('../template-shared');

module.exports = function (jade, agent, { enabled }) {
module.exports = function (jade, agent, { version, enabled }) {
if (!enabled) return jade;

if (!semver.satisfies(version, '>=0.5.6 <2')) {
agent.logger.debug(
'cannot instrument jade version %s, skipping jade instrumentation',
version,
);
return jade;
}

agent.logger.debug('shimming jade.compile');
shimmer.wrap(jade, 'compile', templateShared.wrapCompile(agent, 'jade'));

Expand Down
5 changes: 3 additions & 2 deletions lib/instrumentation/modules/memcached.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ module.exports = function (memcached, agent, { version, enabled }) {
if (!enabled) {
return memcached;
}
if (!semver.satisfies(version, '>=2.2.0')) {

if (!semver.satisfies(version, '>=2.2.0 <3')) {
agent.logger.debug(
'Memcached version %s not supported - aborting...',
'memcached version %s not supported, skipping memcached instrumentation',
version,
);
return memcached;
Expand Down
13 changes: 12 additions & 1 deletion lib/instrumentation/modules/pug.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,22 @@

'use strict';

var semver = require('semver');

var shimmer = require('../shimmer');
var templateShared = require('../template-shared');

module.exports = function (pug, agent, { enabled }) {
module.exports = function (pug, agent, { version, enabled }) {
if (!enabled) return pug;

if (!semver.satisfies(version, '>=0.1.0 <4')) {
agent.logger.debug(
'cannot instrument pug version %s, skipping pug instrumentation',
version,
);
return pug;
}

agent.logger.debug('shimming pug.compile');
shimmer.wrap(pug, 'compile', templateShared.wrapCompile(agent, 'pug'));

Expand Down
Loading