-
Notifications
You must be signed in to change notification settings - Fork 928
Description
Description:
@types/shimmer
is currently part of the @opentelemetry/instrumentation
package's public API. We should avoid having a third-party dependency be part of the public API of this package as breaking changes will affect the public interface of @opentelemetry/instrumentation
A solution to this can be changing InstrumentationAbstract#_wrap
, InstrumentationAbstract#_unwrap
, InstrumentationAbstract#massUnwrap
, InstrumentationAbstract#massWrap
to be custom functions that wrap shimmer
functions and for which we fully control the types.
This issue is considered done when:
-
shimmer
,@types/shimmer
exports are hidden in a way so that they are not part of the public API anymore -
@types/shimmer
is moved todevDependenices
or removed completely
Additional Details
Code sections of interest:
opentelemetry-js/experimental/packages/opentelemetry-instrumentation/src/instrumentation.ts
Lines 73 to 80 in 01a2c35
/* Api to wrap instrumented method */ protected _wrap = shimmer.wrap; /* Api to unwrap instrumented methods */ protected _unwrap = shimmer.unwrap; /* Api to mass wrap instrumented method */ protected _massWrap = shimmer.massWrap; /* Api to mass unwrap instrumented methods */ protected _massUnwrap = shimmer.massUnwrap; Lines 82 to 152 in 01a2c35
protected override _wrap: typeof wrap = (moduleExports, name, wrapper) => { if (isWrapped(moduleExports[name])) { this._unwrap(moduleExports, name); } if (!utilTypes.isProxy(moduleExports)) { return wrap(moduleExports, name, wrapper); } else { const wrapped = wrap(Object.assign({}, moduleExports), name, wrapper); return Object.defineProperty(moduleExports, name, { value: wrapped, }); } }; protected override _unwrap: typeof unwrap = (moduleExports, name) => { if (!utilTypes.isProxy(moduleExports)) { return unwrap(moduleExports, name); } else { return Object.defineProperty(moduleExports, name, { value: moduleExports[name], }); } }; protected override _massWrap: typeof massWrap = ( moduleExportsArray, names, wrapper ) => { if (!moduleExportsArray) { diag.error('must provide one or more modules to patch'); return; } else if (!Array.isArray(moduleExportsArray)) { moduleExportsArray = [moduleExportsArray]; } if (!(names && Array.isArray(names))) { diag.error('must provide one or more functions to wrap on modules'); return; } moduleExportsArray.forEach(moduleExports => { names.forEach(name => { this._wrap(moduleExports, name, wrapper); }); }); }; protected override _massUnwrap: typeof massUnwrap = ( moduleExportsArray, names ) => { if (!moduleExportsArray) { diag.error('must provide one or more modules to patch'); return; } else if (!Array.isArray(moduleExportsArray)) { moduleExportsArray = [moduleExportsArray]; } if (!(names && Array.isArray(names))) { diag.error('must provide one or more functions to wrap on modules'); return; } moduleExportsArray.forEach(moduleExports => { names.forEach(name => { this._unwrap(moduleExports, name); }); }); };
This issue is part of #4586