Move BBM prometheus metrics into separate class
What does this MR do and why?
Related to #357033 (closed)
Move the prometheus metrics gathering for batched background migrations out of the migration wrapper and into a separate class. This simplifies the migration wrapper a bit, before we begin hoist some of the batching boilerplate into the wrapper.
How to set up and validate locally
- In a rails console, create an instance of the metrics class, and verify the gauges have no values
metrics = Gitlab::Database::BackgroundMigration::PrometheusMetrics.new metrics.class.metrics[:gauge_batch_size].values # => {} metrics.class.metrics[:gauge_sub_batch_size].values # => {}
- Create a test job and pass it to the metrics instance:
job = FactoryBot.create(:batched_background_migration_job, started_at: 5.minutes.ago, finished_at: Time.current) metrics.track(job)
- Verify the metrics class has the correct metric values:
metrics.class.metrics[:gauge_batch_size].values[job.batched_migration.prometheus_labels].get # => 5 metrics.class.metrics[:gauge_sub_batch_size].values[job.batched_migration.prometheus_labels].get # => 1
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Patrick Bair