Class: InfluxReporter::Trace

Inherits:
Object
  • Object
show all
Defined in:
lib/influx_reporter/trace.rb

Constant Summary collapse

DEFAULT_KIND =
'code.custom'

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#durationObject (readonly)

Returns the value of attribute duration.



20
21
22
# File 'lib/influx_reporter/trace.rb', line 20

def duration
  @duration
end

#extraObject

Returns the value of attribute extra.



19
20
21
# File 'lib/influx_reporter/trace.rb', line 19

def extra
  @extra
end

#kindObject

Returns the value of attribute kind.



19
20
21
# File 'lib/influx_reporter/trace.rb', line 19

def kind
  @kind
end

#parentsObject

Returns the value of attribute parents.



19
20
21
# File 'lib/influx_reporter/trace.rb', line 19

def parents
  @parents
end

#relative_startObject (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

#signatureObject

Returns the value of attribute signature.



19
20
21
# File 'lib/influx_reporter/trace.rb', line 19

def signature
  @signature
end

#start_timeObject (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

#timestampObject (readonly)

Returns the value of attribute timestamp.



20
21
22
# File 'lib/influx_reporter/trace.rb', line 20

def timestamp
  @timestamp
end

#transactionObject (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

Returns:

  • (Boolean)


37
38
39
# File 'lib/influx_reporter/trace.rb', line 37

def done?
  !!duration
end

#inspectObject



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

Returns:

  • (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