Class: Rollbar::Truncation::FramesStrategy

Inherits:
Object
  • Object
show all
Includes:
Mixin
Defined in:
lib/rollbar/truncation/frames_strategy.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Mixin

#dump, #select_frames, #truncate?

Class Method Details

.call(payload) ⇒ Object



9
10
11
# File 'lib/rollbar/truncation/frames_strategy.rb', line 9

def self.call(payload)
  new.call(payload)
end

Instance Method Details

#call(payload) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rollbar/truncation/frames_strategy.rb', line 13

def call(payload)
  new_payload = payload
  body = new_payload['data']['body']

  if body['trace_chain']
    truncate_trace_chain(body)
  elsif body['trace']
    truncate_trace(body)
  end

  dump(new_payload)
end

#truncate_trace(body) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/rollbar/truncation/frames_strategy.rb', line 26

def truncate_trace(body)
  trace_data = body['trace']
  frames = trace_data['frames']
  trace_data['frames'] = select_frames(frames)

  body['trace']['frames'] = select_frames(body['trace']['frames'])
end

#truncate_trace_chain(body) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/rollbar/truncation/frames_strategy.rb', line 34

def truncate_trace_chain(body)
  chain = body['trace_chain']

  body['trace_chain'] = chain.map do |trace_data|
    frames = trace_data['frames']
    trace_data['frames'] = select_frames(frames)
    trace_data
  end
end