Sha256: 3b974596a040128df0386923904eee3cb4d387a4b3baded45baf5e2d6b6b9823

Contents?: true

Size: 605 Bytes

Versions: 5

Compression:

Stored size: 605 Bytes

Contents

# frozen_string_literal: true

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

      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
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
zipkin-1.6.0 lib/zipkin/collector/log_annotations.rb
zipkin-1.5.2 lib/zipkin/collector/log_annotations.rb
zipkin-1.5.1 lib/zipkin/collector/log_annotations.rb
zipkin-1.5.0 lib/zipkin/collector/log_annotations.rb
zipkin-1.4.0 lib/zipkin/collector/log_annotations.rb