Skip to content

Commit 4b2c14f

Browse files
authored
refactor: Updated agent to use @apm-js-collab/tracing-hooks for the CJS/ESM registration for tracing channel based instrumentation (#3324)
1 parent 2831a89 commit 4b2c14f

File tree

9 files changed

+272
-424
lines changed

9 files changed

+272
-424
lines changed

THIRD_PARTY_NOTICES.md

Lines changed: 219 additions & 8 deletions
Large diffs are not rendered by default.

esm-loader.mjs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@
55

66
// eslint-disable-next-line n/no-unsupported-features/node-builtins
77
import { register } from 'node:module'
8+
import subscriptions from './lib/subscriber-configs.js'
9+
import createSubscriberConfigs from './lib/subscribers/create-config.js'
810
// Exclusions must be regexes
911
const exclusions = [/@openai\/agents.*/]
12+
const { packages, instrumentations } = createSubscriberConfigs(subscriptions)
1013

11-
register('./esm-rewriter.mjs', import.meta.url)
14+
register('@apm-js-collab/tracing-hooks/hook.mjs', import.meta.url, {
15+
data: { instrumentations, packages }
16+
})
1217
register('import-in-the-middle/hook.mjs', import.meta.url, {
1318
data: { exclude: exclusions }
1419
})

esm-rewriter.mjs

Lines changed: 0 additions & 57 deletions
This file was deleted.

lib/patch-module.js

Lines changed: 0 additions & 70 deletions
This file was deleted.

lib/shimmer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const symbols = require('./symbols')
2525
const { unsubscribe } = require('./instrumentation/undici')
2626
const subscriptions = require('./subscriber-configs')
2727
const createSubscriberConfigs = require('./subscribers/create-config')
28-
const ModulePatch = require('./patch-module')
28+
const ModulePatch = require('@apm-js-collab/tracing-hooks')
2929

3030
/**
3131
* Unwrapping is only likely to be used by test code, and is a fairly drastic

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@
201201
"#test/assert": "./test/lib/custom-assertions/index.js"
202202
},
203203
"dependencies": {
204-
"@apm-js-collab/code-transformer": "^0.6.0",
204+
"@apm-js-collab/tracing-hooks": "^0.1.0",
205205
"@grpc/grpc-js": "^1.13.2",
206206
"@grpc/proto-loader": "^0.7.5",
207207
"@newrelic/security-agent": "^2.4.2",
@@ -272,8 +272,7 @@
272272
"self-cert": "^2.0.0",
273273
"should": "*",
274274
"sinon": "^5.1.1",
275-
"superagent": "^9.0.1",
276-
"testdouble": "^3.20.2"
275+
"superagent": "^9.0.1"
277276
},
278277
"repository": {
279278
"type": "git",

test/unit/esm-loader-rewriter.test.mjs

Lines changed: 0 additions & 161 deletions
This file was deleted.

0 commit comments

Comments
 (0)