Class: Txray::Runtime::Transaction
- Inherits:
-
Object
- Object
- Txray::Runtime::Transaction
- Defined in:
- lib/txray/runtime/transaction.rb
Instance Attribute Summary collapse
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#violations ⇒ Object
readonly
Returns the value of attribute violations.
Instance Method Summary collapse
- #duration_ms ⇒ Object
-
#initialize(source) ⇒ Transaction
constructor
A new instance of Transaction.
- #record(violation) ⇒ Object
- #to_event(outcome) ⇒ Object
Constructor Details
#initialize(source) ⇒ Transaction
Returns a new instance of Transaction.
8 9 10 11 12 |
# File 'lib/txray/runtime/transaction.rb', line 8 def initialize(source) @source = source @violations = [] @started_at = Process.clock_gettime(Process::CLOCK_MONOTONIC) end |
Instance Attribute Details
#source ⇒ Object (readonly)
Returns the value of attribute source.
6 7 8 |
# File 'lib/txray/runtime/transaction.rb', line 6 def source @source end |
#violations ⇒ Object (readonly)
Returns the value of attribute violations.
6 7 8 |
# File 'lib/txray/runtime/transaction.rb', line 6 def violations @violations end |
Instance Method Details
#duration_ms ⇒ Object
16 |
# File 'lib/txray/runtime/transaction.rb', line 16 def duration_ms = ((Process.clock_gettime(Process::CLOCK_MONOTONIC) - @started_at) * 1000).round(1) |
#record(violation) ⇒ Object
14 |
# File 'lib/txray/runtime/transaction.rb', line 14 def record(violation) = @violations << violation |
#to_event(outcome) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/txray/runtime/transaction.rb', line 18 def to_event(outcome) { type: "transaction", at: Time.now.to_f, pid: Process.pid, duration_ms: duration_ms, outcome: outcome.to_s, source: source, violations: violations } end |