Reputation: 1182
Is there a relatively simple, documented way in a Phoenix application to read how many active sockets and channels are currently open at any given time? And more specifically, is it possible to filter this data by topic and other channel connection metadata?
My use case is for analytics on active connections to my backend.
Thanks for any suggestions!
Upvotes: 0
Views: 1643
Reputation: 120990
You are looking for Phoenix.Presence
. From the documentation:
Provides Presence tracking to processes and channels.
This behaviour provides presence features such as fetching presences for a given topic, as well as handling diffs of join and leave events as they occur in real-time. Using this module defines a supervisor and allows the calling module to implement the
Phoenix.Tracker
behaviour which starts a tracker process to handle presence information.
Basically, you are supposed to implement Phoenix.Presence
behaviour (the almost ready-to-go example is there in docs,) and Phoenix.Tracker
according to your needs.
Upvotes: 1