Class: Gitlab::Database::BackgroundMigration::BatchMetrics
- Inherits:
-
Object
- Object
- Gitlab::Database::BackgroundMigration::BatchMetrics
- Defined in:
- lib/gitlab/database/background_migration/batch_metrics.rb
Instance Attribute Summary collapse
-
#affected_rows ⇒ Object
readonly
Returns the value of attribute affected_rows.
-
#timings ⇒ Object
readonly
Returns the value of attribute timings.
Instance Method Summary collapse
-
#initialize ⇒ BatchMetrics
constructor
A new instance of BatchMetrics.
- #instrument_operation(label, instrument_affected_rows: true) ⇒ Object
- #time_operation(label, &blk) ⇒ Object
Constructor Details
#initialize ⇒ BatchMetrics
Returns a new instance of BatchMetrics.
10 11 12 13 |
# File 'lib/gitlab/database/background_migration/batch_metrics.rb', line 10 def initialize @timings = {} @affected_rows = {} end |
Instance Attribute Details
#affected_rows ⇒ Object (readonly)
Returns the value of attribute affected_rows.
8 9 10 |
# File 'lib/gitlab/database/background_migration/batch_metrics.rb', line 8 def affected_rows @affected_rows end |
#timings ⇒ Object (readonly)
Returns the value of attribute timings.
7 8 9 |
# File 'lib/gitlab/database/background_migration/batch_metrics.rb', line 7 def timings @timings end |
Instance Method Details
#instrument_operation(label, instrument_affected_rows: true) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/gitlab/database/background_migration/batch_metrics.rb', line 19 def instrument_operation(label, instrument_affected_rows: true) start_time = monotonic_time count = yield timings_for_label(label) << monotonic_time - start_time affected_rows_for_label(label) << count if instrument_affected_rows && count.is_a?(Integer) end |
#time_operation(label, &blk) ⇒ Object
15 16 17 |
# File 'lib/gitlab/database/background_migration/batch_metrics.rb', line 15 def time_operation(label, &blk) instrument_operation(label, instrument_affected_rows: false, &blk) end |