Class: OneApm::EventAnalyticSample

Inherits:
Object
  • Object
show all
Includes:
Coerce
Defined in:
lib/one_apm/transaction/event_analytic_sample.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Coerce

#event_params, #float, #int, #int_or_nil, #log_failure, #string

Constructor Details

#initialize(payload = {}) ⇒ EventAnalyticSample

Returns a new instance of EventAnalyticSample.



10
11
12
13
14
15
16
# File 'lib/one_apm/transaction/event_analytic_sample.rb', line 10

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

Instance Attribute Details

#event_analytic_dataObject

Returns the value of attribute event_analytic_data.



7
8
9
# File 'lib/one_apm/transaction/event_analytic_sample.rb', line 7

def event_analytic_data
  @event_analytic_data
end

#guidObject

Returns the value of attribute guid.



7
8
9
# File 'lib/one_apm/transaction/event_analytic_sample.rb', line 7

def guid
  @guid
end

#metric_idObject (readonly)

Returns the value of attribute metric_id.



8
9
10
# File 'lib/one_apm/transaction/event_analytic_sample.rb', line 8

def metric_id
  @metric_id
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/one_apm/transaction/event_analytic_sample.rb', line 8

def name
  @name
end

#scopeObject (readonly)

Returns the value of attribute scope.



8
9
10
# File 'lib/one_apm/transaction/event_analytic_sample.rb', line 8

def scope
  @scope
end

Instance Method Details

#metrir_id_from(metric_ids) ⇒ Object



23
24
25
26
# File 'lib/one_apm/transaction/event_analytic_sample.rb', line 23

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

#spec_nameObject



18
19
20
21
# File 'lib/one_apm/transaction/event_analytic_sample.rb', line 18

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

#to_collector_array(encoder = nil) ⇒ Object



28
29
30
31
32
33
# File 'lib/one_apm/transaction/event_analytic_sample.rb', line 28

def to_collector_array(encoder = nil)
  [
    spec_name,
    event_analytic_data.map(&:to_collector_array)
  ]
end