Class: InfluxReporter::Trace
- Inherits:
-
Object
- Object
- InfluxReporter::Trace
- Defined in:
- lib/influx_reporter/trace.rb
Constant Summary collapse
- DEFAULT_KIND =
'code.custom'
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.
9 10 11 12 13 14 15 16 17 |
# File 'lib/influx_reporter/trace.rb', line 9 def initialize(transaction, signature, kind = nil, parents = [], extra = nil) @transaction = transaction @signature = signature @kind = kind || DEFAULT_KIND @parents = parents || [] @extra = extra || {} @timestamp = Util.nanos end |
Instance Attribute Details
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
20 21 22 |
# File 'lib/influx_reporter/trace.rb', line 20 def duration @duration end |
#extra ⇒ Object
Returns the value of attribute extra.
19 20 21 |
# File 'lib/influx_reporter/trace.rb', line 19 def extra @extra end |
#kind ⇒ Object
Returns the value of attribute kind.
19 20 21 |
# File 'lib/influx_reporter/trace.rb', line 19 def kind @kind end |
#parents ⇒ Object
Returns the value of attribute parents.
19 20 21 |
# File 'lib/influx_reporter/trace.rb', line 19 def parents @parents end |
#relative_start ⇒ Object (readonly)
Returns the value of attribute relative_start.
20 21 22 |
# File 'lib/influx_reporter/trace.rb', line 20 def relative_start @relative_start end |
#signature ⇒ Object
Returns the value of attribute signature.
19 20 21 |
# File 'lib/influx_reporter/trace.rb', line 19 def signature @signature end |
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
20 21 22 |
# File 'lib/influx_reporter/trace.rb', line 20 def start_time @start_time end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
20 21 22 |
# File 'lib/influx_reporter/trace.rb', line 20 def @timestamp end |
#transaction ⇒ Object (readonly)
Returns the value of attribute transaction.
20 21 22 |
# File 'lib/influx_reporter/trace.rb', line 20 def transaction @transaction end |
Instance Method Details
#done(ms = Util.nanos) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/influx_reporter/trace.rb', line 30 def done(ms = Util.nanos) @duration = ms - start_time @transaction._trace_stopped self self end |
#done? ⇒ Boolean
37 38 39 |
# File 'lib/influx_reporter/trace.rb', line 37 def done? !!duration end |
#inspect ⇒ Object
45 46 47 48 |
# File 'lib/influx_reporter/trace.rb', line 45 def inspect info = %w[signature kind parents extra timestamp duration relative_start] "<Trace #{info.map { |m| "#{m}:#{send(m).inspect}" }.join(' ')}>" end |
#running? ⇒ Boolean
41 42 43 |
# File 'lib/influx_reporter/trace.rb', line 41 def running? !done? end |
#start(relative_to) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/influx_reporter/trace.rb', line 22 def start(relative_to) @start_time = Util.nanos @relative_start = start_time - relative_to @transaction._trace_started self self end |