Class: Txnap::Report
- Inherits:
-
Object
- Object
- Txnap::Report
- Defined in:
- lib/txnap/report.rb
Instance Attribute Summary collapse
-
#database_time ⇒ Object
readonly
Returns the value of attribute database_time.
-
#gaps ⇒ Object
readonly
Returns the value of attribute gaps.
-
#locks ⇒ Object
readonly
Returns the value of attribute locks.
-
#longest_gap ⇒ Object
readonly
Returns the value of attribute longest_gap.
-
#outcome ⇒ Object
readonly
Returns the value of attribute outcome.
-
#sql_count ⇒ Object
readonly
Returns the value of attribute sql_count.
-
#transaction_duration ⇒ Object
readonly
Returns the value of attribute transaction_duration.
Instance Method Summary collapse
-
#initialize(outcome:, transaction_duration:, database_time:, gaps:, sql_count:) ⇒ Report
constructor
A new instance of Report.
- #to_h ⇒ Object
Constructor Details
#initialize(outcome:, transaction_duration:, database_time:, gaps:, sql_count:) ⇒ Report
Returns a new instance of Report.
35 36 37 38 39 40 41 42 43 |
# File 'lib/txnap/report.rb', line 35 def initialize(outcome:, transaction_duration:, database_time:, gaps:, sql_count:) @outcome = outcome @transaction_duration = transaction_duration @database_time = database_time @gaps = gaps.freeze @longest_gap = gaps.first @locks = (@longest_gap&.locks || []).freeze @sql_count = sql_count end |
Instance Attribute Details
#database_time ⇒ Object (readonly)
Returns the value of attribute database_time.
27 28 29 |
# File 'lib/txnap/report.rb', line 27 def database_time @database_time end |
#gaps ⇒ Object (readonly)
Returns the value of attribute gaps.
27 28 29 |
# File 'lib/txnap/report.rb', line 27 def gaps @gaps end |
#locks ⇒ Object (readonly)
Returns the value of attribute locks.
27 28 29 |
# File 'lib/txnap/report.rb', line 27 def locks @locks end |
#longest_gap ⇒ Object (readonly)
Returns the value of attribute longest_gap.
27 28 29 |
# File 'lib/txnap/report.rb', line 27 def longest_gap @longest_gap end |
#outcome ⇒ Object (readonly)
Returns the value of attribute outcome.
27 28 29 |
# File 'lib/txnap/report.rb', line 27 def outcome @outcome end |
#sql_count ⇒ Object (readonly)
Returns the value of attribute sql_count.
27 28 29 |
# File 'lib/txnap/report.rb', line 27 def sql_count @sql_count end |
#transaction_duration ⇒ Object (readonly)
Returns the value of attribute transaction_duration.
27 28 29 |
# File 'lib/txnap/report.rb', line 27 def transaction_duration @transaction_duration end |
Instance Method Details
#to_h ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/txnap/report.rb', line 45 def to_h { outcome: outcome, transaction_duration_ms: transaction_duration * 1000.0, database_time_ms: database_time * 1000.0, longest_gap_ms: longest_gap.duration * 1000.0, sql_count: sql_count, gap: longest_gap.to_h, gaps: gaps.map(&:to_h), locks: locks.map(&:to_h) } end |