Sha256: 15e59b82a538b7648082eca20fd9f21a02ea2d956596f4716bd25aed320950cf

Contents?: true

Size: 1.11 KB

Versions: 7

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

module Karafka
  module Web
    module Management
      module Migrations
        # Moves to using lag total as a normalization for both lags
        class IntroduceLagTotalInMetrics < Base
          self.versions_until = '1.2.0'
          self.type = :consumers_metrics

          # @param state [Hash]
          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
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
karafka-web-0.9.1 lib/karafka/web/management/migrations/1706607960_introduce_lag_total_in_metrics.rb
karafka-web-0.9.0 lib/karafka/web/management/migrations/1706607960_introduce_lag_total_in_metrics.rb
karafka-web-0.9.0.rc3 lib/karafka/web/management/migrations/1706607960_introduce_lag_total_in_metrics.rb
karafka-web-0.9.0.rc2 lib/karafka/web/management/migrations/1706607960_introduce_lag_total_in_metrics.rb
karafka-web-0.9.0.rc1 lib/karafka/web/management/migrations/1706607960_introduce_lag_total_in_metrics.rb
karafka-web-0.8.2 lib/karafka/web/management/migrations/1706607960_introduce_lag_total_in_metrics.rb
karafka-web-0.8.1 lib/karafka/web/management/migrations/1706607960_introduce_lag_total_in_metrics.rb