Class: BaselineRedRpm::Tracing::Collector

Inherits:
Object
  • Object
show all
Defined in:
lib/baseline_red_rpm/tracing/collector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(local_endpoint) ⇒ Collector

Returns a new instance of Collector.



8
9
10
11
# File 'lib/baseline_red_rpm/tracing/collector.rb', line 8

def initialize(local_endpoint)
  @buffer = Buffer.new
  @local_endpoint = local_endpoint
end

Instance Attribute Details

#bufferObject (readonly)

Returns the value of attribute buffer.



6
7
8
# File 'lib/baseline_red_rpm/tracing/collector.rb', line 6

def buffer
  @buffer
end

Instance Method Details

#retrieveObject



13
14
15
# File 'lib/baseline_red_rpm/tracing/collector.rb', line 13

def retrieve
  @buffer.retrieve
end

#send_span(span, end_time) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/baseline_red_rpm/tracing/collector.rb', line 17

def send_span(span, end_time)
  duration = end_time - span.start_time

  @buffer << {
    "traceId" => span.context.trace_id,
    "id" => span.context.span_id,
    "parentId" => span.context.parent_id,
    "name" => span.operation_name,
    "timestamp" => span.start_time,
    "duration" => duration * 1_000,
    "logEntries" => span.log_entries,
    "tags" => span.tags
  }
end