Class: Karafka::Web::Management::Migrations::ConsumersMetrics::IntroduceLagTotal

Inherits:
Base
  • Object
show all
Defined in:
lib/karafka/web/management/migrations/consumers_metrics/1706607960_introduce_lag_total.rb

Overview

Moves to using lag total as a normalization for both lags

Instance Method Summary collapse

Methods inherited from Base

applicable?, index, migrate, sorted_descendants

Instance Method Details

#migrate(state) ⇒ Object

Parameters:

  • state (Hash)


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/karafka/web/management/migrations/consumers_metrics/1706607960_introduce_lag_total.rb', line 14

def migrate(state)
  state[:aggregated].each_value do |metrics|
    metrics.each do |metric|
      metric.last[:lag_total] = metric.last[:lag_stored]
      metric.last.delete(:lag_stored)
      metric.last.delete(:lag)
    end
  end

  state[:consumer_groups].each_value do |metrics|
    metrics.each do |metric_group|
      metric_group.last.each_value do |metric|
        metric.each_value do |sample|
          sample[:lag_total] = sample[:lag_stored]
          sample.delete(:lag_stored)
          sample.delete(:lag)
        end
      end
    end
  end
end