Skip to content

Commit

Permalink
Merge pull request #891 from rollbar/wj-skip-non-json-keys
Browse files Browse the repository at this point in the history
Expect to see and handle non-json objects
  • Loading branch information
waltjones committed Jul 12, 2019
2 parents bb4e743 + d67e837 commit ac2ef3c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/rollbar/truncation/remove_any_key_strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,21 @@ def extract_title_from_trace(trace)
def data_keys
@data_keys ||= {}.tap do |hash|
data.keys.reject { |key| skip_keys.include?(key) }.each do |key|
size = dump(data[key]).bytesize
hash[key] = size
set_key_size(key, hash)
end
end
end

def set_key_size(key, hash)
size = dump(data[key]).bytesize
hash[key] = size
rescue ::JSON::GeneratorError
hash[key] = 0 # don't try to truncate non JSON object

# Log it
truncation_key['non_json_keys'] ||= {}
truncation_key['non_json_keys'][key] = data[key].class
end
end
end
end

0 comments on commit ac2ef3c

Please sign in to comment.