Add ActionCable Prometheus metrics
We already added metrics around Action Cable thread pooling and connections, but this is not sufficient to populate a standard service dashboard.
As part of the readiness review for Action Cable, we therefore identified the need to add more standard metrics such as latency, saturation, and error rate. These should feed directly into our SLOs, since real-time updates will be part of the overall webservice experience. The existing service catalog is a good reference for how this could be integrated into existing dashboards and alerting rules.
Note that since existing web metrics evolve around the traditional request-response flow of HTTP, with Action Cable this would only cover the initial protocol upgrade request going through the /-/cable
endpoint. So RequestsRackMiddleware
is not going to provide enough coverage here. We will have to emit these through other hooks.
See #296845 (comment 492016572)
-
transmit.action_cable
: A single message transmitted to one client. Count these using thechannel_class
as a label. Includes themessage
wrapped in JSON envelope &via
. Capture count + message size (in bytes/KB). -
transmit_subscription_confirmation.action_cable
: Emitted after successful subscription to a channel. Count these withchannel_class
as a label. -
transmit_subscription_rejection.action_cable
: Emitted when subscription to a channel is rejected. We don't have any application logic that would reject a connection yet but maybe there are other reasons why this would happen. Count withchannel_class
as a label. -
broadcast.action_cable
: Emitted when a broadcast is sent to all subscribers to a stream (source code here). Contains the stream name (broadcasting
),message
andcoder
(defaults to"ActiveSupport::JSON"
)