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
I have a use case where a GenServer needs to monitor a connection. The connection automatically reconnects when it disconnects, and it publishes telemetry events for it.
The problem is my GenServer can crash and get restarted, but :telemetry doesn't clean up the event handler.
Is there any performant way to have :telemetry Process.monitor/1 anything that calls attach/4 and automatically detaches when those processes end?
There are ways to do this on the user side of :telemetry, but it seems very hacky: The config argument of attach could be {handler_id, pid_of_caller}, then the handler can call Process.alive?(pid_of_caller) and call detach if true. It also seems less performant than just having a process monitor.
Thanks for the help.
The text was updated successfully, but these errors were encountered:
I have a use case where a GenServer needs to monitor a connection. The connection automatically reconnects when it disconnects, and it publishes telemetry events for it.
The problem is my GenServer can crash and get restarted, but :telemetry doesn't clean up the event handler.
Is there any performant way to have :telemetry
Process.monitor/1
anything that callsattach/4
and automatically detaches when those processes end?There are ways to do this on the user side of :telemetry, but it seems very hacky: The config argument of attach could be
{handler_id, pid_of_caller
}, then the handler can callProcess.alive?(pid_of_caller)
and calldetach
if true. It also seems less performant than just having a process monitor.Thanks for the help.
The text was updated successfully, but these errors were encountered: