Skip to content

Commit c07aa53

Browse files
authored
fix: Update import-in-the-middle (#4806)
* fix: Update `import-in-the-middle` * add changelog entry * linting is important
1 parent 3cbc9c7 commit c07aa53

File tree

4 files changed

+30
-29
lines changed

4 files changed

+30
-29
lines changed

experimental/CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ All notable changes to experimental packages in this project will be documented
1515
### :bug: (Bug Fix)
1616

1717
* fix(sdk-node): register context manager if no tracer options are provided [#4781](https://github.com/open-telemetry/opentelemetry-js/pull/4781) @pichlermarc
18+
* fix(instrumentation): Update `import-in-the-middle` to fix [numerous bugs](https://github.com/DataDog/import-in-the-middle/releases/tag/v1.8.1) [#4806](https://github.com/open-telemetry/opentelemetry-js/pull/4806) @timfish
1819

1920
### :books: (Refine Doc)
2021

@@ -61,7 +62,7 @@ All notable changes to experimental packages in this project will be documented
6162

6263
### :bug: (Bug Fix)
6364

64-
* fix(instrumentation): Update `import-in-the-middle` to fix [numerous bugs](https://github.com/DataDog/import-in-the-middle/pull/91) [#4745](https://github.com/open-telemetry/opentelemetry-js/pull/4745) @timfish
65+
* fix(instrumentation): Update `import-in-the-middle` to fix [numerous bugs](https://github.com/DataDog/import-in-the-middle/releases/tag/v1.8.0) [#4745](https://github.com/open-telemetry/opentelemetry-js/pull/4745) @timfish
6566

6667
### :books: (Refine Doc)
6768

experimental/packages/opentelemetry-instrumentation/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"dependencies": {
7575
"@opentelemetry/api-logs": "0.52.0",
7676
"@types/shimmer": "^1.0.2",
77-
"import-in-the-middle": "1.8.0",
77+
"import-in-the-middle": "1.8.1",
7878
"require-in-the-middle": "^7.1.1",
7979
"semver": "^7.5.2",
8080
"shimmer": "^1.2.1"

experimental/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ import {
2525
Hooked,
2626
} from './RequireInTheMiddleSingleton';
2727
import type { HookFn } from 'import-in-the-middle';
28-
import * as ImportInTheMiddle from 'import-in-the-middle';
28+
import { Hook as HookImport } from 'import-in-the-middle';
2929
import {
3030
InstrumentationConfig,
3131
InstrumentationModuleDefinition,
3232
} from '../../types';
3333
import { diag } from '@opentelemetry/api';
3434
import type { OnRequireFn } from 'require-in-the-middle';
35-
import { Hook } from 'require-in-the-middle';
35+
import { Hook as HookRequire } from 'require-in-the-middle';
3636
import { readFileSync } from 'fs';
3737
import { isWrapped } from '../../utils';
3838

@@ -46,7 +46,7 @@ export abstract class InstrumentationBase<
4646
implements types.Instrumentation<ConfigType>
4747
{
4848
private _modules: InstrumentationModuleDefinition[];
49-
private _hooks: (Hooked | Hook)[] = [];
49+
private _hooks: (Hooked | HookRequire)[] = [];
5050
private _requireInTheMiddleSingleton: RequireInTheMiddleSingleton =
5151
RequireInTheMiddleSingleton.getInstance();
5252
private _enabled = false;
@@ -305,15 +305,15 @@ export abstract class InstrumentationBase<
305305
// For an absolute paths, we must create a separate instance of the
306306
// require-in-the-middle `Hook`.
307307
const hook = path.isAbsolute(module.name)
308-
? new Hook([module.name], { internals: true }, onRequire)
308+
? new HookRequire([module.name], { internals: true }, onRequire)
309309
: this._requireInTheMiddleSingleton.register(module.name, onRequire);
310310

311311
this._hooks.push(hook);
312-
const esmHook = new (
313-
ImportInTheMiddle as unknown as {
314-
Hook: typeof ImportInTheMiddle.default;
315-
}
316-
).Hook([module.name], { internals: false }, <HookFn>hookFn);
312+
const esmHook = new HookImport(
313+
[module.name],
314+
{ internals: false },
315+
<HookFn>hookFn
316+
);
317317
this._hooks.push(esmHook);
318318
}
319319
}

package-lock.json

+18-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)