Class: Tracebin::Timer
- Inherits:
-
Object
- Object
- Tracebin::Timer
- Includes:
- Helpers
- Defined in:
- lib/tracebin/timer.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
-
#transaction_name ⇒ Object
Returns the value of attribute transaction_name.
Instance Method Summary collapse
- #duration ⇒ Object
-
#initialize(transaction_name = nil) ⇒ Timer
constructor
A new instance of Timer.
- #payload ⇒ Object
- #start! ⇒ Object
- #stop! ⇒ Object
- #transaction_type ⇒ Object
Methods included from Helpers
Constructor Details
#initialize(transaction_name = nil) ⇒ Timer
Returns a new instance of Timer.
11 12 13 14 15 |
# File 'lib/tracebin/timer.rb', line 11 def initialize(transaction_name = nil) @transaction_name = transaction_name @start_time = nil @stop_time = nil end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
9 10 11 |
# File 'lib/tracebin/timer.rb', line 9 def events @events end |
#transaction_name ⇒ Object
Returns the value of attribute transaction_name.
8 9 10 |
# File 'lib/tracebin/timer.rb', line 8 def transaction_name @transaction_name end |
Instance Method Details
#duration ⇒ Object
45 46 47 |
# File 'lib/tracebin/timer.rb', line 45 def duration to_milliseconds @stop_time - @start_time end |
#payload ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/tracebin/timer.rb', line 28 def payload { type: :cycle_transaction, data: { transaction_type: transaction_type, name: @transaction_name, start: @start_time, stop: @stop_time, duration: duration, events: @events } } end |
#start! ⇒ Object
17 18 19 20 |
# File 'lib/tracebin/timer.rb', line 17 def start! @start_time = Time.now Recorder.start_recording end |
#stop! ⇒ Object
22 23 24 25 26 |
# File 'lib/tracebin/timer.rb', line 22 def stop! collect_events Recorder.stop_recording @stop_time = Time.now end |
#transaction_type ⇒ Object
49 50 51 |
# File 'lib/tracebin/timer.rb', line 49 def transaction_type 'request_response' end |