@@ -70,6 +70,7 @@ protected function addReverbMetrics(): void
7070 $ reverbUp = false ;
7171 $ totalConnections = 0 ;
7272 $ totalChannels = 0 ;
73+ $ totalSubscriptions = 0 ;
7374
7475 foreach ($ this ->appProvider ->all () as $ app ) {
7576 try {
@@ -85,13 +86,18 @@ protected function addReverbMetrics(): void
8586 ]);
8687 $ totalConnections += $ metrics ['connections ' ];
8788
88- // Channel counts per app
89- foreach ($ metrics ['channels ' ] as $ type => $ count ) {
90- $ this ->store ->gauge ('reverb_channels_active ' , $ count , [
89+ // Channel counts and subscriptions per app
90+ foreach ($ metrics ['channels ' ] as $ type => $ data ) {
91+ $ this ->store ->gauge ('reverb_channels_active ' , $ data [ ' count ' ] , [
9192 'app_id ' => $ appId ,
9293 'type ' => $ type ,
9394 ]);
94- $ totalChannels += $ count ;
95+ $ this ->store ->gauge ('reverb_subscriptions_total ' , $ data ['subscriptions ' ], [
96+ 'app_id ' => $ appId ,
97+ 'type ' => $ type ,
98+ ]);
99+ $ totalChannels += $ data ['count ' ];
100+ $ totalSubscriptions += $ data ['subscriptions ' ];
95101 }
96102 }
97103 } catch (Throwable ) {
@@ -106,13 +112,14 @@ protected function addReverbMetrics(): void
106112 if ($ reverbUp ) {
107113 $ this ->store ->gauge ('reverb_connections_current ' , $ totalConnections );
108114 $ this ->store ->gauge ('reverb_channels_current ' , $ totalChannels );
115+ $ this ->store ->gauge ('reverb_subscriptions_current ' , $ totalSubscriptions );
109116 }
110117 }
111118
112119 /**
113120 * Fetch metrics for a specific app from Reverb's API.
114121 *
115- * @return array{connections: int, channels: array<string, int>}|null
122+ * @return array{connections: int, channels: array<string, array{count: int, subscriptions: int} >}|null
116123 */
117124 protected function fetchAppMetrics (Application $ app ): ?array
118125 {
@@ -126,22 +133,23 @@ protected function fetchAppMetrics(Application $app): ?array
126133
127134 $ connections = $ connectionsResult ->connections ?? 0 ;
128135
129- // Get channel info
136+ // Get channel info with subscription counts
130137 $ channelsResult = $ pusher ->get ('/channels ' , [
131138 'info ' => 'subscription_count ' ,
132139 ]);
133140
134141 $ channels = [
135- 'public ' => 0 ,
136- 'private ' => 0 ,
137- 'presence ' => 0 ,
138- 'encrypted ' => 0 ,
142+ 'public ' => [ ' count ' => 0 , ' subscriptions ' => 0 ] ,
143+ 'private ' => [ ' count ' => 0 , ' subscriptions ' => 0 ] ,
144+ 'presence ' => [ ' count ' => 0 , ' subscriptions ' => 0 ] ,
145+ 'encrypted ' => [ ' count ' => 0 , ' subscriptions ' => 0 ] ,
139146 ];
140147
141148 if ($ channelsResult && isset ($ channelsResult ->channels )) {
142149 foreach ($ channelsResult ->channels as $ name => $ info ) {
143150 $ type = $ this ->determineChannelType ($ name );
144- $ channels [$ type ]++;
151+ $ channels [$ type ]['count ' ]++;
152+ $ channels [$ type ]['subscriptions ' ] += $ info ->subscription_count ?? 0 ;
145153 }
146154 }
147155
0 commit comments