Class: Rollbar::Truncation::MinBodyStrategy

Inherits:
Object
  • Object
show all
Includes:
Mixin
Defined in:
lib/rollbar/truncation/min_body_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/min_body_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
25
# File 'lib/rollbar/truncation/min_body_strategy.rb', line 13

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

  if body['trace_chain']
    body['trace_chain'] = body['trace_chain'].map do |trace_data|
      truncate_trace_data(trace_data)
    end
  elsif body['trace']
    body['trace'] = truncate_trace_data(body['trace'])
  end

  dump(payload)
end

#truncate_trace_data(trace_data) ⇒ Object



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

def truncate_trace_data(trace_data)
  trace_data['exception'].delete('description')
  trace_data['exception']['message'] = trace_data['exception']['message'][0, 255]
  trace_data['frames'] = select_frames(trace_data['frames'], 1)

  trace_data
end