Sha256: 25e1c5cf95bf37488442f1f8599c1da30694834f43bd9303ca29ecdf44fda428

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

module ElasticAPM
  module Serializers
    # @api private
    class Transactions < Serializer
      # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
      def build(transaction)
        {
          id: transaction.id,
          name: transaction.name,
          type: transaction.type,
          result: transaction.result.to_s,
          duration: ms(transaction.duration),
          timestamp: micros_to_time(transaction.timestamp).utc.iso8601,
          spans: transaction.spans.map do |span|
            {
              id: span.id,
              parent: span.parent && span.parent.id,
              name: span.name,
              type: span.type,
              start: ms(span.relative_start),
              duration: ms(span.duration),
              context: span.context && { db: span.context.to_h }
            }
          end,
          sampled: transaction.sampled,
          context: transaction.context.to_h
        }
      end
      # rubocop:enable Metrics/AbcSize, Metrics/MethodLength

      def build_all(transactions)
        { transactions: Array(transactions).map(&method(:build)) }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
elastic-apm-0.2.0 lib/elastic_apm/serializers/transactions.rb