-
Notifications
You must be signed in to change notification settings - Fork 398
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: tried to load agent in globalPreload and split out shimmer regis…
…trations
- Loading branch information
Showing
7 changed files
with
120 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
function preload() { | ||
require('./index') | ||
} | ||
module.exports = preload() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const pkgs = Object.create(null) | ||
function registerInstrumentation(opts) { | ||
if (!hasValidRegisterOptions(opts)) { | ||
return | ||
} | ||
|
||
const registeredInstrumentation = pkgs[opts.moduleName] | ||
|
||
if (!registeredInstrumentation) { | ||
pkgs[opts.moduleName] = [] | ||
} | ||
|
||
pkgs[opts.moduleName].push({ ...opts }) | ||
} | ||
|
||
function hasValidRegisterOptions(opts) { | ||
if (!opts) { | ||
//logger.warn('Instrumentation registration failed, no options provided') | ||
return false | ||
} | ||
|
||
if (!opts.moduleName) { | ||
//logger.warn(`Instrumentation registration failed, 'moduleName' not provided`) | ||
return false | ||
} | ||
|
||
if (!opts.onRequire && !opts.onResolved) { | ||
/*logger.warn( | ||
'Instrumentation registration for %s failed, no require hooks provided.', | ||
opts.moduleName | ||
) | ||
*/ | ||
|
||
return false | ||
} | ||
|
||
return true | ||
} | ||
|
||
|
||
module.exports = { | ||
pkgs, | ||
registerInstrumentation | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "logger-test-case", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "hello.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"express": "^4.18.2" | ||
} | ||
} |