Class: AppPerfRpm::Aggregator

Inherits:
Object
  • Object
show all
Defined in:
lib/app_perf_rpm/aggregator.rb

Instance Method Summary collapse

Constructor Details

#initializeAggregator

Returns a new instance of Aggregator.



5
6
# File 'lib/app_perf_rpm/aggregator.rb', line 5

def initialize
end

Instance Method Details

#aggregate(traces) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/app_perf_rpm/aggregator.rb', line 8

def aggregate(traces)
  metrics = []
  traces = arrange_traces(traces)
  spans = traces_to_spans(traces)
  spans_by_time(spans).each_pair do |time, spans|
    group_spans(spans).each_pair do |(type, layer, domain, url, controller, action), grouped_spans|
      opts = {}
      opts["type"] = type if type
      opts["layer"] = layer if layer
      opts["domain"] = domain if domain
      opts["url"] = url if url
      opts["controller"] = controller if controller
      opts["action"] = action if action
      metrics << build_metric("trace.web.request.duration", time, grouped_spans, opts)
    end
  end

  return metrics
end