Skip to content

Commit 2ff2a3e

Browse files
committed
wip
1 parent 96a06b5 commit 2ff2a3e

File tree

3 files changed

+22
-28
lines changed

3 files changed

+22
-28
lines changed

packages/datadog-instrumentations/src/couchbase.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ function wrapV3Query (query) {
160160
}
161161

162162
// semver >=2 <3
163-
// couchbase v2 won't build on LTS node versions greater than 12
164163
addHook({ name: 'couchbase', file: 'lib/bucket.js', versions: ['^2.6.5'] }, Bucket => {
165164
const startCh = channel('apm:couchbase:query:start')
166165
const finishCh = channel('apm:couchbase:query:finish')

packages/dd-trace/test/plugins/externals.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
},
88
{
99
"name": "couchbase",
10-
"versions": [">=3.0.0 <3.2.0", "3.2.0 - 3.2.1", "3.2.2 - 3.2.4"],
11-
"nodeVersions": [">=14.0.0 <18.0.0"]
10+
"versions": ["3.2.0 - 3.2.1", "3.2.2 - 3.2.4"],
11+
"nodeVersions": [">=14.0.0"]
1212
},
1313
{
1414
"name": "couchbase",
1515
"versions": [">=4.0.0"],
16-
"nodeVersions": [">=14.0.0 <18.0.0"],
16+
"nodeVersions": [">=14.0.0"],
1717
"ignoreMinVersion": true
1818
}
1919
],

packages/dd-trace/test/setup/core.js

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,6 @@ function loadInstFile (file, instrumentations) {
6060
})
6161
}
6262

63-
function removeVersions (instrumentations = [], external) {
64-
return instrumentations.filter(instrumentation => {
65-
let keep = true
66-
instrumentation.versions.forEach(instVersion => {
67-
external.versions.forEach((extVersion) => {
68-
if (semver.intersects(instVersion, extVersion)) keep = false
69-
})
70-
})
71-
return keep
72-
})
73-
}
74-
7563
function withVersions (plugin, modules, range, cb) {
7664
let instrumentations = typeof plugin === 'string' ? loadInst(plugin) : [].concat(plugin)
7765
const names = instrumentations.map(instrumentation => instrumentation.name)
@@ -82,22 +70,29 @@ function withVersions (plugin, modules, range, cb) {
8270
if (externals[name]) {
8371
[].concat(externals[name]).forEach(external => {
8472
const { nodeVersions } = external
85-
let satisfies = true
86-
if (nodeVersions) {
87-
satisfies = false
88-
for (const version of nodeVersions) {
89-
if (semver.satisfies(process.version, version)) {
90-
satisfies = true
91-
break
92-
}
93-
}
94-
}
73+
const satisfies = nodeVersions
74+
? nodeVersions
75+
.reduce((satisfies, version) => satisfies || semver.satisfies(process.version, version), false)
76+
: true
9577

9678
if (satisfies) {
79+
// use external in instrumentation
9780
instrumentations.push(external)
9881
} else {
99-
// remove all versions with that don't satisfy node version based on externals
100-
instrumentations = removeVersions(instrumentations, external)
82+
// node version not satisifed
83+
// don't add this external, and remove all other instrumentations from testing with overlapping versions
84+
instrumentations = instrumentations.filter(instrumentation => {
85+
return instrumentation.versions
86+
.reduce((crossed, instVersion) => {
87+
external.versions.forEach(extVersion => crossed.push([instVersion, extVersion]))
88+
return crossed
89+
}
90+
, []) // cross instrumentation versions with externals versions
91+
.reduce((matches, versions) => {
92+
const [instVersion, extVersion] = versions
93+
return matches && !semver.intersects(instVersion, extVersion)
94+
}, true) // filter on matching overlaps
95+
})
10196
}
10297
})
10398
}

0 commit comments

Comments
 (0)