Tracking the duration of WebSocket connections and topic subscriptions

In my app, I monitor WebSocket processes (socket.transport_pid) and channel servers to run stuff when they are gone (eg, log a socket disconnection).

I am pondering how could I measure for how long was the user connected (AFAIK telemetry does not provide such metric), and that disconnection logic seems like the perfect place to compare start vs finish, except… I guess there are no guarantees about how timely are monitors called?

If that technique is unreliable, is there another one?

1 Like