WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Open
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
5a39238
switch to js implementation of orchestrion
rochdev Nov 9, 2025
1461c7e
add new dependencies to 3rd party licenses
rochdev Nov 9, 2025
c475b16
fix missing return value
rochdev Nov 9, 2025
761b3d6
add compatibility layer with old hooks
rochdev Nov 9, 2025
21830e7
add disabling rewriter instrumentations
rochdev Nov 9, 2025
20f209f
add error handling
rochdev Nov 9, 2025
2abb6f7
lazy load rewriter dependencies
rochdev Nov 9, 2025
10de506
code cleanup
rochdev Nov 9, 2025
de2c092
add initial source map support and remove engines option
rochdev Nov 10, 2025
ca368c1
add support for replacing subclass instance methods from parent
rochdev Nov 11, 2025
ed9e2d3
fix namespace
rochdev Nov 11, 2025
2bdd856
fix invalid transform
rochdev Nov 11, 2025
d44a73d
fix incorrect binding and channel name
rochdev Nov 11, 2025
3a2b043
refactor
rochdev Nov 12, 2025
e88b24b
fix last langchain test
rochdev Nov 12, 2025
b93eecd
update config file format and clean up code
rochdev Nov 18, 2025
7fcbb7a
improve startup time for source maps
rochdev Nov 18, 2025
9577be8
add comment explaining the purpose of the js rewriter
rochdev Dec 4, 2025
3bcadcd
fix missing 3rd party licenses
rochdev Dec 8, 2025
f53b8fa
fix missing 3rd party licenses
rochdev Dec 8, 2025
8881cb6
refactor transforms as code instead of ast
rochdev Dec 10, 2025
223db86
code cleanup
rochdev Dec 10, 2025
2fb6421
split instrumentations in individual files
rochdev Dec 10, 2025
83deac9
code cleanup
rochdev Dec 10, 2025
51d81f4
add support for traceCallback
rochdev Dec 11, 2025
da34dd3
add basic tests
rochdev Dec 11, 2025
325d435
code cleanup
rochdev Dec 11, 2025
dec9877
fix test
rochdev Dec 11, 2025
8dd9c31
update comment to reflect the new plan
rochdev Dec 11, 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
153 changes: 79 additions & 74 deletions LICENSE-3rdparty.csv
Original file line number Diff line number Diff line change
@@ -1,74 +1,79 @@
"component","origin","license","copyright"
"@datadog/flagging-core","https://github.com/DataDog/openfeature-js-client","['Apache-2.0']","['DataDog']"
"@datadog/libdatadog","https://github.com/DataDog/libdatadog-nodejs","['Apache-2.0']","['Datadog Inc.']"
"@datadog/native-appsec","https://github.com/DataDog/dd-native-appsec-js","['Apache-2.0']","['Datadog Inc.']"
"@datadog/native-iast-taint-tracking","https://github.com/DataDog/dd-native-iast-taint-tracking-js","['Apache-2.0']","['Datadog Inc.']"
"@datadog/native-metrics","https://github.com/DataDog/dd-native-metrics-js","['Apache-2.0']","['Datadog Inc.']"
"@datadog/openfeature-node-server","https://github.com/DataDog/openfeature-js-client","['Apache-2.0']","['DataDog']"
"@datadog/pprof","https://github.com/DataDog/pprof-nodejs","['Apache-2.0']","['Google Inc.']"
"@datadog/sketches-js","https://github.com/DataDog/sketches-js","['Apache-2.0']","['DataDog']"
"@datadog/wasm-js-rewriter","https://github.com/DataDog/dd-wasm-js-rewriter","['Apache-2.0']","['Datadog Inc.']"
"@isaacs/ttlcache","https://github.com/isaacs/ttlcache","['BlueOak-1.0.0']","['Isaac Z. Schlueter']"
"@jsep-plugin/assignment","https://github.com/EricSmekens/jsep","['MIT']","['Shelly']"
"@jsep-plugin/regex","https://github.com/EricSmekens/jsep","['MIT']","['Shelly']"
"@openfeature/server-sdk","https://github.com/open-feature/js-sdk","['Apache-2.0']","['open-feature']"
"@opentelemetry/api","https://github.com/open-telemetry/opentelemetry-js","['Apache-2.0']","['OpenTelemetry Authors']"
"@opentelemetry/api-logs","https://github.com/open-telemetry/opentelemetry-js","['Apache-2.0']","['OpenTelemetry Authors']"
"@opentelemetry/core","https://github.com/open-telemetry/opentelemetry-js","['Apache-2.0']","['OpenTelemetry Authors']"
"@opentelemetry/resources","https://github.com/open-telemetry/opentelemetry-js","['Apache-2.0']","['OpenTelemetry Authors']"
"@opentelemetry/semantic-conventions","https://github.com/open-telemetry/opentelemetry-js","['Apache-2.0']","['OpenTelemetry Authors']"
"@protobufjs/aspromise","https://github.com/protobufjs/protobuf.js","['BSD-3-Clause']","['Daniel Wirtz']"
"@protobufjs/base64","https://github.com/protobufjs/protobuf.js","['BSD-3-Clause']","['Daniel Wirtz']"
"@protobufjs/codegen","https://github.com/protobufjs/protobuf.js","['BSD-3-Clause']","['Daniel Wirtz']"
"@protobufjs/eventemitter","https://github.com/protobufjs/protobuf.js","['BSD-3-Clause']","['Daniel Wirtz']"
"@protobufjs/fetch","https://github.com/protobufjs/protobuf.js","['BSD-3-Clause']","['Daniel Wirtz']"
"@protobufjs/float","https://github.com/protobufjs/protobuf.js","['BSD-3-Clause']","['Daniel Wirtz']"
"@protobufjs/inquire","https://github.com/protobufjs/protobuf.js","['BSD-3-Clause']","['Daniel Wirtz']"
"@protobufjs/path","https://github.com/protobufjs/protobuf.js","['BSD-3-Clause']","['Daniel Wirtz']"
"@protobufjs/pool","https://github.com/protobufjs/protobuf.js","['BSD-3-Clause']","['Daniel Wirtz']"
"@protobufjs/utf8","https://github.com/protobufjs/protobuf.js","['BSD-3-Clause']","['Daniel Wirtz']"
"@types/node","https://github.com/DefinitelyTyped/DefinitelyTyped","['MIT']","['DefinitelyTyped']"
"acorn","https://github.com/acornjs/acorn","['MIT']","['acornjs']"
"acorn-import-attributes","https://github.com/xtuc/acorn-import-attributes","['MIT']","['Sven Sauleau']"
"argparse","https://github.com/nodeca/argparse","['Python-2.0']","['nodeca']"
"cjs-module-lexer","https://github.com/nodejs/cjs-module-lexer","['MIT']","['Guy Bedford']"
"crypto-randomuuid","npm:crypto-randomuuid","['MIT']","['Stephen Belanger']"
"dc-polyfill","https://github.com/DataDog/dc-polyfill","['MIT']","['Thomas Hunter II']"
"dd-trace","https://github.com/DataDog/dd-trace-js","['(Apache-2.0 OR BSD-3-Clause)']","['Datadog Inc. <[email protected]>']"
"delay","https://github.com/sindresorhus/delay","['MIT']","['Sindre Sorhus']"
"detect-newline","https://github.com/sindresorhus/detect-newline","['MIT']","['Sindre Sorhus']"
"escape-string-regexp","https://github.com/sindresorhus/escape-string-regexp","['MIT']","['Sindre Sorhus']"
"fast-fifo","https://github.com/mafintosh/fast-fifo","['MIT']","['Mathias Buus']"
"ignore","https://github.com/kaelzhang/node-ignore","['MIT']","['kael']"
"import-in-the-middle","https://github.com/nodejs/import-in-the-middle","['Apache-2.0']","['Bryan English']"
"istanbul-lib-coverage","https://github.com/istanbuljs/istanbuljs","['BSD-3-Clause']","['Krishnan Anantheswaran']"
"jest-docblock","https://github.com/jestjs/jest","['MIT']","['jestjs']"
"js-yaml","https://github.com/nodeca/js-yaml","['MIT']","['Vladimir Zapparov']"
"jsep","https://github.com/EricSmekens/jsep","['MIT']","['Stephen Oney']"
"jsonpath-plus","https://github.com/JSONPath-Plus/JSONPath","['MIT']","['Stefan Goessner']"
"limiter","https://github.com/jhurliman/node-rate-limiter","['MIT']","['John Hurliman']"
"lodash.sortby","https://github.com/lodash/lodash","['MIT']","['John-David Dalton']"
"long","https://github.com/dcodeIO/long.js","['Apache-2.0']","['Daniel Wirtz']"
"lru-cache","https://github.com/isaacs/node-lru-cache","['ISC']","['Isaac Z. Schlueter']"
"module-details-from-path","https://github.com/watson/module-details-from-path","['MIT']","['Thomas Watson']"
"mutexify","https://github.com/mafintosh/mutexify","['MIT']","['Mathias Buus']"
"node-addon-api","https://github.com/nodejs/node-addon-api","['MIT']","['nodejs']"
"node-gyp-build","https://github.com/prebuild/node-gyp-build","['MIT']","['Mathias Buus']"
"opentracing","https://github.com/opentracing/opentracing-javascript","['Apache-2.0']","['opentracing']"
"p-limit","https://github.com/sindresorhus/p-limit","['MIT']","['Sindre Sorhus']"
"path-to-regexp","https://github.com/pillarjs/path-to-regexp","['MIT']","['pillarjs']"
"pprof-format","https://github.com/DataDog/pprof-format","['MIT']","['Datadog Inc.']"
"protobufjs","https://github.com/protobufjs/protobuf.js","['BSD-3-Clause']","['Daniel Wirtz']"
"queue-tick","https://github.com/mafintosh/queue-tick","['MIT']","['Mathias Buus']"
"retry","https://github.com/tim-kos/node-retry","['MIT']","['Tim Koschützki']"
"rfdc","https://github.com/davidmarkclements/rfdc","['MIT']","['David Mark Clements']"
"semifies","https://github.com/holepunchto/semifies","['Apache-2.0']","['Holepunch Inc']"
"shell-quote","https://github.com/ljharb/shell-quote","['MIT']","['James Halliday']"
"source-map","https://github.com/mozilla/source-map","['BSD-3-Clause']","['Nick Fitzgerald']"
"spark-md5","https://github.com/satazor/js-spark-md5","['(WTFPL OR MIT)']","['André Cruz']"
"tlhunter-sorted-set","https://github.com/tlhunter/node-sorted-set","['MIT']","['Thomas Hunter II']"
"ttl-set","https://github.com/watson/ttl-set","['MIT']","['Thomas Watson']"
"undici-types","https://github.com/nodejs/undici","['MIT']","['nodejs']"
"yocto-queue","https://github.com/sindresorhus/yocto-queue","['MIT']","['Sindre Sorhus']"
"aws-lambda-nodejs-runtime-interface-client","https://github.com/aws/aws-lambda-nodejs-runtime-interface-client/blob/v2.1.0/src/utils/UserFunction.ts","['Apache-2.0']","['Amazon.com Inc. or its affiliates']"
"is-git-url","https://github.com/jonschlinkert/is-git-url/blob/396965ffabf2f46656c8af4c47bef1d69f09292e/index.js#L9C15-L9C87","['MIT']","['Jon Schlinkert']"
"component","origin","license","copyright"
"@datadog/flagging-core","https://github.com/DataDog/openfeature-js-client","['Apache-2.0']","['DataDog']"
"@datadog/libdatadog","https://github.com/DataDog/libdatadog-nodejs","['Apache-2.0']","['Datadog Inc.']"
"@datadog/native-appsec","https://github.com/DataDog/dd-native-appsec-js","['Apache-2.0']","['Datadog Inc.']"
"@datadog/native-iast-taint-tracking","https://github.com/DataDog/dd-native-iast-taint-tracking-js","['Apache-2.0']","['Datadog Inc.']"
"@datadog/native-metrics","https://github.com/DataDog/dd-native-metrics-js","['Apache-2.0']","['Datadog Inc.']"
"@datadog/openfeature-node-server","https://github.com/DataDog/openfeature-js-client","['Apache-2.0']","['DataDog']"
"@datadog/pprof","https://github.com/DataDog/pprof-nodejs","['Apache-2.0']","['Google Inc.']"
"@datadog/sketches-js","https://github.com/DataDog/sketches-js","['Apache-2.0']","['DataDog']"
"@datadog/source-map","npm:@datadog/source-map","[]","[]"
"@datadog/wasm-js-rewriter","https://github.com/DataDog/dd-wasm-js-rewriter","['Apache-2.0']","['Datadog Inc.']"
"@isaacs/ttlcache","https://github.com/isaacs/ttlcache","['BlueOak-1.0.0']","['Isaac Z. Schlueter']"
"@jsep-plugin/assignment","https://github.com/EricSmekens/jsep","['MIT']","['Shelly']"
"@jsep-plugin/regex","https://github.com/EricSmekens/jsep","['MIT']","['Shelly']"
"@openfeature/server-sdk","https://github.com/open-feature/js-sdk","['Apache-2.0']","['open-feature']"
"@opentelemetry/api","https://github.com/open-telemetry/opentelemetry-js","['Apache-2.0']","['OpenTelemetry Authors']"
"@opentelemetry/api-logs","https://github.com/open-telemetry/opentelemetry-js","['Apache-2.0']","['OpenTelemetry Authors']"
"@opentelemetry/core","https://github.com/open-telemetry/opentelemetry-js","['Apache-2.0']","['OpenTelemetry Authors']"
"@opentelemetry/resources","https://github.com/open-telemetry/opentelemetry-js","['Apache-2.0']","['OpenTelemetry Authors']"
"@opentelemetry/semantic-conventions","https://github.com/open-telemetry/opentelemetry-js","['Apache-2.0']","['OpenTelemetry Authors']"
"@protobufjs/aspromise","https://github.com/protobufjs/protobuf.js","['BSD-3-Clause']","['Daniel Wirtz']"
"@protobufjs/base64","https://github.com/protobufjs/protobuf.js","['BSD-3-Clause']","['Daniel Wirtz']"
"@protobufjs/codegen","https://github.com/protobufjs/protobuf.js","['BSD-3-Clause']","['Daniel Wirtz']"
"@protobufjs/eventemitter","https://github.com/protobufjs/protobuf.js","['BSD-3-Clause']","['Daniel Wirtz']"
"@protobufjs/fetch","https://github.com/protobufjs/protobuf.js","['BSD-3-Clause']","['Daniel Wirtz']"
"@protobufjs/float","https://github.com/protobufjs/protobuf.js","['BSD-3-Clause']","['Daniel Wirtz']"
"@protobufjs/inquire","https://github.com/protobufjs/protobuf.js","['BSD-3-Clause']","['Daniel Wirtz']"
"@protobufjs/path","https://github.com/protobufjs/protobuf.js","['BSD-3-Clause']","['Daniel Wirtz']"
"@protobufjs/pool","https://github.com/protobufjs/protobuf.js","['BSD-3-Clause']","['Daniel Wirtz']"
"@protobufjs/utf8","https://github.com/protobufjs/protobuf.js","['BSD-3-Clause']","['Daniel Wirtz']"
"@types/node","https://github.com/DefinitelyTyped/DefinitelyTyped","['MIT']","['DefinitelyTyped']"
"acorn","https://github.com/acornjs/acorn","['MIT']","['acornjs']"
"acorn-import-attributes","https://github.com/xtuc/acorn-import-attributes","['MIT']","['Sven Sauleau']"
"argparse","https://github.com/nodeca/argparse","['Python-2.0']","['nodeca']"
"astring","https://github.com/davidbonnet/astring","['MIT']","['David Bonnet']"
"cjs-module-lexer","https://github.com/nodejs/cjs-module-lexer","['MIT']","['Guy Bedford']"
"crypto-randomuuid","npm:crypto-randomuuid","['MIT']","['Stephen Belanger']"
"dc-polyfill","https://github.com/DataDog/dc-polyfill","['MIT']","['Thomas Hunter II']"
"dd-trace","https://github.com/DataDog/dd-trace-js","['(Apache-2.0 OR BSD-3-Clause)']","['Datadog Inc. <[email protected]>']"
"delay","https://github.com/sindresorhus/delay","['MIT']","['Sindre Sorhus']"
"detect-newline","https://github.com/sindresorhus/detect-newline","['MIT']","['Sindre Sorhus']"
"escape-string-regexp","https://github.com/sindresorhus/escape-string-regexp","['MIT']","['Sindre Sorhus']"
"esquery","https://github.com/estools/esquery","['BSD-3-Clause']","['Joel Feenstra']"
"estraverse","https://github.com/estools/estraverse","['BSD-2-Clause']","['estools']"
"fast-fifo","https://github.com/mafintosh/fast-fifo","['MIT']","['Mathias Buus']"
"ignore","https://github.com/kaelzhang/node-ignore","['MIT']","['kael']"
"import-in-the-middle","https://github.com/nodejs/import-in-the-middle","['Apache-2.0']","['Bryan English']"
"istanbul-lib-coverage","https://github.com/istanbuljs/istanbuljs","['BSD-3-Clause']","['Krishnan Anantheswaran']"
"jest-docblock","https://github.com/jestjs/jest","['MIT']","['jestjs']"
"js-yaml","https://github.com/nodeca/js-yaml","['MIT']","['Vladimir Zapparov']"
"jsep","https://github.com/EricSmekens/jsep","['MIT']","['Stephen Oney']"
"jsonpath-plus","https://github.com/JSONPath-Plus/JSONPath","['MIT']","['Stefan Goessner']"
"limiter","https://github.com/jhurliman/node-rate-limiter","['MIT']","['John Hurliman']"
"lodash.sortby","https://github.com/lodash/lodash","['MIT']","['John-David Dalton']"
"long","https://github.com/dcodeIO/long.js","['Apache-2.0']","['Daniel Wirtz']"
"lru-cache","https://github.com/isaacs/node-lru-cache","['ISC']","['Isaac Z. Schlueter']"
"meriyah","https://github.com/meriyah/meriyah","['ISC']","['Kenny F.']"
"module-details-from-path","https://github.com/watson/module-details-from-path","['MIT']","['Thomas Watson']"
"mutexify","https://github.com/mafintosh/mutexify","['MIT']","['Mathias Buus']"
"node-addon-api","https://github.com/nodejs/node-addon-api","['MIT']","['nodejs']"
"node-gyp-build","https://github.com/prebuild/node-gyp-build","['MIT']","['Mathias Buus']"
"opentracing","https://github.com/opentracing/opentracing-javascript","['Apache-2.0']","['opentracing']"
"p-limit","https://github.com/sindresorhus/p-limit","['MIT']","['Sindre Sorhus']"
"path-to-regexp","https://github.com/pillarjs/path-to-regexp","['MIT']","['pillarjs']"
"pprof-format","https://github.com/DataDog/pprof-format","['MIT']","['Datadog Inc.']"
"protobufjs","https://github.com/protobufjs/protobuf.js","['BSD-3-Clause']","['Daniel Wirtz']"
"queue-tick","https://github.com/mafintosh/queue-tick","['MIT']","['Mathias Buus']"
"retry","https://github.com/tim-kos/node-retry","['MIT']","['Tim Koschützki']"
"rfdc","https://github.com/davidmarkclements/rfdc","['MIT']","['David Mark Clements']"
"semifies","https://github.com/holepunchto/semifies","['Apache-2.0']","['Holepunch Inc']"
"shell-quote","https://github.com/ljharb/shell-quote","['MIT']","['James Halliday']"
"source-map","https://github.com/mozilla/source-map","['BSD-3-Clause']","['Nick Fitzgerald']"
"spark-md5","https://github.com/satazor/js-spark-md5","['(WTFPL OR MIT)']","['André Cruz']"
"tlhunter-sorted-set","https://github.com/tlhunter/node-sorted-set","['MIT']","['Thomas Hunter II']"
"ttl-set","https://github.com/watson/ttl-set","['MIT']","['Thomas Watson']"
"undici-types","https://github.com/nodejs/undici","['MIT']","['nodejs']"
"yocto-queue","https://github.com/sindresorhus/yocto-queue","['MIT']","['Sindre Sorhus']"
"aws-lambda-nodejs-runtime-interface-client","https://github.com/aws/aws-lambda-nodejs-runtime-interface-client/blob/v2.1.0/src/utils/UserFunction.ts","['Apache-2.0']","['Amazon.com Inc. or its affiliates']"
"is-git-url","https://github.com/jonschlinkert/is-git-url/blob/396965ffabf2f46656c8af4c47bef1d69f09292e/index.js#L9C15-L9C87","['MIT']","['Jon Schlinkert']"
9 changes: 7 additions & 2 deletions loader-hook.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import regexpEscape from 'escape-string-regexp'
import * as iitm from 'import-in-the-middle/hook.mjs'
import hooks from './packages/datadog-instrumentations/src/helpers/hooks.js'
import configHelper from './packages/dd-trace/src/config-helper.js'
import * as rewriterLoader from './packages/datadog-instrumentations/src/helpers/rewriter/loader.mjs'

// For some reason `getEnvironmentVariable` is not otherwise available to ESM.
const env = configHelper.getEnvironmentVariable
Expand All @@ -17,6 +18,10 @@ function initialize (data = {}) {
return iitm.initialize(data)
}

function load (url, context, nextLoad) {
return rewriterLoader.load(url, context, (url, context) => iitm.load(url, context, nextLoad))
}

function addInstrumentations (data) {
const instrumentations = Object.keys(hooks)

Expand Down Expand Up @@ -48,5 +53,5 @@ function addExclusions (data) {
)
}

export { initialize }
export { load, getFormat, resolve, getSource } from 'import-in-the-middle/hook.mjs'
export { initialize, load }
export { getFormat, resolve, getSource } from 'import-in-the-middle/hook.mjs'
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,18 @@
"@datadog/openfeature-node-server": "^0.2.0",
"@datadog/pprof": "5.12.0",
"@datadog/sketches-js": "2.1.1",
"@datadog/source-map": "npm:source-map@^0.6.0",
"@datadog/wasm-js-rewriter": "5.0.1",
"@isaacs/ttlcache": "^2.0.1",
"@opentelemetry/api": ">=1.0.0 <1.10.0",
"@opentelemetry/api-logs": "<1.0.0",
"@opentelemetry/core": ">=1.14.0 <1.31.0",
"@opentelemetry/resources": ">=1.0.0 <1.31.0",
"astring": "^1.9.0",
"crypto-randomuuid": "^1.0.0",
"dc-polyfill": "^0.1.10",
"escape-string-regexp": "^5.0.0",
"esquery": "^1.6.0",
"ignore": "^7.0.5",
"import-in-the-middle": "^1.14.2",
"istanbul-lib-coverage": "^3.2.2",
Expand All @@ -147,6 +150,7 @@
"limiter": "^1.1.5",
"lodash.sortby": "^4.7.0",
"lru-cache": "^10.4.3",
"meriyah": "^6.1.4",
"module-details-from-path": "^1.0.4",
"mutexify": "^1.4.0",
"opentracing": ">=0.14.7",
Expand Down
1 change: 1 addition & 0 deletions packages/datadog-instrumentations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

require('./src/helpers/bundler-register')
require('./src/helpers/register')
require('./src/helpers/rewriter/loader')
10 changes: 10 additions & 0 deletions packages/datadog-instrumentations/src/helpers/instrument.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const dc = require('dc-polyfill')
const instrumentations = require('./instrumentations')
const rewriterInstrumentations = require('./rewriter/instrumentations')
const { AsyncResource } = require('async_hooks')

const channelMap = {}
Expand All @@ -22,6 +23,15 @@ exports.tracingChannel = function (name) {
return tc
}

exports.getHooks = function getHooks (names) {
names = [names].flat()

return rewriterInstrumentations
.map(inst => inst.module)
.filter(({ name }) => names.includes(name))
.map(({ name, versionRange, filePath }) => ({ name, versions: [versionRange], file: filePath }))
}

/**
* @param {object} args
* @param {string|string[]} args.name module name
Expand Down
5 changes: 5 additions & 0 deletions packages/datadog-instrumentations/src/helpers/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const checkRequireCache = require('./check-require-cache')
const telemetry = require('../../../dd-trace/src/guardrails/telemetry')
const { isInServerlessEnvironment } = require('../../../dd-trace/src/serverless')
const { getEnvironmentVariables } = require('../../../dd-trace/src/config-helper')
const rewriter = require('./rewriter')

const envs = getEnvironmentVariables()

Expand Down Expand Up @@ -48,6 +49,10 @@ if (DD_TRACE_DEBUG && DD_TRACE_DEBUG.toLowerCase() !== 'false') {
const seenCombo = new Set()
const allInstrumentations = {}

for (const inst of disabledInstrumentations) {
rewriter.disable(inst)
}

// TODO: make this more efficient
for (const packageName of names) {
if (disabledInstrumentations.has(packageName)) continue
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict'

let meriyah
let astring
let esquery

module.exports = {
parse: (...args) => {
meriyah ??= require('meriyah')

return meriyah.parse(...args)
},

generate: (...args) => {
astring ??= require('astring')

return astring.generate(...args)
},

traverse: (ast, query, visitor) => {
esquery ??= require('esquery')

const selector = esquery.parse(query)

return esquery.traverse(ast, selector, visitor)
},
}
Loading
Loading