Socket
Socket
Sign inDemoInstall

@opentelemetry/instrumentation

Package Overview
Dependencies
Maintainers
3
Versions
125
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/instrumentation - npm Package Compare versions

Comparing version 0.52.1 to 0.53.0

6

build/esm/index.d.ts

@@ -5,5 +5,5 @@ export { registerInstrumentations } from './autoLoader';

export { InstrumentationNodeModuleFile } from './instrumentationNodeModuleFile';
export * from './types';
export * from './types_internal';
export * from './utils';
export { Instrumentation, InstrumentationConfig, InstrumentationModuleDefinition, InstrumentationModuleFile, ShimWrapped, SpanCustomizationHook, } from './types';
export { AutoLoaderOptions, AutoLoaderResult } from './types_internal';
export { isWrapped, safeExecuteInTheMiddle, safeExecuteInTheMiddleAsync, } from './utils';
//# sourceMappingURL=index.d.ts.map

@@ -20,5 +20,3 @@ /*

export { InstrumentationNodeModuleFile } from './instrumentationNodeModuleFile';
export * from './types';
export * from './types_internal';
export * from './utils';
export { isWrapped, safeExecuteInTheMiddle, safeExecuteInTheMiddleAsync, } from './utils';
//# sourceMappingURL=index.js.map

@@ -48,3 +48,3 @@ import { DiagLogger, Meter, MeterProvider, Tracer, TracerProvider, Span } from '@opentelemetry/api';

* Sets InstrumentationConfig to this plugin
* @param InstrumentationConfig
* @param config
*/

@@ -51,0 +51,0 @@ setConfig(config: ConfigType): void;

@@ -37,2 +37,3 @@ /*

this.instrumentationVersion = instrumentationVersion;
this._config = {};
/* Api to wrap instrumented method */

@@ -46,5 +47,3 @@ this._wrap = shimmer.wrap;

this._massUnwrap = shimmer.massUnwrap;
// copy config first level properties to ensure they are immutable.
// nested properties are not copied, thus are mutable from the outside.
this._config = __assign({ enabled: true }, config);
this.setConfig(config);
this._diag = diag.createComponentLogger({

@@ -117,3 +116,3 @@ namespace: instrumentationName,

* Sets InstrumentationConfig to this plugin
* @param InstrumentationConfig
* @param config
*/

@@ -123,3 +122,3 @@ InstrumentationAbstract.prototype.setConfig = function (config) {

// nested properties are not copied, thus are mutable from the outside.
this._config = __assign({}, config);
this._config = __assign({ enabled: true }, config);
};

@@ -126,0 +125,0 @@ /**

@@ -72,5 +72,6 @@ /*

var wrapped = wrap(Object.assign({}, moduleExports), name, wrapper);
return Object.defineProperty(moduleExports, name, {
Object.defineProperty(moduleExports, name, {
value: wrapped,
});
return wrapped;
}

@@ -129,7 +130,2 @@ };

_this._modules = modules || [];
if (_this._modules.length === 0) {
diag.debug('No modules instrumentation has been defined for ' +
("'" + _this.instrumentationName + "@" + _this.instrumentationVersion + "'") +
', nothing will be patched');
}
if (_this._config.enabled) {

@@ -136,0 +132,0 @@ _this.enable();

@@ -9,8 +9,2 @@ import { TracerProvider, MeterProvider, Span } from '@opentelemetry/api';

instrumentationVersion: string;
/**
* Instrumentation Description - please describe all useful information
* as Instrumentation might patch different version of different modules,
* or support different browsers etc.
*/
instrumentationDescription?: string;
/** Method to disable the instrumentation */

@@ -101,5 +95,5 @@ disable(): void;

/** Method to patch the instrumentation */
patch?: (moduleExports: any, moduleVersion?: string) => any;
patch?: ((moduleExports: any, moduleVersion?: string | undefined) => any) | undefined;
/** Method to unpatch the instrumentation */
unpatch?: (moduleExports: any, moduleVersion?: string) => void;
unpatch?: ((moduleExports: any, moduleVersion?: string | undefined) => void) | undefined;
}

@@ -106,0 +100,0 @@ /**

@@ -1,2 +0,2 @@

export declare const VERSION = "0.52.1";
export declare const VERSION = "0.53.0";
//# sourceMappingURL=version.d.ts.map

@@ -17,3 +17,3 @@ /*

// this is autogenerated file, see scripts/version-update.js
export var VERSION = '0.52.1';
export var VERSION = '0.53.0';
//# sourceMappingURL=version.js.map

@@ -5,5 +5,5 @@ export { registerInstrumentations } from './autoLoader';

export { InstrumentationNodeModuleFile } from './instrumentationNodeModuleFile';
export * from './types';
export * from './types_internal';
export * from './utils';
export { Instrumentation, InstrumentationConfig, InstrumentationModuleDefinition, InstrumentationModuleFile, ShimWrapped, SpanCustomizationHook, } from './types';
export { AutoLoaderOptions, AutoLoaderResult } from './types_internal';
export { isWrapped, safeExecuteInTheMiddle, safeExecuteInTheMiddleAsync, } from './utils';
//# sourceMappingURL=index.d.ts.map

@@ -20,5 +20,3 @@ /*

export { InstrumentationNodeModuleFile } from './instrumentationNodeModuleFile';
export * from './types';
export * from './types_internal';
export * from './utils';
export { isWrapped, safeExecuteInTheMiddle, safeExecuteInTheMiddleAsync, } from './utils';
//# sourceMappingURL=index.js.map

@@ -48,3 +48,3 @@ import { DiagLogger, Meter, MeterProvider, Tracer, TracerProvider, Span } from '@opentelemetry/api';

* Sets InstrumentationConfig to this plugin
* @param InstrumentationConfig
* @param config
*/

@@ -51,0 +51,0 @@ setConfig(config: ConfigType): void;

@@ -26,2 +26,3 @@ /*

this.instrumentationVersion = instrumentationVersion;
this._config = {};
/* Api to wrap instrumented method */

@@ -35,5 +36,3 @@ this._wrap = shimmer.wrap;

this._massUnwrap = shimmer.massUnwrap;
// copy config first level properties to ensure they are immutable.
// nested properties are not copied, thus are mutable from the outside.
this._config = Object.assign({ enabled: true }, config);
this.setConfig(config);
this._diag = diag.createComponentLogger({

@@ -98,3 +97,3 @@ namespace: instrumentationName,

* Sets InstrumentationConfig to this plugin
* @param InstrumentationConfig
* @param config
*/

@@ -104,3 +103,3 @@ setConfig(config) {

// nested properties are not copied, thus are mutable from the outside.
this._config = Object.assign({}, config);
this._config = Object.assign({ enabled: true }, config);
}

@@ -107,0 +106,0 @@ /**

@@ -45,5 +45,6 @@ /*

const wrapped = wrap(Object.assign({}, moduleExports), name, wrapper);
return Object.defineProperty(moduleExports, name, {
Object.defineProperty(moduleExports, name, {
value: wrapped,
});
return wrapped;
}

@@ -102,7 +103,2 @@ };

this._modules = modules || [];
if (this._modules.length === 0) {
diag.debug('No modules instrumentation has been defined for ' +
`'${this.instrumentationName}@${this.instrumentationVersion}'` +
', nothing will be patched');
}
if (this._config.enabled) {

@@ -109,0 +105,0 @@ this.enable();

@@ -9,8 +9,2 @@ import { TracerProvider, MeterProvider, Span } from '@opentelemetry/api';

instrumentationVersion: string;
/**
* Instrumentation Description - please describe all useful information
* as Instrumentation might patch different version of different modules,
* or support different browsers etc.
*/
instrumentationDescription?: string;
/** Method to disable the instrumentation */

@@ -101,5 +95,5 @@ disable(): void;

/** Method to patch the instrumentation */
patch?: (moduleExports: any, moduleVersion?: string) => any;
patch?: ((moduleExports: any, moduleVersion?: string | undefined) => any) | undefined;
/** Method to unpatch the instrumentation */
unpatch?: (moduleExports: any, moduleVersion?: string) => void;
unpatch?: ((moduleExports: any, moduleVersion?: string | undefined) => void) | undefined;
}

@@ -106,0 +100,0 @@ /**

@@ -1,2 +0,2 @@

export declare const VERSION = "0.52.1";
export declare const VERSION = "0.53.0";
//# sourceMappingURL=version.d.ts.map

@@ -17,3 +17,3 @@ /*

// this is autogenerated file, see scripts/version-update.js
export const VERSION = '0.52.1';
export const VERSION = '0.53.0';
//# sourceMappingURL=version.js.map

@@ -5,5 +5,5 @@ export { registerInstrumentations } from './autoLoader';

export { InstrumentationNodeModuleFile } from './instrumentationNodeModuleFile';
export * from './types';
export * from './types_internal';
export * from './utils';
export { Instrumentation, InstrumentationConfig, InstrumentationModuleDefinition, InstrumentationModuleFile, ShimWrapped, SpanCustomizationHook, } from './types';
export { AutoLoaderOptions, AutoLoaderResult } from './types_internal';
export { isWrapped, safeExecuteInTheMiddle, safeExecuteInTheMiddleAsync, } from './utils';
//# sourceMappingURL=index.d.ts.map

@@ -17,14 +17,4 @@ "use strict";

*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.InstrumentationNodeModuleFile = exports.InstrumentationNodeModuleDefinition = exports.InstrumentationBase = exports.registerInstrumentations = void 0;
exports.safeExecuteInTheMiddleAsync = exports.safeExecuteInTheMiddle = exports.isWrapped = exports.InstrumentationNodeModuleFile = exports.InstrumentationNodeModuleDefinition = exports.InstrumentationBase = exports.registerInstrumentations = void 0;
var autoLoader_1 = require("./autoLoader");

@@ -38,5 +28,6 @@ Object.defineProperty(exports, "registerInstrumentations", { enumerable: true, get: function () { return autoLoader_1.registerInstrumentations; } });

Object.defineProperty(exports, "InstrumentationNodeModuleFile", { enumerable: true, get: function () { return instrumentationNodeModuleFile_1.InstrumentationNodeModuleFile; } });
__exportStar(require("./types"), exports);
__exportStar(require("./types_internal"), exports);
__exportStar(require("./utils"), exports);
var utils_1 = require("./utils");
Object.defineProperty(exports, "isWrapped", { enumerable: true, get: function () { return utils_1.isWrapped; } });
Object.defineProperty(exports, "safeExecuteInTheMiddle", { enumerable: true, get: function () { return utils_1.safeExecuteInTheMiddle; } });
Object.defineProperty(exports, "safeExecuteInTheMiddleAsync", { enumerable: true, get: function () { return utils_1.safeExecuteInTheMiddleAsync; } });
//# sourceMappingURL=index.js.map

@@ -48,3 +48,3 @@ import { DiagLogger, Meter, MeterProvider, Tracer, TracerProvider, Span } from '@opentelemetry/api';

* Sets InstrumentationConfig to this plugin
* @param InstrumentationConfig
* @param config
*/

@@ -51,0 +51,0 @@ setConfig(config: ConfigType): void;

@@ -29,2 +29,3 @@ "use strict";

this.instrumentationVersion = instrumentationVersion;
this._config = {};
/* Api to wrap instrumented method */

@@ -38,5 +39,3 @@ this._wrap = shimmer.wrap;

this._massUnwrap = shimmer.massUnwrap;
// copy config first level properties to ensure they are immutable.
// nested properties are not copied, thus are mutable from the outside.
this._config = Object.assign({ enabled: true }, config);
this.setConfig(config);
this._diag = api_1.diag.createComponentLogger({

@@ -101,3 +100,3 @@ namespace: instrumentationName,

* Sets InstrumentationConfig to this plugin
* @param InstrumentationConfig
* @param config
*/

@@ -107,3 +106,3 @@ setConfig(config) {

// nested properties are not copied, thus are mutable from the outside.
this._config = Object.assign({}, config);
this._config = Object.assign({ enabled: true }, config);
}

@@ -110,0 +109,0 @@ /**

@@ -48,5 +48,6 @@ "use strict";

const wrapped = (0, shimmer_1.wrap)(Object.assign({}, moduleExports), name, wrapper);
return Object.defineProperty(moduleExports, name, {
Object.defineProperty(moduleExports, name, {
value: wrapped,
});
return wrapped;
}

@@ -105,7 +106,2 @@ };

this._modules = modules || [];
if (this._modules.length === 0) {
api_1.diag.debug('No modules instrumentation has been defined for ' +
`'${this.instrumentationName}@${this.instrumentationVersion}'` +
', nothing will be patched');
}
if (this._config.enabled) {

@@ -112,0 +108,0 @@ this.enable();

@@ -9,8 +9,2 @@ import { TracerProvider, MeterProvider, Span } from '@opentelemetry/api';

instrumentationVersion: string;
/**
* Instrumentation Description - please describe all useful information
* as Instrumentation might patch different version of different modules,
* or support different browsers etc.
*/
instrumentationDescription?: string;
/** Method to disable the instrumentation */

@@ -101,5 +95,5 @@ disable(): void;

/** Method to patch the instrumentation */
patch?: (moduleExports: any, moduleVersion?: string) => any;
patch?: ((moduleExports: any, moduleVersion?: string | undefined) => any) | undefined;
/** Method to unpatch the instrumentation */
unpatch?: (moduleExports: any, moduleVersion?: string) => void;
unpatch?: ((moduleExports: any, moduleVersion?: string | undefined) => void) | undefined;
}

@@ -106,0 +100,0 @@ /**

@@ -1,2 +0,2 @@

export declare const VERSION = "0.52.1";
export declare const VERSION = "0.53.0";
//# sourceMappingURL=version.d.ts.map

@@ -20,3 +20,3 @@ "use strict";

// this is autogenerated file, see scripts/version-update.js
exports.VERSION = '0.52.1';
exports.VERSION = '0.53.0';
//# sourceMappingURL=version.js.map
{
"name": "@opentelemetry/instrumentation",
"version": "0.52.1",
"version": "0.53.0",
"description": "Base class for node which OpenTelemetry instrumentation modules extend",

@@ -51,4 +51,4 @@ "author": "OpenTelemetry Authors",

"tdd:browser": "karma start",
"test:cjs": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts' --exclude 'test/browser/**/*.ts'",
"test:esm": "nyc node --experimental-loader=./hook.mjs ../../../node_modules/mocha/bin/mocha 'test/node/*.test.mjs' test/node/*.test.mjs",
"test:cjs": "nyc mocha 'test/**/*.test.ts' --exclude 'test/browser/**/*.ts'",
"test:esm": "nyc node --experimental-loader=./hook.mjs ../../../node_modules/mocha/bin/mocha 'test/node/*.test.mjs'",
"test": "npm run test:cjs && npm run test:esm",

@@ -76,4 +76,4 @@ "test:browser": "karma start --single-run",

"dependencies": {
"@opentelemetry/api-logs": "0.52.1",
"@types/shimmer": "^1.0.2",
"@opentelemetry/api-logs": "0.53.0",
"@types/shimmer": "^1.2.0",
"import-in-the-middle": "^1.8.1",

@@ -88,7 +88,7 @@ "require-in-the-middle": "^7.1.1",

"devDependencies": {
"@babel/core": "7.24.7",
"@babel/preset-env": "7.24.7",
"@babel/core": "7.25.2",
"@babel/preset-env": "7.25.3",
"@opentelemetry/api": "1.9.0",
"@opentelemetry/sdk-metrics": "1.25.1",
"@types/mocha": "10.0.6",
"@opentelemetry/sdk-metrics": "1.26.0",
"@types/mocha": "10.0.7",
"@types/node": "18.6.5",

@@ -99,7 +99,7 @@ "@types/semver": "7.5.8",

"babel-loader": "8.3.0",
"babel-plugin-istanbul": "6.1.1",
"babel-plugin-istanbul": "7.0.0",
"codecov": "3.8.3",
"cpx2": "2.0.0",
"cross-var": "1.1.0",
"karma": "6.4.3",
"karma": "6.4.4",
"karma-chrome-launcher": "3.1.0",

@@ -111,7 +111,6 @@ "karma-coverage": "2.2.1",

"lerna": "6.6.2",
"mocha": "10.2.0",
"mocha": "10.7.3",
"nyc": "15.1.0",
"sinon": "15.1.2",
"ts-loader": "9.5.1",
"ts-mocha": "10.0.0",
"typescript": "4.4.4",

@@ -126,3 +125,3 @@ "webpack": "5.89.0",

"sideEffects": false,
"gitHead": "0608f405573901e54db01e44c533009cf28be262"
"gitHead": "720bc8c70d47029cb6b41a34ffdc3d25cbaa2f80"
}

@@ -10,2 +10,5 @@ # OpenTelemetry Instrumentation for web and node

**Note: Much of OpenTelemetry JS documentation is written assuming the compiled application is run as CommonJS.**
For more details on ECMAScript Modules vs CommonJS, refer to [esm-support](https://github.com/open-telemetry/opentelemetry-js/blob/main/doc/esm-support.md).
```bash

@@ -112,3 +115,3 @@ npm install --save @opentelemetry/instrumentation

const myInstrumentationn = new MyInstrumentation();
const myInstrumentation = new MyInstrumentation();
myInstrumentation.setTracerProvider(provider); // this is optional, only if global TracerProvider shouldn't be used

@@ -224,9 +227,14 @@ myInstrumentation.setMeterProvider(meterProvider); // this is optional

## Instrumentation for ES Modules In Node.js (experimental)
## Instrumentation for ECMAScript Modules (ESM) in Node.js (experimental)
As the module loading mechanism for ESM is different than CJS, you need to select a custom loader so instrumentation can load hook on the ESM module it want to patch. To do so, you must provide the `--experimental-loader=@opentelemetry/instrumentation/hook.mjs` flag to the `node` binary. Alternatively you can set the `NODE_OPTIONS` environment variable to `NODE_OPTIONS="--experimental-loader=@opentelemetry/instrumentation/hook.mjs"`.
As the ESM module loader from Node.js is experimental, so is our support for it. Feel free to provide feedback or report issues about it.
Node.js uses a different module loader for ECMAScript Modules (ESM) vs. CommonJS (CJS).
A `require()` call will cause Node.js to use the CommonJS module loader.
An `import ...` statement or `import()` call will cause Node.js to use the ECMAScript module loader.
**Note**: ESM Instrumentation is not yet supported for Node 20.
If your application is written in JavaScript as ESM, or it must compile to ESM from TypeScript, then a loader hook is required to properly patch instrumentation.
The custom hook for ESM instrumentation is `--experimental-loader=@opentelemetry/instrumentation/hook.mjs`.
This flag must be passed to the `node` binary, which is often done as a startup command and/or in the `NODE_OPTIONS` environment variable.
For more details on ECMAScript Modules vs CommonJS, refer to [esm-support](https://github.com/open-telemetry/opentelemetry-js/blob/main/doc/esm-support.md).
## Limitations

@@ -233,0 +241,0 @@

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc