Sha256: 84f550151dae39825ca85ae3a0a4affdb00f9f6213af2e3ff43575ecd8b9b52f

Contents?: true

Size: 1.51 KB

Versions: 3

Compression:

Stored size: 1.51 KB

Contents

# encoding: utf-8
module OneApm
  class EventAnalyticData
    include OneApm::Coerce
    OA_ERROR_ALL_KEY = 'Errors/all'.freeze

    attr_reader :start_time, :guid, :refer_guid, :trip_guid,  :call_count, :duration
    attr_reader :errors, :apdex, :request_url, :bytes_sent, :bytes_rec, :has_trace,  :exec_time, :call_type

    def initialize(payload = {})
       @start_time  = payload[:start_timestamp].to_f * 1000
       @guid        = payload[:guid]
       @refer_guid  = payload[:referring_transaction_guid]
       @trip_guid   = payload[:cat_trip_id] || @refer_guid || @guid
       @call_count  = payload[:call_count] || 1
       @duration    = payload[:duration]
       @errors      = error_times(payload[:metrics])
       @apdex       = payload[:apdex_perf_zone]
       @request_url = payload[:request_url]
       @bytes_sent  = 0
       @bytes_rec   = 0
       @has_trace   = apdex != Transaction::OA_APDEX_S ? 1 : 0
       @exec_time   = payload[:duration]
       @call_type   = 0  # 0: syn , 1: asyn
    end

    def error_times(txn_metrics)
      return txn_metrics[OA_ERROR_ALL_KEY].call_count if txn_metrics.has_key?(OA_ERROR_ALL_KEY) rescue 0
      return 0
    end

    def to_collector_array(encoder = nil)
      [
        start_time, 
        guid,       
        refer_guid, 
        trip_guid,  
        call_count, 
        duration,   
        errors,     
        apdex,      
        request_url,
        bytes_sent, 
        bytes_rec,  
        has_trace,  
        exec_time,  
        call_type
      ]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
oneapm_rpm-1.4.2 lib/one_apm/transaction/event_analytic_data.rb
oneapm_rpm-1.4.1 lib/one_apm/transaction/event_analytic_data.rb
oneapm_rpm-1.4.0 lib/one_apm/transaction/event_analytic_data.rb