# 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