Class: Gitlab::Metrics::Subscribers::LoadBalancing
- Inherits:
-
ActiveSupport::Subscriber
- Object
- ActiveSupport::Subscriber
- Gitlab::Metrics::Subscribers::LoadBalancing
- Defined in:
- lib/gitlab/metrics/subscribers/load_balancing.rb
Constant Summary collapse
- PROMETHEUS_COUNTER =
:gitlab_transaction_caught_up_replica_pick_count_total
- LOG_COUNTERS =
{ true => :caught_up_replica_pick_ok, false => :caught_up_replica_pick_fail }.freeze
Class Method Summary collapse
Instance Method Summary collapse
- #caught_up_replica_pick(event) ⇒ Object
-
#web_transaction_completed(_event) ⇒ Object
we want to update Prometheus counter after the controller/action are set.
Class Method Details
.load_balancing_payload ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/gitlab/metrics/subscribers/load_balancing.rb', line 28 def self.load_balancing_payload return {} unless Gitlab::SafeRequestStore.active? {}.tap do |payload| LOG_COUNTERS.values.each do |counter| value = Gitlab::SafeRequestStore[counter] payload[counter] = value.to_i if value end end end |
Instance Method Details
#caught_up_replica_pick(event) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/gitlab/metrics/subscribers/load_balancing.rb', line 12 def caught_up_replica_pick(event) return unless Gitlab::SafeRequestStore.active? result = event.payload[:result] counter_name = counter(result) increment(counter_name) end |
#web_transaction_completed(_event) ⇒ Object
we want to update Prometheus counter after the controller/action are set
22 23 24 25 26 |
# File 'lib/gitlab/metrics/subscribers/load_balancing.rb', line 22 def web_transaction_completed(_event) return unless Gitlab::SafeRequestStore.active? LOG_COUNTERS.keys.each { |result| increment_prometheus_for_result_label(result) } end |