newrelic 10.6.2 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NEWS.md +48 -0
- package/README.md +11 -23
- package/THIRD_PARTY_NOTICES.md +139 -64
- package/esm-loader.mjs +1 -225
- package/index.js +22 -4
- package/lib/config/default.js +0 -8
- package/lib/context-manager/create-context-manager.js +3 -17
- package/lib/feature_flags.js +3 -2
- package/lib/instrumentation/@prisma/client.js +23 -46
- package/lib/instrumentation/{amqplib.js → amqplib/amqplib.js} +0 -28
- package/lib/instrumentation/amqplib/nr-hooks.js +20 -0
- package/lib/instrumentation/core/async-hooks.js +1 -1
- package/lib/instrumentation/core/timers.js +2 -2
- package/lib/instrumentation/grpc-js/grpc.js +11 -15
- package/lib/instrumentation/grpc-js/nr-hooks.js +17 -5
- package/lib/instrumentation/pino/nr-hooks.js +3 -4
- package/lib/instrumentation/pino/pino.js +7 -20
- package/lib/instrumentations.js +1 -1
- package/lib/metrics/names.js +1 -2
- package/lib/shim/message-shim.js +1 -1
- package/lib/shim/transaction-shim.js +4 -4
- package/lib/shimmer.js +62 -163
- package/package.json +14 -16
- package/lib/context-manager/diagnostics/legacy-diagnostic-context-manager.js +0 -36
- package/lib/esm-shim.mjs +0 -36
package/lib/shimmer.js
CHANGED
|
@@ -12,6 +12,9 @@ const logger = require('./logger').child({ component: 'shimmer' })
|
|
|
12
12
|
const INSTRUMENTATIONS = require('./instrumentations')()
|
|
13
13
|
const properties = require('./util/properties')
|
|
14
14
|
const shims = require('./shim')
|
|
15
|
+
const { Hook } = require('require-in-the-middle')
|
|
16
|
+
const IitmHook = require('import-in-the-middle')
|
|
17
|
+
let pkgsToHook = []
|
|
15
18
|
|
|
16
19
|
const NAMES = require('./metrics/names')
|
|
17
20
|
const symbols = require('./symbols')
|
|
@@ -65,13 +68,6 @@ const CORE_INSTRUMENTATION = {
|
|
|
65
68
|
}
|
|
66
69
|
}
|
|
67
70
|
|
|
68
|
-
const FORCE_MODULE_RESOLUTION_WARNING =
|
|
69
|
-
'Unable to retrieve cached path for one or more modules ' +
|
|
70
|
-
'with an already loaded parent. Forcing resolution. ' +
|
|
71
|
-
'This should not occur during normal agent execution. ' +
|
|
72
|
-
'Module resolution performance my be impacted. ' +
|
|
73
|
-
'See trace-level logs for specific modules.'
|
|
74
|
-
|
|
75
71
|
/**
|
|
76
72
|
* Unwrapping is only likely to be used by test code, and is a fairly drastic
|
|
77
73
|
* maneuver, but it should be pretty safe if there's a desire to reboot the
|
|
@@ -279,79 +275,6 @@ const shimmer = (module.exports = {
|
|
|
279
275
|
instrumented = []
|
|
280
276
|
},
|
|
281
277
|
|
|
282
|
-
/**
|
|
283
|
-
* Patch the module.load function so that we see modules loading and
|
|
284
|
-
* have an opportunity to patch them with instrumentation.
|
|
285
|
-
*
|
|
286
|
-
* @param agent
|
|
287
|
-
*/
|
|
288
|
-
patchModule: function patchModule(agent) {
|
|
289
|
-
logger.trace('Wrapping module loader.')
|
|
290
|
-
const Module = require('module')
|
|
291
|
-
const filepathMap = {}
|
|
292
|
-
|
|
293
|
-
shimmer.wrapMethod(Module, 'Module', '_resolveFilename', function wrapRes(resolve) {
|
|
294
|
-
return function wrappedResolveFilename(file) {
|
|
295
|
-
// This is triggered by the load call, so record the path that has been seen so
|
|
296
|
-
// we can examine it after the load call has returned.
|
|
297
|
-
const resolvedFilepath = resolve.apply(this, arguments)
|
|
298
|
-
|
|
299
|
-
// Only fire the first time we see a specific module resolved
|
|
300
|
-
if (filepathMap[file] !== resolvedFilepath) {
|
|
301
|
-
filepathMap[file] = resolvedFilepath
|
|
302
|
-
|
|
303
|
-
_onResolveFileName(agent, file, resolvedFilepath)
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
return resolvedFilepath
|
|
307
|
-
}
|
|
308
|
-
})
|
|
309
|
-
|
|
310
|
-
shimmer.wrapMethod(Module, 'Module', '_load', function wrapLoad(load) {
|
|
311
|
-
return function wrappedLoad(request, parent, isMain) {
|
|
312
|
-
// _load() will invoke _resolveFilename() first time resolving a module.
|
|
313
|
-
const m = load.apply(this, arguments)
|
|
314
|
-
|
|
315
|
-
const fileName = resolveFileName(request, parent, isMain)
|
|
316
|
-
return _postLoad(agent, m, request, fileName)
|
|
317
|
-
}
|
|
318
|
-
})
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* Forces file name resolve for modules not in our cache when
|
|
322
|
-
* their parent has already been loaded/cached by Node.
|
|
323
|
-
* Provides a fall-back for unexpected cases that may occur.
|
|
324
|
-
* Also provides flexibility for testing now that node 11+ caches these.
|
|
325
|
-
*
|
|
326
|
-
* @param {*} request
|
|
327
|
-
* @param {*} parent
|
|
328
|
-
* @param {*} isMain
|
|
329
|
-
*/
|
|
330
|
-
function resolveFileName(request, parent, isMain) {
|
|
331
|
-
const cachedPath = filepathMap[request]
|
|
332
|
-
if (!cachedPath && parent && parent.loaded) {
|
|
333
|
-
logger.warnOnce('Force Resolution', FORCE_MODULE_RESOLUTION_WARNING)
|
|
334
|
-
|
|
335
|
-
if (logger.traceEnabled()) {
|
|
336
|
-
logger.trace(`No cached path found for ${request}. Forcing resolution.`)
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
// Our patched _resolveFilename will cache. No need to here.
|
|
340
|
-
return Module._resolveFilename(request, parent, isMain)
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
return cachedPath
|
|
344
|
-
}
|
|
345
|
-
},
|
|
346
|
-
|
|
347
|
-
unpatchModule: function unpatchModule() {
|
|
348
|
-
logger.trace('Unwrapping to previous module loader.')
|
|
349
|
-
const Module = require('module')
|
|
350
|
-
|
|
351
|
-
shimmer.unwrapMethod(Module, 'Module', '_resolveFilename')
|
|
352
|
-
shimmer.unwrapMethod(Module, 'Module', '_load')
|
|
353
|
-
},
|
|
354
|
-
|
|
355
278
|
/**
|
|
356
279
|
* Registers all instrumentation for 3rd party libraries.
|
|
357
280
|
*
|
|
@@ -372,9 +295,6 @@ const shimmer = (module.exports = {
|
|
|
372
295
|
logger.warn('Failed to load instrumentation for ' + instrInfo.module, e)
|
|
373
296
|
return
|
|
374
297
|
}
|
|
375
|
-
} else if (moduleName === 'amqplib') {
|
|
376
|
-
// TODO: Remove this code when amqplib instrumentation is made external.
|
|
377
|
-
require('./instrumentation/amqplib').selfRegister(shimmer)
|
|
378
298
|
} else {
|
|
379
299
|
const fileName = path.join(__dirname, 'instrumentation', moduleName + '.js')
|
|
380
300
|
shimmer.registerInstrumentation({
|
|
@@ -404,7 +324,7 @@ const shimmer = (module.exports = {
|
|
|
404
324
|
registerCoreInstrumentation(agent) {
|
|
405
325
|
// Instrument global.
|
|
406
326
|
const globalShim = new shims.Shim(agent, 'globals', 'globals')
|
|
407
|
-
applyDebugState(globalShim, global)
|
|
327
|
+
applyDebugState(globalShim, global, false)
|
|
408
328
|
const globalsFilepath = path.join(__dirname, 'instrumentation', 'core', 'globals.js')
|
|
409
329
|
_firstPartyInstrumentation(agent, globalsFilepath, globalShim, global, 'globals')
|
|
410
330
|
|
|
@@ -420,10 +340,39 @@ const shimmer = (module.exports = {
|
|
|
420
340
|
}
|
|
421
341
|
|
|
422
342
|
const shim = shims.createShimFromType(core.type, agent, mojule, mojule)
|
|
423
|
-
applyDebugState(shim, core)
|
|
343
|
+
applyDebugState(shim, core, false)
|
|
424
344
|
_firstPartyInstrumentation(agent, filePath, shim, uninstrumented, mojule)
|
|
425
345
|
}
|
|
426
346
|
},
|
|
347
|
+
// TODO: remove the following methods once test-utilities have been updated and released
|
|
348
|
+
// with the new registerHooks and removeHooks methods
|
|
349
|
+
patchModule(agent) {
|
|
350
|
+
shimmer.registerHooks(agent)
|
|
351
|
+
},
|
|
352
|
+
unpatchModule() {
|
|
353
|
+
shimmer.removeHooks()
|
|
354
|
+
},
|
|
355
|
+
registerHooks(agent) {
|
|
356
|
+
this._ritm = new Hook(pkgsToHook, function onHook(exports, name, basedir) {
|
|
357
|
+
return _postLoad(agent, exports, name, basedir)
|
|
358
|
+
})
|
|
359
|
+
this._iitm = new IitmHook(pkgsToHook, function onESMHook(exports, name, basedir) {
|
|
360
|
+
return _postLoad(agent, exports, name, basedir, true)
|
|
361
|
+
})
|
|
362
|
+
},
|
|
363
|
+
removeHooks() {
|
|
364
|
+
if (this._ritm) {
|
|
365
|
+
this._ritm.unhook()
|
|
366
|
+
this._ritm = null
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
if (this._iitm) {
|
|
370
|
+
this._iitm.unhook()
|
|
371
|
+
this._iitm = null
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
pkgsToHook = []
|
|
375
|
+
},
|
|
427
376
|
|
|
428
377
|
bootstrapInstrumentation: function bootstrapInstrumentation(agent) {
|
|
429
378
|
shimmer.registerCoreInstrumentation(agent)
|
|
@@ -439,6 +388,12 @@ const shimmer = (module.exports = {
|
|
|
439
388
|
|
|
440
389
|
if (!registeredInstrumentation) {
|
|
441
390
|
shimmer.registeredInstrumentations[opts.moduleName] = []
|
|
391
|
+
// not using a set because this is shared by reference
|
|
392
|
+
// to allow custom instrumentation to be loaded after the
|
|
393
|
+
// agent is bootstrapped
|
|
394
|
+
if (!pkgsToHook.includes(opts.moduleName)) {
|
|
395
|
+
pkgsToHook.push(opts.moduleName)
|
|
396
|
+
}
|
|
442
397
|
}
|
|
443
398
|
|
|
444
399
|
shimmer.registeredInstrumentations[opts.moduleName].push({ ...opts })
|
|
@@ -511,16 +466,18 @@ const shimmer = (module.exports = {
|
|
|
511
466
|
}
|
|
512
467
|
})
|
|
513
468
|
|
|
514
|
-
function applyDebugState(shim, nodule) {
|
|
469
|
+
function applyDebugState(shim, nodule, inEsm) {
|
|
515
470
|
if (shimmer.debug) {
|
|
516
471
|
shim.enableDebug()
|
|
517
472
|
instrumented.push(shim)
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
473
|
+
if (!inEsm) {
|
|
474
|
+
instrumented.push({
|
|
475
|
+
[symbols.unwrap]: function unwrapNodule() {
|
|
476
|
+
delete nodule[symbols.shim]
|
|
477
|
+
}
|
|
478
|
+
})
|
|
479
|
+
nodule[symbols.shim] = shim
|
|
480
|
+
}
|
|
524
481
|
}
|
|
525
482
|
}
|
|
526
483
|
|
|
@@ -533,8 +490,9 @@ function applyDebugState(shim, nodule) {
|
|
|
533
490
|
* @param nodule
|
|
534
491
|
* @param moduleName
|
|
535
492
|
* @param resolvedName
|
|
493
|
+
* @param esmResolver
|
|
536
494
|
*/
|
|
537
|
-
function instrumentPostLoad(agent, nodule, moduleName, resolvedName) {
|
|
495
|
+
function instrumentPostLoad(agent, nodule, moduleName, resolvedName, esmResolver) {
|
|
538
496
|
const instrumentations = shimmer.registeredInstrumentations[moduleName]
|
|
539
497
|
instrumentations.forEach((instrumentation) => {
|
|
540
498
|
if (
|
|
@@ -548,6 +506,10 @@ function instrumentPostLoad(agent, nodule, moduleName, resolvedName) {
|
|
|
548
506
|
return
|
|
549
507
|
}
|
|
550
508
|
|
|
509
|
+
// We only return the .default when we're a CJS module in the import-in-the-middle(ESM)
|
|
510
|
+
// callback hook
|
|
511
|
+
const resolvedNodule = instrumentation.isEsm || !esmResolver ? nodule : nodule.default
|
|
512
|
+
|
|
551
513
|
const shim = shims.createShimFromType(
|
|
552
514
|
instrumentation.type,
|
|
553
515
|
agent,
|
|
@@ -556,7 +518,7 @@ function instrumentPostLoad(agent, nodule, moduleName, resolvedName) {
|
|
|
556
518
|
instrumentation.shimName
|
|
557
519
|
)
|
|
558
520
|
|
|
559
|
-
applyDebugState(shim,
|
|
521
|
+
applyDebugState(shim, resolvedNodule, esmResolver)
|
|
560
522
|
trackInstrumentationUsage(
|
|
561
523
|
agent,
|
|
562
524
|
shim,
|
|
@@ -573,7 +535,7 @@ function instrumentPostLoad(agent, nodule, moduleName, resolvedName) {
|
|
|
573
535
|
}
|
|
574
536
|
|
|
575
537
|
try {
|
|
576
|
-
if (instrumentation.onRequire(shim,
|
|
538
|
+
if (instrumentation.onRequire(shim, resolvedNodule, moduleName) !== false) {
|
|
577
539
|
nodule = shim.getExport(nodule)
|
|
578
540
|
instrumentation[symbols.instrumented] = true
|
|
579
541
|
}
|
|
@@ -621,7 +583,7 @@ function _firstPartyInstrumentation(agent, fileName, shim, nodule, moduleName) {
|
|
|
621
583
|
}
|
|
622
584
|
}
|
|
623
585
|
|
|
624
|
-
function _postLoad(agent, nodule, name, resolvedName) {
|
|
586
|
+
function _postLoad(agent, nodule, name, resolvedName, esmResolver) {
|
|
625
587
|
const instrumentation = shimmer.getInstrumentationNameFromModuleName(name)
|
|
626
588
|
const registeredInstrumentation = shimmer.registeredInstrumentations[instrumentation]
|
|
627
589
|
const hasPostLoadInstrumentation =
|
|
@@ -632,76 +594,12 @@ function _postLoad(agent, nodule, name, resolvedName) {
|
|
|
632
594
|
// Check if this is a known instrumentation and then run it.
|
|
633
595
|
if (hasPostLoadInstrumentation) {
|
|
634
596
|
logger.trace('Instrumenting %s with onRequire (module loaded) hook.', name)
|
|
635
|
-
return instrumentPostLoad(agent, nodule, instrumentation, resolvedName)
|
|
597
|
+
return instrumentPostLoad(agent, nodule, instrumentation, resolvedName, esmResolver)
|
|
636
598
|
}
|
|
637
599
|
|
|
638
600
|
return nodule
|
|
639
601
|
}
|
|
640
602
|
|
|
641
|
-
function _onResolveFileName(agent, requiredNameOrPath, resolvedFilepath) {
|
|
642
|
-
const instrumentation = shimmer.getInstrumentationNameFromModuleName(requiredNameOrPath)
|
|
643
|
-
const registeredInstrumentation = shimmer.registeredInstrumentations[instrumentation]
|
|
644
|
-
const hasResolvedFileInstrumentation =
|
|
645
|
-
registeredInstrumentation &&
|
|
646
|
-
registeredInstrumentation.length &&
|
|
647
|
-
registeredInstrumentation.filter((instrumentation) => instrumentation.onResolved).length
|
|
648
|
-
|
|
649
|
-
// Check if this is a known instrumentation and then run it.
|
|
650
|
-
if (hasResolvedFileInstrumentation) {
|
|
651
|
-
logger.trace('Instrumenting %s with onResolved hook.', requiredNameOrPath)
|
|
652
|
-
_instrumentOnResolved(agent, instrumentation, resolvedFilepath)
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
/**
|
|
657
|
-
* Invokes the onResolved handler with a shim instance.
|
|
658
|
-
*
|
|
659
|
-
* Given Node.js caches resolvedFilePaths in versions we support and we cache as well
|
|
660
|
-
* for the cases we force resolution, we should not run into the case of multiple
|
|
661
|
-
* invocations for the same module. As such, this function does not defend against multiple runs.
|
|
662
|
-
*
|
|
663
|
-
* @param agent
|
|
664
|
-
* @param moduleName
|
|
665
|
-
* @param resolvedFilepath
|
|
666
|
-
*/
|
|
667
|
-
function _instrumentOnResolved(agent, moduleName, resolvedFilepath) {
|
|
668
|
-
const instrumentations = shimmer.registeredInstrumentations[moduleName]
|
|
669
|
-
instrumentations.forEach((instrumentation) => {
|
|
670
|
-
const shim = shims.createShimFromType(instrumentation.type, agent, moduleName, resolvedFilepath)
|
|
671
|
-
|
|
672
|
-
trackInstrumentationUsage(
|
|
673
|
-
agent,
|
|
674
|
-
shim,
|
|
675
|
-
instrumentation.specifier || moduleName,
|
|
676
|
-
NAMES.FEATURES.INSTRUMENTATION.ON_RESOLVED
|
|
677
|
-
)
|
|
678
|
-
|
|
679
|
-
try {
|
|
680
|
-
instrumentation.onResolved(shim, moduleName, resolvedFilepath)
|
|
681
|
-
} catch (instrumentationError) {
|
|
682
|
-
if (instrumentation.onError) {
|
|
683
|
-
try {
|
|
684
|
-
instrumentation.onError(instrumentationError)
|
|
685
|
-
} catch (error) {
|
|
686
|
-
logger.warn(
|
|
687
|
-
error,
|
|
688
|
-
instrumentationError,
|
|
689
|
-
'OnResolved instrumentation for %s failed, then the onError handler threw an error',
|
|
690
|
-
moduleName
|
|
691
|
-
)
|
|
692
|
-
}
|
|
693
|
-
} else {
|
|
694
|
-
logger.warn(
|
|
695
|
-
instrumentationError,
|
|
696
|
-
'OnResolved instrumentation for %s failed. Please report this to the ' +
|
|
697
|
-
'maintainers of the custom instrumentation.',
|
|
698
|
-
moduleName
|
|
699
|
-
)
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
})
|
|
703
|
-
}
|
|
704
|
-
|
|
705
603
|
function hasValidRegisterOptions(opts) {
|
|
706
604
|
if (!opts) {
|
|
707
605
|
logger.warn('Instrumentation registration failed, no options provided')
|
|
@@ -713,7 +611,7 @@ function hasValidRegisterOptions(opts) {
|
|
|
713
611
|
return false
|
|
714
612
|
}
|
|
715
613
|
|
|
716
|
-
if (!opts.onRequire
|
|
614
|
+
if (!opts.onRequire) {
|
|
717
615
|
logger.warn(
|
|
718
616
|
'Instrumentation registration for %s failed, no require hooks provided.',
|
|
719
617
|
opts.moduleName
|
|
@@ -732,7 +630,8 @@ function hasValidRegisterOptions(opts) {
|
|
|
732
630
|
* @param {*} agent The agent instance.
|
|
733
631
|
* @param {*} shim The instance of the shim used to instrument the module.
|
|
734
632
|
* @param {string} moduleName The name of the required module.
|
|
735
|
-
* @param {string} metricPrefix Support metric prefix to prepend to the metrics. Will indicate onRequire
|
|
633
|
+
* @param {string} metricPrefix Support metric prefix to prepend to the metrics. Will indicate onRequire
|
|
634
|
+
*
|
|
736
635
|
* from NAMES.FEATURES.INSTRUMENTATION.
|
|
737
636
|
*/
|
|
738
637
|
function trackInstrumentationUsage(agent, shim, moduleName, metricPrefix) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "newrelic",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"author": "New Relic Node.js agent team <nodejs@newrelic.com>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"contributors": [
|
|
@@ -136,7 +136,7 @@
|
|
|
136
136
|
],
|
|
137
137
|
"homepage": "https://github.com/newrelic/node-newrelic",
|
|
138
138
|
"engines": {
|
|
139
|
-
"node": ">=
|
|
139
|
+
"node": ">=16",
|
|
140
140
|
"npm": ">=6.0.0"
|
|
141
141
|
},
|
|
142
142
|
"directories": {
|
|
@@ -146,8 +146,7 @@
|
|
|
146
146
|
"bench": "node ./bin/run-bench.js",
|
|
147
147
|
"docker-env": "./bin/docker-env-vars.sh",
|
|
148
148
|
"docs": "npm ci && jsdoc -c ./jsdoc-conf.json --private -r .",
|
|
149
|
-
"integration": "npm run prepare-test && npm run sub-install && time c8 -o ./coverage/integration tap --test-regex='(\\/|^test\\/integration\\/.*\\.tap\\.js)$' --timeout=
|
|
150
|
-
"integration:async-local": "npm run prepare-test && npm run sub-install && time c8 -o ./coverage/integration-async-local tap --test-regex='(\\/|^test\\/integration\\/.*\\.tap\\.js)$' --timeout=360 --no-coverage --reporter classic --test-env=NEW_RELIC_FEATURE_FLAG_ASYNC_LOCAL_CONTEXT=1",
|
|
149
|
+
"integration": "npm run prepare-test && npm run sub-install && time c8 -o ./coverage/integration tap --test-regex='(\\/|^test\\/integration\\/.*\\.tap\\.js)$' --timeout=300 --no-coverage --reporter classic",
|
|
151
150
|
"prepare-test": "npm run ssl && npm run docker-env",
|
|
152
151
|
"lint": "eslint ./*.{js,mjs} lib test bin examples",
|
|
153
152
|
"lint:fix": "eslint --fix, ./*.{js,mjs} lib test bin examples",
|
|
@@ -158,20 +157,18 @@
|
|
|
158
157
|
"smoke": "npm run ssl && time tap test/smoke/**/**/*.tap.js --timeout=180 --no-coverage",
|
|
159
158
|
"ssl": "./bin/ssl.sh",
|
|
160
159
|
"sub-install": "node test/bin/install_sub_deps",
|
|
161
|
-
"test": "npm run integration && npm run unit
|
|
160
|
+
"test": "npm run integration && npm run unit",
|
|
162
161
|
"third-party-updates": "oss third-party manifest --includeOptDeps && oss third-party notices --includeOptDeps && git add THIRD_PARTY_NOTICES.md third_party_manifest.json",
|
|
163
162
|
"unit": "rm -f newrelic_agent.log && time c8 -o ./coverage/unit tap --test-regex='(\\/|^test\\/unit\\/.*\\.test\\.js)$' --timeout=180 --no-coverage --reporter classic",
|
|
164
163
|
"unit:scripts": "time c8 -o ./coverage/scripts-unit tap --test-regex='(\\/|^bin\\/test\\/.*\\.test\\.js)$' --timeout=180 --no-coverage --reporter classic",
|
|
165
|
-
"unit:async-local": "rm -f newrelic_agent.log && time tap --test-regex='(\\/|^test\\/unit\\/.*\\.test\\.js)$' --timeout=180 --no-coverage --reporter classic --test-env=NEW_RELIC_FEATURE_FLAG_ASYNC_LOCAL_CONTEXT=1",
|
|
166
|
-
"unit:esm": "rm -f newrelic_agent.log && time c8 -o ./coverage/esm-unit --include *.mjs --include **/*.mjs --exclude false tap --test-regex='(\\/|^test\\/unit\\/.*\\.test\\.mjs)$' --timeout=180 --no-coverage --reporter classic --node-arg=--experimental-loader=testdouble",
|
|
167
164
|
"update-cross-agent-tests": "./bin/update-cats.sh",
|
|
168
165
|
"versioned-tests": "./bin/run-versioned-tests.sh",
|
|
169
166
|
"update-changelog-version": "node ./bin/update-changelog-version",
|
|
170
167
|
"checkout-external-versioned": "node ./test/versioned-external/checkout-external-tests.js",
|
|
171
168
|
"versioned:major": "VERSIONED_MODE=--major npm run versioned",
|
|
172
169
|
"versioned": "npm run checkout-external-versioned && npm run prepare-test && NPM7=1 time ./bin/run-versioned-tests.sh",
|
|
173
|
-
"versioned:
|
|
174
|
-
"versioned:
|
|
170
|
+
"versioned:legacy-context": "NEW_RELIC_FEATURE_FLAG_LEGACY_CONTEXT_MANAGER=1 npm run versioned",
|
|
171
|
+
"versioned:legacy_context:major": "NEW_RELIC_FEATURE_FLAG_LEGACY_CONTEXT_MANAGER=1 npm run versioned:major",
|
|
175
172
|
"versioned:security": "NEW_RELIC_SECURITY_AGENT_ENABLED=true npm run versioned",
|
|
176
173
|
"versioned:security:major": "NEW_RELIC_SECURITY_AGENT_ENABLED=true npm run versioned:major",
|
|
177
174
|
"prepare": "husky install"
|
|
@@ -182,28 +179,30 @@
|
|
|
182
179
|
"dependencies": {
|
|
183
180
|
"@grpc/grpc-js": "^1.8.10",
|
|
184
181
|
"@grpc/proto-loader": "^0.7.5",
|
|
185
|
-
"@
|
|
186
|
-
"@newrelic/
|
|
187
|
-
"@newrelic/koa": "^7.1.1",
|
|
182
|
+
"@newrelic/aws-sdk": "^7.0.0",
|
|
183
|
+
"@newrelic/koa": "^8.0.0",
|
|
188
184
|
"@newrelic/security-agent": "0.2.1",
|
|
189
|
-
"@newrelic/superagent": "^
|
|
185
|
+
"@newrelic/superagent": "^7.0.0",
|
|
190
186
|
"@tyriar/fibonacci-heap": "^2.0.7",
|
|
191
187
|
"concat-stream": "^2.0.0",
|
|
192
188
|
"https-proxy-agent": "^7.0.1",
|
|
189
|
+
"import-in-the-middle": "^1.4.2",
|
|
193
190
|
"json-bigint": "^1.0.0",
|
|
194
191
|
"json-stringify-safe": "^5.0.0",
|
|
195
192
|
"readable-stream": "^3.6.1",
|
|
193
|
+
"require-in-the-middle": "^7.2.0",
|
|
196
194
|
"semver": "^7.5.2",
|
|
197
195
|
"winston-transport": "^4.5.0"
|
|
198
196
|
},
|
|
199
197
|
"optionalDependencies": {
|
|
200
198
|
"@contrast/fn-inspect": "^3.3.0",
|
|
201
|
-
"@newrelic/native-metrics": "^
|
|
199
|
+
"@newrelic/native-metrics": "^10.0.0",
|
|
200
|
+
"@prisma/prisma-fmt-wasm": "^4.17.0-16.27eb2449f178cd9fe1a4b892d732cc4795f75085"
|
|
202
201
|
},
|
|
203
202
|
"devDependencies": {
|
|
204
203
|
"@newrelic/eslint-config": "^0.3.0",
|
|
205
204
|
"@newrelic/newrelic-oss-cli": "^0.1.2",
|
|
206
|
-
"@newrelic/test-utilities": "^
|
|
205
|
+
"@newrelic/test-utilities": "^8.0.0",
|
|
207
206
|
"@octokit/rest": "^18.0.15",
|
|
208
207
|
"@slack/bolt": "^3.7.0",
|
|
209
208
|
"ajv": "^6.12.6",
|
|
@@ -242,7 +241,6 @@
|
|
|
242
241
|
"sinon": "^4.5.0",
|
|
243
242
|
"tap": "^16.3.4",
|
|
244
243
|
"temp": "^0.8.1",
|
|
245
|
-
"testdouble": "3.17.2",
|
|
246
244
|
"when": "*"
|
|
247
245
|
},
|
|
248
246
|
"repository": {
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2021 New Relic Corporation. All rights reserved.
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
'use strict'
|
|
7
|
-
|
|
8
|
-
const LegacyContextManager = require('../legacy-context-manager')
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Overrides setContext to add diagnostic logging around setting and removing
|
|
12
|
-
* from context. Currently just supports the segment.probe().
|
|
13
|
-
*
|
|
14
|
-
* Exists in own class to keep default context management as minimal/efficient as possible
|
|
15
|
-
* given we wrap pretty much every functions execution.
|
|
16
|
-
*/
|
|
17
|
-
class LegacyDiagnosticContextManager extends LegacyContextManager {
|
|
18
|
-
setContext(newContext) {
|
|
19
|
-
this._logDiagnostic(this._context, 'Removed from context')
|
|
20
|
-
|
|
21
|
-
this._context = newContext
|
|
22
|
-
|
|
23
|
-
this._logDiagnostic(newContext, 'Set in context')
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
_logDiagnostic(context, message) {
|
|
27
|
-
// This is to currently support diagnostic logging of segments which gets attached to
|
|
28
|
-
// transactions with a stack trace. All of this is output at once at the end of a transaction
|
|
29
|
-
// when enabled for clear tracing.
|
|
30
|
-
if (context && context.probe) {
|
|
31
|
-
context.probe(message)
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
module.exports = LegacyDiagnosticContextManager
|
package/lib/esm-shim.mjs
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2022 New Relic Corporation. All rights reserved.
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import shimmer from './shimmer.js'
|
|
7
|
-
import newrelic from '../index.js'
|
|
8
|
-
const { agent } = newrelic
|
|
9
|
-
|
|
10
|
-
export default function wrapModule(module, moduleName, resolvedPath) {
|
|
11
|
-
const proxiedProps = Object.assign(Object.create(null), module)
|
|
12
|
-
const proxiedModule = new Proxy(module, {
|
|
13
|
-
get: (target, key) => {
|
|
14
|
-
return proxiedProps[key] || target[key]
|
|
15
|
-
},
|
|
16
|
-
set: (target, key, val) => {
|
|
17
|
-
return (proxiedProps[key] = val)
|
|
18
|
-
},
|
|
19
|
-
/**
|
|
20
|
-
* This is normally not allowed.
|
|
21
|
-
* We have some things that define property, unsure if at the module level.
|
|
22
|
-
* Ideally, we can get away from doing this sort of thing at all in the future
|
|
23
|
-
* in a post AsyncLocalStorage world, etc.
|
|
24
|
-
* If we never do at the module level, perhaps we can not define this or defer upstream
|
|
25
|
-
*
|
|
26
|
-
* @param target
|
|
27
|
-
* @param key
|
|
28
|
-
* @param descriptor
|
|
29
|
-
*/
|
|
30
|
-
defineProperty: (target, key, descriptor) => {
|
|
31
|
-
return Object.defineProperty(proxiedProps, key, descriptor)
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
return shimmer.instrumentPostLoad(agent, proxiedModule, moduleName, resolvedPath, true)
|
|
36
|
-
}
|