@@ -68,11 +68,31 @@ See `execute/3` to learn how the handlers are invoked.
6868All the handlers are executed by the process dispatching event. If the function fails (raises,
6969exits or throws) then the handler is removed and a failure event is emitted.
7070
71- Handler failure events `[telemetry, handler, failure]` should only be used for monitoring
72- and diagnostic purposes. Re-attaching a failed handler will likely result in the handler
73- failing again.
74-
7571Note that you should not rely on the order in which handlers are invoked.
72+
73+ ### Failing Handlers
74+
75+ When a handler fails, it is removed and a **failure event** is emitted.
76+ This is useful for monitoring and diagnostic purposes.
77+
78+ Handler failure events are executed as:
79+
80+ * Event name: `[telemetry, handler, failure]`
81+ * Measurements:
82+ * `monotonic_time` - The current monotonic time in native units from calling
83+ `erlang:monotonic_time/0`
84+ * `system_time` - The current system time in native units from calling
85+ `erlang:system_time/0`
86+ * Metadata:
87+ * `event_name` - The event that failed (`t:event_name/0`)
88+ * `handler_id` - The ID of the handler that failed
89+ * `handler_config` - The configuration of the handler that failed
90+ * `kind` - The kind of failure (`error`, `exit`, `throw`)
91+ * `reason` - The reason for the failure
92+ * `stacktrace` - The stacktrace for the failure
93+
94+ These handler failure events should only be used for monitoring and diagnostic purposes.
95+ Re-attaching a failed handler will likely result in the handler failing again.
7696""" ).
7797-spec attach (HandlerId , EventName , Function , Config ) -> ok | {error , already_exists } when
7898 HandlerId :: handler_id (),
@@ -98,9 +118,7 @@ or `&handle_event/4`) as event handlers.
98118All the handlers are executed by the process dispatching event. If the function fails (raises,
99119exits or throws) a handler failure event is emitted and then the handler is removed.
100120
101- Handler failure events `[telemetry, handler, failure]` should only be used for monitoring
102- and diagnostic purposes. Re-attaching a failed handler will likely result in the handler
103- failing again.
121+ Failing handlers emit a failure event, which is documented in `attach/4`.
104122
105123Note that you should not rely on the order in which handlers are invoked.
106124""" ).
0 commit comments