Skip to content

Commit 9a8afc4

Browse files
docs(stdlib): minor insight event documentation improvement (#2728)
1 parent e1bf214 commit 9a8afc4

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

packages/stdlib/src/events.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,24 @@ import { isNil } from "./lodash.js";
1212
*/
1313

1414
/**
15-
* Manually track (async) function duration.
15+
* The insight event is a tool for tracking the duration of (async) functions manually.
16+
* By utilizing the insight event, you can gain access to a task or request-specific logger and
17+
* obtain insights into the execution time of your functions.
1618
*
17-
* By passing the event down through (async) functions, it facilitates a unified way to
18-
* have access to a task / request specific logger and insights in the duration of your
19-
* functions.
19+
* How to use the Insight Event:
20+
*
21+
* Start by retrieving a root event. It can be created by calling {@link newEvent}
22+
* and passing it a logger. When you use the {@link getApp} from @compas/store,
23+
* it automatically adds a root event to `ctx.event`.
24+
* In your tests you can use {@link newTestEvent}.
25+
*
26+
* You could pass the event object down through your (async) functions as an argument.
27+
* This allows the insight event to associate the event with the specific task or request.
28+
*
29+
* Finally, you should stop the event for correct logging by calling {@link eventStop}.
30+
* When the root event is stopped via {@link eventStop} it calculates the duration
31+
* by subtracting the start time from the end time. the event can log the start
32+
* and end times of the function execution if necessary.
2033
*
2134
* @example
2235
* async function userList(event) {

0 commit comments

Comments
 (0)