Sha256: fb051e27e891b315bda938400369a49c83cc837d95974568126cc385eae54d38

Contents?: true

Size: 845 Bytes

Versions: 3

Compression:

Stored size: 845 Bytes

Contents

# encoding: utf-8

module OneApm
  class EventAnalyticSample
    include OneApm::Coerce

    attr_accessor :event_analytic_data, :guid
    attr_reader :metric_id, :name, :scope

    def initialize(payload = {})
       @name        = payload[:name]
       @scope       = payload[:scope] || ''
       @metric_id   = metrir_id_from(payload[:metric_ids] || {})
       @guid        = payload[:guid]
       @event_analytic_data = [ OneApm::EventAnalyticData.new(payload) ]
    end

    def spec_name
      return [metric_id] if metric_id 
      [-1, name, scope]
    end

    def metrir_id_from(metric_ids)
      metric_spec = OneApm::MetricSpec.new(name, scope)
      metric_ids[metric_spec]
    end

    def to_collector_array(encoder = nil)
      [
        spec_name,
        event_analytic_data.map(&:to_collector_array)
      ]
    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_sample.rb
oneapm_rpm-1.4.1 lib/one_apm/transaction/event_analytic_sample.rb
oneapm_rpm-1.4.0 lib/one_apm/transaction/event_analytic_sample.rb