Module: Zipkin::Collector::LogAnnotations

Defined in:
lib/zipkin/collector/log_annotations.rb

Class Method Summary collapse

Class Method Details

.build(span) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/zipkin/collector/log_annotations.rb', line 6

def self.build(span)
  span.logs.map do |log|
    {
      timestamp: Timestamp.create(log.fetch(:timestamp)),
      value: format_log_value(log)
    }
  end
end

.format_log_value(log) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/zipkin/collector/log_annotations.rb', line 15

def self.format_log_value(log)
  if log.keys == %i[event timestamp]
    log.fetch(:event)
  else
    log
      .reject { |key, _value| key == :timestamp }
      .map { |key, value| "#{key}=#{value}" }
      .join(' ')
  end
end