You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Track require() source locations and additional metadata (#10)
- After running `trackRequires(true, { trackSource: true });`, the `require()` traces will now have an `args` object which contains the source location which can be rendered as a table in the <https://ui.perfetto.dev> view.
- Metadata for other measurements can be passed using the <https://developer.mozilla.org/en-US/docs/Web/API/Performance/measure#detail> property and it would be set as the `args` object on the trace object.
Signed-off-by: Darshan Sen <raisinten@gmail.com>
Copy file name to clipboardExpand all lines: docs/api/README.md
+8-4Lines changed: 8 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,19 +20,23 @@ Call `traceEvents.getEvents()` to get the PerformanceEntry objects in the [Trace
20
20
"ph": "X",
21
21
"pid": 1,
22
22
"ts": 34509,
23
-
"dur": 1004141
23
+
"dur": 1004141,
24
+
"args": null
24
25
},
25
26
{
26
27
"name": "A",
27
28
"cat": "measure",
28
29
"ph": "X",
29
30
"pid": 1,
30
31
"ts": 33837,
31
-
"dur": 2002098
32
+
"dur": 2002098,
33
+
"args": { "foo": "bar" }
32
34
}
33
35
]
34
36
```
35
37
36
-
## `trackRequires(bool)` (only available in [CommonJS](https://nodejs.org/api/modules.html#modules-commonjs-modules))
38
+
## `trackRequires(switch, options)` (only available in [CommonJS](https://nodejs.org/api/modules.html#modules-commonjs-modules))
37
39
38
-
Call `trackRequires(true)` to enable tracking `require()`s and call `trackRequires(false)` to disable tracking `require()`s.
40
+
-`switch` (**bool**) - Call `trackRequires(true)` to enable tracking `require()`s and call `trackRequires(false)` to disable tracking `require()`s.
41
+
-`options` (**object**)
42
+
-`trackSource` (**bool**) - Call `trackRequires(true, { trackSource: true })` to enable tracking `require()`s and also capture the source locations. This creates a throw-away error object and parses the `stack` property, so it introduces an overhead.
0 commit comments