Skip to content

Commit fd7a386

Browse files
authored
make getModulePath ignore reflect metadata module (#150)
* make getModulePath ignore reflect metadata module * add comment clarifying need
1 parent 2d5e6e8 commit fd7a386

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/autometrics/src/utils.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,15 @@ function getWrappedFunctionPath(): string | undefined {
9292
return (
9393
index > 2 &&
9494
file &&
95+
// Ignore autometrics internals
9596
!file.includes("autometrics/index.cjs") &&
9697
!file.includes("autometrics/index.mjs") &&
9798
!file.includes("wrappers.ts") &&
98-
!file.includes("wrappers.js")
99+
!file.includes("wrappers.js") &&
100+
// Ignore reflect-metadata - often used by IOC libraries for runtime dependency injection
101+
// Without this, instrumented functions will be attributed to this module rather than
102+
// the module the function truly belongs to
103+
!file.includes("reflect-metadata")
99104
);
100105
});
101106
return call?.file;

0 commit comments

Comments
 (0)