Commit a6527ff6 authored by Matthias Käppler's avatar Matthias Käppler

Merge branch 'ab/batched-migration-metrics' into 'master'

Add last update at gauge

See merge request gitlab-org/gitlab!60640
parents f1fa50b9 939c8ce6
......@@ -67,6 +67,7 @@ module Gitlab
metric_for(:counter_updated_tuples).increment(base_labels, tracking_record.batch_size)
metric_for(:gauge_migrated_tuples).set(base_labels, tracking_record.batched_migration.migrated_tuple_count)
metric_for(:gauge_total_tuple_count).set(base_labels, tracking_record.batched_migration.total_tuple_count)
metric_for(:gauge_last_update_time).set(base_labels, Time.current.to_i)
if metrics = tracking_record.metrics
metrics['timings']&.each do |key, timings|
......@@ -120,6 +121,10 @@ module Gitlab
gauge_total_tuple_count: Gitlab::Metrics.gauge(
:batched_migration_total_tuple_count,
'Total tuple count the migration needs to touch'
),
gauge_last_update_time: Gitlab::Metrics.gauge(
:batched_migration_last_update_time_seconds,
'Unix epoch time in seconds'
)
}
end
......
......@@ -142,7 +142,7 @@ RSpec.describe Gitlab::Database::BackgroundMigration::BatchedMigrationWrapper, '
it 'reports job duration' do
freeze_time do
expect(Time).to receive(:current).and_return(Time.zone.now - 5.seconds).ordered
expect(Time).to receive(:current).and_return(Time.zone.now).ordered
allow(Time).to receive(:current).and_call_original
expect(described_class.metrics[:gauge_job_duration]).to receive(:set).with(labels, 5.seconds)
......@@ -155,6 +155,14 @@ RSpec.describe Gitlab::Database::BackgroundMigration::BatchedMigrationWrapper, '
subject
end
it 'reports last updated at timestamp' do
freeze_time do
expect(described_class.metrics[:gauge_last_update_time]).to receive(:set).with(labels, Time.current.to_i)
subject
end
end
end
context 'when the migration job does not raise an error' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment