Sha256: 9ba298a3652455f5fdc9c70eb044b22385c81e5b3ff04ba3193dabc791aaeb8e

Contents?: true

Size: 1.12 KB

Versions: 7

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

module Karafka
  module Web
    module Management
      module Migrations
        module ConsumersMetrics
          # Renames total lag to hybrid to better represent what it is
          class RenameLagTotalToLagHybrid < Base
            self.versions_until = '1.2.1'
            self.type = :consumers_metrics

            # @param state [Hash]
            def migrate(state)
              state[:aggregated].each_value do |metrics|
                metrics.each do |metric|
                  metric.last[:lag_hybrid] = metric.last[:lag_total] || 0
                  metric.last.delete(:lag_total)
                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_hybrid] = sample[:lag_total]
                      sample.delete(:lag_total)
                    end
                  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.10.3 lib/karafka/web/management/migrations/consumers_metrics/1706611396_rename_lag_total_to_lag_hybrid.rb
karafka-web-0.10.2 lib/karafka/web/management/migrations/consumers_metrics/1706611396_rename_lag_total_to_lag_hybrid.rb
karafka-web-0.10.1 lib/karafka/web/management/migrations/consumers_metrics/1706611396_rename_lag_total_to_lag_hybrid.rb
karafka-web-0.10.0 lib/karafka/web/management/migrations/consumers_metrics/1706611396_rename_lag_total_to_lag_hybrid.rb
karafka-web-0.10.0.rc2 lib/karafka/web/management/migrations/consumers_metrics/1706611396_rename_lag_total_to_lag_hybrid.rb
karafka-web-0.10.0.rc1 lib/karafka/web/management/migrations/consumers_metrics/1706611396_rename_lag_total_to_lag_hybrid.rb
karafka-web-0.10.0.beta1 lib/karafka/web/management/migrations/consumers_metrics/1706611396_rename_lag_total_to_lag_hybrid.rb