Class: Gitlab::Database::Batch::Metrics
- Inherits:
-
Object
- Object
- Gitlab::Database::Batch::Metrics
- Defined in:
- lib/gitlab/database/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 ⇒ Metrics
constructor
A new instance of Metrics.
- #instrument_operation(label, instrument_affected_rows: true) ⇒ Object
- #time_operation(label, &blk) ⇒ Object
Constructor Details
#initialize ⇒ Metrics
Returns a new instance of Metrics.
9 10 11 12 |
# File 'lib/gitlab/database/batch/metrics.rb', line 9 def initialize @timings = {} @affected_rows = {} end |
Instance Attribute Details
#affected_rows ⇒ Object (readonly)
Returns the value of attribute affected_rows.
7 8 9 |
# File 'lib/gitlab/database/batch/metrics.rb', line 7 def affected_rows @affected_rows end |
#timings ⇒ Object (readonly)
Returns the value of attribute timings.
7 8 9 |
# File 'lib/gitlab/database/batch/metrics.rb', line 7 def timings @timings end |
Instance Method Details
#instrument_operation(label, instrument_affected_rows: true) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/gitlab/database/batch/metrics.rb', line 18 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
14 15 16 |
# File 'lib/gitlab/database/batch/metrics.rb', line 14 def time_operation(label, &blk) instrument_operation(label, instrument_affected_rows: false, &blk) end |