module Zipkin::Encoders::JsonEncoder::LogAnnotations

Public Class Methods

build(span) click to toggle source
# File lib/zipkin/encoders/json_encoder/log_annotations.rb, line 12
def self.build(span)
  span.logs.map do |log|
    {
      Fields::TIMESTAMP => Timestamp.create(log.fetch(:timestamp)),
      Fields::VALUE => format_log_value(log)
    }
  end
end
format_log_value(log) click to toggle source
# File lib/zipkin/encoders/json_encoder/log_annotations.rb, line 21
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