@opentelemetry/instrumentation
Advanced tools
Comparing version 0.38.0 to 0.39.0
@@ -47,3 +47,3 @@ /* | ||
import { diag } from '@opentelemetry/api'; | ||
import * as RequireInTheMiddle from 'require-in-the-middle'; | ||
import { Hook } from 'require-in-the-middle'; | ||
/** | ||
@@ -190,5 +190,6 @@ * Base abstract class for instrumenting node plugins | ||
// `RequireInTheMiddleSingleton` does not support absolute paths. | ||
// For an absolute paths, we must create a separate instance of `RequireInTheMiddle`. | ||
// For an absolute paths, we must create a separate instance of the | ||
// require-in-the-middle `Hook`. | ||
var hook = path.isAbsolute(module_2.name) | ||
? RequireInTheMiddle([module_2.name], { internals: true }, onRequire) | ||
? new Hook([module_2.name], { internals: true }, onRequire) | ||
: this_1._requireInTheMiddleSingleton.register(module_2.name, onRequire); | ||
@@ -195,0 +196,0 @@ this_1._hooks.push(hook); |
@@ -1,5 +0,5 @@ | ||
import * as RequireInTheMiddle from 'require-in-the-middle'; | ||
import type { OnRequireFn } from 'require-in-the-middle'; | ||
export declare type Hooked = { | ||
moduleName: string; | ||
onRequire: RequireInTheMiddle.OnRequireFn; | ||
onRequire: OnRequireFn; | ||
}; | ||
@@ -24,6 +24,6 @@ /** | ||
* @param {string} moduleName Module name | ||
* @param {RequireInTheMiddle.OnRequireFn} onRequire Hook function | ||
* @param {OnRequireFn} onRequire Hook function | ||
* @returns {Hooked} Registered hook | ||
*/ | ||
register(moduleName: string, onRequire: RequireInTheMiddle.OnRequireFn): Hooked; | ||
register(moduleName: string, onRequire: OnRequireFn): Hooked; | ||
/** | ||
@@ -30,0 +30,0 @@ * Get the `RequireInTheMiddleSingleton` singleton |
@@ -27,3 +27,3 @@ /* | ||
}; | ||
import * as RequireInTheMiddle from 'require-in-the-middle'; | ||
import { Hook } from 'require-in-the-middle'; | ||
import * as path from 'path'; | ||
@@ -64,3 +64,3 @@ import { ModuleNameTrie, ModuleNameSeparator } from './ModuleNameTrie'; | ||
var _this = this; | ||
RequireInTheMiddle( | ||
new Hook( | ||
// Intercept all `require` calls; we will filter the matching ones below | ||
@@ -98,3 +98,3 @@ null, { internals: true }, function (exports, name, basedir) { | ||
* @param {string} moduleName Module name | ||
* @param {RequireInTheMiddle.OnRequireFn} onRequire Hook function | ||
* @param {OnRequireFn} onRequire Hook function | ||
* @returns {Hooked} Registered hook | ||
@@ -101,0 +101,0 @@ */ |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "0.38.0"; | ||
export declare const VERSION = "0.39.0"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -17,3 +17,3 @@ /* | ||
// this is autogenerated file, see scripts/version-update.js | ||
export var VERSION = '0.38.0'; | ||
export var VERSION = '0.39.0'; | ||
//# sourceMappingURL=version.js.map |
@@ -21,3 +21,3 @@ /* | ||
import { diag } from '@opentelemetry/api'; | ||
import * as RequireInTheMiddle from 'require-in-the-middle'; | ||
import { Hook } from 'require-in-the-middle'; | ||
/** | ||
@@ -135,5 +135,6 @@ * Base abstract class for instrumenting node plugins | ||
// `RequireInTheMiddleSingleton` does not support absolute paths. | ||
// For an absolute paths, we must create a separate instance of `RequireInTheMiddle`. | ||
// For an absolute paths, we must create a separate instance of the | ||
// require-in-the-middle `Hook`. | ||
const hook = path.isAbsolute(module.name) | ||
? RequireInTheMiddle([module.name], { internals: true }, onRequire) | ||
? new Hook([module.name], { internals: true }, onRequire) | ||
: this._requireInTheMiddleSingleton.register(module.name, onRequire); | ||
@@ -140,0 +141,0 @@ this._hooks.push(hook); |
@@ -1,5 +0,5 @@ | ||
import * as RequireInTheMiddle from 'require-in-the-middle'; | ||
import type { OnRequireFn } from 'require-in-the-middle'; | ||
export declare type Hooked = { | ||
moduleName: string; | ||
onRequire: RequireInTheMiddle.OnRequireFn; | ||
onRequire: OnRequireFn; | ||
}; | ||
@@ -24,6 +24,6 @@ /** | ||
* @param {string} moduleName Module name | ||
* @param {RequireInTheMiddle.OnRequireFn} onRequire Hook function | ||
* @param {OnRequireFn} onRequire Hook function | ||
* @returns {Hooked} Registered hook | ||
*/ | ||
register(moduleName: string, onRequire: RequireInTheMiddle.OnRequireFn): Hooked; | ||
register(moduleName: string, onRequire: OnRequireFn): Hooked; | ||
/** | ||
@@ -30,0 +30,0 @@ * Get the `RequireInTheMiddleSingleton` singleton |
@@ -16,3 +16,3 @@ /* | ||
*/ | ||
import * as RequireInTheMiddle from 'require-in-the-middle'; | ||
import { Hook } from 'require-in-the-middle'; | ||
import * as path from 'path'; | ||
@@ -52,3 +52,3 @@ import { ModuleNameTrie, ModuleNameSeparator } from './ModuleNameTrie'; | ||
_initialize() { | ||
RequireInTheMiddle( | ||
new Hook( | ||
// Intercept all `require` calls; we will filter the matching ones below | ||
@@ -75,3 +75,3 @@ null, { internals: true }, (exports, name, basedir) => { | ||
* @param {string} moduleName Module name | ||
* @param {RequireInTheMiddle.OnRequireFn} onRequire Hook function | ||
* @param {OnRequireFn} onRequire Hook function | ||
* @returns {Hooked} Registered hook | ||
@@ -78,0 +78,0 @@ */ |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "0.38.0"; | ||
export declare const VERSION = "0.39.0"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -17,3 +17,3 @@ /* | ||
// this is autogenerated file, see scripts/version-update.js | ||
export const VERSION = '0.38.0'; | ||
export const VERSION = '0.39.0'; | ||
//# sourceMappingURL=version.js.map |
@@ -24,3 +24,3 @@ "use strict"; | ||
const api_1 = require("@opentelemetry/api"); | ||
const RequireInTheMiddle = require("require-in-the-middle"); | ||
const require_in_the_middle_1 = require("require-in-the-middle"); | ||
/** | ||
@@ -138,5 +138,6 @@ * Base abstract class for instrumenting node plugins | ||
// `RequireInTheMiddleSingleton` does not support absolute paths. | ||
// For an absolute paths, we must create a separate instance of `RequireInTheMiddle`. | ||
// For an absolute paths, we must create a separate instance of the | ||
// require-in-the-middle `Hook`. | ||
const hook = path.isAbsolute(module.name) | ||
? RequireInTheMiddle([module.name], { internals: true }, onRequire) | ||
? new require_in_the_middle_1.Hook([module.name], { internals: true }, onRequire) | ||
: this._requireInTheMiddleSingleton.register(module.name, onRequire); | ||
@@ -143,0 +144,0 @@ this._hooks.push(hook); |
@@ -1,5 +0,5 @@ | ||
import * as RequireInTheMiddle from 'require-in-the-middle'; | ||
import type { OnRequireFn } from 'require-in-the-middle'; | ||
export declare type Hooked = { | ||
moduleName: string; | ||
onRequire: RequireInTheMiddle.OnRequireFn; | ||
onRequire: OnRequireFn; | ||
}; | ||
@@ -24,6 +24,6 @@ /** | ||
* @param {string} moduleName Module name | ||
* @param {RequireInTheMiddle.OnRequireFn} onRequire Hook function | ||
* @param {OnRequireFn} onRequire Hook function | ||
* @returns {Hooked} Registered hook | ||
*/ | ||
register(moduleName: string, onRequire: RequireInTheMiddle.OnRequireFn): Hooked; | ||
register(moduleName: string, onRequire: OnRequireFn): Hooked; | ||
/** | ||
@@ -30,0 +30,0 @@ * Get the `RequireInTheMiddleSingleton` singleton |
@@ -19,3 +19,3 @@ "use strict"; | ||
exports.RequireInTheMiddleSingleton = void 0; | ||
const RequireInTheMiddle = require("require-in-the-middle"); | ||
const require_in_the_middle_1 = require("require-in-the-middle"); | ||
const path = require("path"); | ||
@@ -55,3 +55,3 @@ const ModuleNameTrie_1 = require("./ModuleNameTrie"); | ||
_initialize() { | ||
RequireInTheMiddle( | ||
new require_in_the_middle_1.Hook( | ||
// Intercept all `require` calls; we will filter the matching ones below | ||
@@ -78,3 +78,3 @@ null, { internals: true }, (exports, name, basedir) => { | ||
* @param {string} moduleName Module name | ||
* @param {RequireInTheMiddle.OnRequireFn} onRequire Hook function | ||
* @param {OnRequireFn} onRequire Hook function | ||
* @returns {Hooked} Registered hook | ||
@@ -81,0 +81,0 @@ */ |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "0.38.0"; | ||
export declare const VERSION = "0.39.0"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -20,3 +20,3 @@ "use strict"; | ||
// this is autogenerated file, see scripts/version-update.js | ||
exports.VERSION = '0.38.0'; | ||
exports.VERSION = '0.39.0'; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@opentelemetry/instrumentation", | ||
"version": "0.38.0", | ||
"version": "0.39.0", | ||
"description": "Base class for node which OpenTelemetry instrumentation modules extend", | ||
@@ -71,3 +71,3 @@ "author": "OpenTelemetry Authors", | ||
"dependencies": { | ||
"require-in-the-middle": "^6.0.0", | ||
"require-in-the-middle": "^7.1.0", | ||
"semver": "^7.3.2", | ||
@@ -82,3 +82,3 @@ "shimmer": "^1.2.1" | ||
"@opentelemetry/api": "1.4.1", | ||
"@opentelemetry/sdk-metrics": "1.12.0", | ||
"@opentelemetry/sdk-metrics": "1.13.0", | ||
"@types/mocha": "10.0.0", | ||
@@ -102,3 +102,2 @@ "@types/node": "18.6.5", | ||
"nyc": "15.1.0", | ||
"rimraf": "4.1.2", | ||
"sinon": "15.0.0", | ||
@@ -116,3 +115,3 @@ "ts-loader": "8.4.0", | ||
"sideEffects": false, | ||
"gitHead": "a04090010ee18e17487b449984807cc2b7b6e3e6" | ||
"gitHead": "8fc76896595aac912bf9e15d4f19c167317844c8" | ||
} |
@@ -26,5 +26,5 @@ # OpenTelemetry Instrumentation for web and node | ||
export class MyPlugin extends InstrumentationBase { | ||
export class MyInstrumentation extends InstrumentationBase { | ||
constructor(config: InstrumentationConfig = {}) { | ||
super('MyPlugin', VERSION, config); | ||
super('MyInstrumentation', VERSION, config); | ||
} | ||
@@ -110,8 +110,8 @@ | ||
// Later | ||
// Later, but before the module to instrument is required | ||
const myPLugin = new MyPlugin(); | ||
myPLugin.setTracerProvider(provider); // this is optional, only if global TracerProvider shouldn't be used | ||
myPLugin.setMeterProvider(meterProvider); // this is optional | ||
myPLugin.enable(); | ||
const myInstrumentationn = new MyInstrumentation(); | ||
myInstrumentation.setTracerProvider(provider); // this is optional, only if global TracerProvider shouldn't be used | ||
myInstrumentation.setMeterProvider(meterProvider); // this is optional | ||
myInstrumentation.enable(); | ||
// or use Auto Loader | ||
@@ -130,5 +130,5 @@ ``` | ||
export class MyPlugin extends InstrumentationBase { | ||
export class MyInstrumentation extends InstrumentationBase { | ||
constructor(config: InstrumentationConfig = {}) { | ||
super('MyPlugin', VERSION, config); | ||
super('MyInstrumentation', VERSION, config); | ||
} | ||
@@ -156,6 +156,6 @@ | ||
const myPLugin = new MyPlugin(); | ||
myPLugin.setTracerProvider(provider); // this is optional, only if global TracerProvider shouldn't be used | ||
myPLugin.setMeterProvider(meterProvider); // this is optional, only if global MeterProvider shouldn't be used | ||
myPLugin.enable(); | ||
const myInstrumentation = new MyInstrumentation(); | ||
myInstrumentation.setTracerProvider(provider); // this is optional, only if global TracerProvider shouldn't be used | ||
myInstrumentation.setMeterProvider(meterProvider); // this is optional, only if global MeterProvider shouldn't be used | ||
myInstrumentation.enable(); | ||
// or use Auto Loader | ||
@@ -166,46 +166,2 @@ ``` | ||
Successor of loading plugins through TracerProvider "plugins" option. | ||
It also supersedes PluginLoader for node. The old configurations usually looks like | ||
### NODE - old way using TracerProvider - not available anymore | ||
```javascript | ||
const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node'); | ||
const { B3Propagator } = require('@opentelemetry/propagator-b3'); | ||
const provider = new NodeTracerProvider({ | ||
plugins: { | ||
http: { enabled: false }, | ||
}, | ||
}); | ||
provider.register({ | ||
propagator: new B3Propagator(), | ||
}); | ||
``` | ||
### WEB - old way using TracerProvider - not available anymore | ||
```javascript | ||
const { WebTracerProvider } = require('@opentelemetry/sdk-trace-web'); | ||
const { UserInteractionPlugin } = require('@opentelemetry/plugin-user-interaction'); | ||
const { XMLHttpRequestInstrumentation } = require('@opentelemetry/instrumentation-xml-http-request'); | ||
const { B3Propagator } = require('@opentelemetry/propagator-b3'); | ||
const provider = new WebTracerProvider({ | ||
plugins: [ | ||
new UserInteractionPlugin(), | ||
new XMLHttpRequestInstrumentation({ | ||
ignoreUrls: [/localhost/], | ||
propagateTraceHeaderCorsUrls: [ | ||
'http://localhost:8090', | ||
], | ||
}), | ||
], | ||
}); | ||
provider.register({ | ||
propagator: new B3Propagator(), | ||
}); | ||
``` | ||
After change it will look like this - mixing plugins and instrumentations together | ||
All plugins will be bound to TracerProvider as well as instrumentations | ||
### NODE - Auto Loader | ||
@@ -271,2 +227,10 @@ | ||
## Limitations | ||
Instrumentations for external modules (e.g. express, mongodb,...) hooks the `require` call. Therefore following conditions need to be met that this mechanism can work: | ||
* `require` is used. ECMA script modules (using `import`) is not supported as of now | ||
* Instrumentations are registered **before** the module to instrument is `require`ed | ||
* modules are not included in a bundle. Tools like `esbuild`, `webpack`, ... usually have some mechanism to exclude specific modules from bundling | ||
## License | ||
@@ -278,4 +242,4 @@ | ||
- For more information on OpenTelemetry, visit: <https://opentelemetry.io/> | ||
- For help or feedback on this project, join us in [GitHub Discussions][discussions-url] | ||
* For more information on OpenTelemetry, visit: <https://opentelemetry.io/> | ||
* For help or feedback on this project, join us in [GitHub Discussions][discussions-url] | ||
@@ -282,0 +246,0 @@ [discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28
3790
343531
244
+ Addedrequire-in-the-middle@7.4.0(transitive)
- Removedrequire-in-the-middle@6.0.0(transitive)
Updatedrequire-in-the-middle@^7.1.0