Class: Karafka::Web::Ui::Models::Status::Checks::MaterializingLag

Inherits:
Base
  • Object
show all
Defined in:
lib/karafka/web/ui/models/status/checks/materializing_lag.rb

Overview

Note:

Since both states and metrics are reported together, checking one of them is sufficient.

Checks if there is significant lag in the reporting of aggregated data.

If there’s a large gap between when data is reported and when it’s materialized, the Web UI will show stale information. This often indicates over-saturation on the consumer that materializes states.

The maximum acceptable lag is twice the tracking interval.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

depends_on, independent!, independent?, #initialize

Constructor Details

This class inherits a constructor from Karafka::Web::Ui::Models::Status::Checks::Base

Class Method Details

.halted_detailsHash

Returns details with zero lag for halted state.

Returns:

  • (Hash)

    details with zero lag for halted state



24
25
26
27
# File 'lib/karafka/web/ui/models/status/checks/materializing_lag.rb', line 24

def halted_details
  max_lag = (Web.config.tracking.interval * 2) / 1_000
  { lag: 0, max_lag: max_lag }
end

Instance Method Details

#callStatus::Step

Executes the materializing lag check.

Compares the current state’s dispatch time with the current time.

Returns:

  • (Status::Step)

    success if lag is acceptable, failure if too high



35
36
37
38
39
40
41
42
# File 'lib/karafka/web/ui/models/status/checks/materializing_lag.rb', line 35

def call
  max_lag = (Web.config.tracking.interval * 2) / 1_000
  lag = Time.now.to_f - context.current_state.dispatched_at

  status = (lag > max_lag) ? :failure : :success

  step(status, { lag: lag, max_lag: max_lag })
end