blob: a9355eeae40ab82aaae818344724748b0e490753 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# frozen_string_literal: true
module Gitlab
module Metrics
module Subscribers
class ActionCable < ActiveSupport::Subscriber
include Gitlab::Utils::StrongMemoize
attach_to :action_cable
SINGLE_CLIENT_TRANSMISSION = :action_cable_single_client_transmissions_total
TRANSMIT_SUBSCRIPTION_CONFIRMATION = :action_cable_subscription_confirmations_total
TRANSMIT_SUBSCRIPTION_REJECTION = :action_cable_subscription_rejections_total
BROADCAST = :action_cable_broadcasts_total
def transmit_subscription_confirmation(event)
confirm_subscription_counter.increment
end
def transmit_subscription_rejection(event)
reject_subscription_counter.increment
end
def transmit(event)
transmit_counter.increment
end
def broadcast(event)
broadcast_counter.increment
end
private
def transmit_counter
strong_memoize("transmission_counter") do
::Gitlab::Metrics.counter(
SINGLE_CLIENT_TRANSMISSION,
'The number of ActionCable messages transmitted to any client in any channel'
)
end
end
def broadcast_counter
strong_memoize("broadcast_counter") do
::Gitlab::Metrics.counter(
BROADCAST,
'The number of ActionCable broadcasts emitted'
)
end
end
def confirm_subscription_counter
strong_memoize("confirm_subscription_counter") do
::Gitlab::Metrics.counter(
TRANSMIT_SUBSCRIPTION_CONFIRMATION,
'The number of ActionCable subscriptions from clients confirmed'
)
end
end
def reject_subscription_counter
strong_memoize("reject_subscription_counter") do
::Gitlab::Metrics.counter(
TRANSMIT_SUBSCRIPTION_REJECTION,
'The number of ActionCable subscriptions from clients rejected'
)
end
end
end
end
end
end
|