Class: Opbeat::Trace
- Inherits:
-
Object
- Object
- Opbeat::Trace
- Defined in:
- lib/opbeat/trace.rb
Constant Summary collapse
- DEFAULT_KIND =
'code.custom'.freeze
Instance Attribute Summary collapse
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#extra ⇒ Object
Returns the value of attribute extra.
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#parents ⇒ Object
Returns the value of attribute parents.
-
#relative_start ⇒ Object
readonly
Returns the value of attribute relative_start.
-
#signature ⇒ Object
Returns the value of attribute signature.
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
-
#transaction ⇒ Object
readonly
Returns the value of attribute transaction.
Instance Method Summary collapse
- #done(ms = Util.nanos) ⇒ Object
- #done? ⇒ Boolean
-
#initialize(transaction, signature, kind = nil, parents = [], extra = nil) ⇒ Trace
constructor
A new instance of Trace.
- #inspect ⇒ Object
- #running? ⇒ Boolean
- #start(relative_to) ⇒ Object
Constructor Details
#initialize(transaction, signature, kind = nil, parents = [], extra = nil) ⇒ Trace
Returns a new instance of Trace.
8 9 10 11 12 13 14 15 16 |
# File 'lib/opbeat/trace.rb', line 8 def initialize transaction, signature, kind = nil, parents = [], extra = nil @transaction = transaction @signature = signature @kind = kind || DEFAULT_KIND @parents = parents || [] @extra = extra = Util.nearest_minute.to_i end |
Instance Attribute Details
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
19 20 21 |
# File 'lib/opbeat/trace.rb', line 19 def duration @duration end |
#extra ⇒ Object
Returns the value of attribute extra.
18 19 20 |
# File 'lib/opbeat/trace.rb', line 18 def extra @extra end |
#kind ⇒ Object
Returns the value of attribute kind.
18 19 20 |
# File 'lib/opbeat/trace.rb', line 18 def kind @kind end |
#parents ⇒ Object
Returns the value of attribute parents.
18 19 20 |
# File 'lib/opbeat/trace.rb', line 18 def parents @parents end |
#relative_start ⇒ Object (readonly)
Returns the value of attribute relative_start.
19 20 21 |
# File 'lib/opbeat/trace.rb', line 19 def relative_start @relative_start end |
#signature ⇒ Object
Returns the value of attribute signature.
18 19 20 |
# File 'lib/opbeat/trace.rb', line 18 def signature @signature end |
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
19 20 21 |
# File 'lib/opbeat/trace.rb', line 19 def start_time @start_time end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
19 20 21 |
# File 'lib/opbeat/trace.rb', line 19 def end |
#transaction ⇒ Object (readonly)
Returns the value of attribute transaction.
19 20 21 |
# File 'lib/opbeat/trace.rb', line 19 def transaction @transaction end |
Instance Method Details
#done(ms = Util.nanos) ⇒ Object
28 29 30 31 32 |
# File 'lib/opbeat/trace.rb', line 28 def done ms = Util.nanos @duration = ms - start_time self end |
#done? ⇒ Boolean
34 35 36 |
# File 'lib/opbeat/trace.rb', line 34 def done? !!duration end |
#inspect ⇒ Object
42 43 44 45 |
# File 'lib/opbeat/trace.rb', line 42 def inspect info = %w{signature kind parents extra timestamp duration relative_start} "<Trace #{info.map { |m| "#{m}:#{send(m).inspect}" }.join(' ')}>" end |
#running? ⇒ Boolean
38 39 40 |
# File 'lib/opbeat/trace.rb', line 38 def running? !done? end |
#start(relative_to) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/opbeat/trace.rb', line 21 def start relative_to @start_time = Util.nanos @relative_start = start_time - relative_to self end |