From 217db9d93b0dba676f0ad995018e81f52eef822c Mon Sep 17 00:00:00 2001 From: Ugaitz Urien Date: Fri, 15 Nov 2024 14:47:50 +0100 Subject: [PATCH 1/2] Do not instrument @elastic/elasticsearch >=8.16.0 --- packages/datadog-instrumentations/src/elasticsearch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/datadog-instrumentations/src/elasticsearch.js b/packages/datadog-instrumentations/src/elasticsearch.js index ef38cd8dd27..7ecaff374b2 100644 --- a/packages/datadog-instrumentations/src/elasticsearch.js +++ b/packages/datadog-instrumentations/src/elasticsearch.js @@ -13,7 +13,7 @@ addHook({ name: '@elastic/transport', file: 'lib/Transport.js', versions: ['>=8' return exports }) -addHook({ name: '@elastic/elasticsearch', file: 'lib/Transport.js', versions: ['>=5.6.16 <8', '>=8'] }, Transport => { +addHook({ name: '@elastic/elasticsearch', file: 'lib/Transport.js', versions: ['>=5.6.16 <8', '>=8 <8.16.0'] }, Transport => { shimmer.wrap(Transport.prototype, 'request', createWrapRequest('elasticsearch')) shimmer.wrap(Transport.prototype, 'getConnection', createWrapGetConnection('elasticsearch')) return Transport From 3d1406efc3767d5ae7bf5421a507bce730f64057 Mon Sep 17 00:00:00 2001 From: Ugaitz Urien Date: Fri, 15 Nov 2024 15:14:23 +0100 Subject: [PATCH 2/2] Only exclude 8.16.0 from the esm tests --- packages/datadog-instrumentations/src/elasticsearch.js | 2 +- .../test/integration-test/client.spec.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/datadog-instrumentations/src/elasticsearch.js b/packages/datadog-instrumentations/src/elasticsearch.js index 7ecaff374b2..ef38cd8dd27 100644 --- a/packages/datadog-instrumentations/src/elasticsearch.js +++ b/packages/datadog-instrumentations/src/elasticsearch.js @@ -13,7 +13,7 @@ addHook({ name: '@elastic/transport', file: 'lib/Transport.js', versions: ['>=8' return exports }) -addHook({ name: '@elastic/elasticsearch', file: 'lib/Transport.js', versions: ['>=5.6.16 <8', '>=8 <8.16.0'] }, Transport => { +addHook({ name: '@elastic/elasticsearch', file: 'lib/Transport.js', versions: ['>=5.6.16 <8', '>=8'] }, Transport => { shimmer.wrap(Transport.prototype, 'request', createWrapRequest('elasticsearch')) shimmer.wrap(Transport.prototype, 'getConnection', createWrapGetConnection('elasticsearch')) return Transport diff --git a/packages/datadog-plugin-elasticsearch/test/integration-test/client.spec.js b/packages/datadog-plugin-elasticsearch/test/integration-test/client.spec.js index eacd384c033..9f64b0c7c27 100644 --- a/packages/datadog-plugin-elasticsearch/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-elasticsearch/test/integration-test/client.spec.js @@ -13,7 +13,8 @@ describe('esm', () => { let proc let sandbox - withVersions('elasticsearch', ['@elastic/elasticsearch'], version => { + // excluding 8.16.0 for esm tests, because it is not working: https://github.com/elastic/elasticsearch-js/issues/2466 + withVersions('elasticsearch', ['@elastic/elasticsearch'], '<8.16.0 || >8.16.0', version => { before(async function () { this.timeout(20000) sandbox = await createSandbox([`'@elastic/elasticsearch@${version}'`], false, [