Skip to content

Instantly share code, notes, and snippets.

@radixdev
Created October 3, 2017 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save radixdev/24b603aea015d296ef8029a36560e3ab to your computer and use it in GitHub Desktop.
Save radixdev/24b603aea015d296ef8029a36560e3ab to your computer and use it in GitHub Desktop.
Grabs the error class from the papertrail daily reports
#!/usr/bin/env ruby
def pbpaste
`pbpaste`
end
# get the raw text
papertrail_text = pbpaste()
# match for the error types
# An example snippet of a full line below
# SDK Error (AndroidApp - 15.9.2) (CirrusMusic) : exception_class: android.content.res.Resources$NotFoundException: Resource ID #0x112005c,session_id: null|android
# Match for anything that's not a ":" to get the exception class name
matches = papertrail_text.scan(/exception_class: ([^:]*):.*,session_id/)
# bucketize the errors
buckets = {}
for match in matches do
# Increment the bucket or initialize the bucket with 1
buckets[match] = (buckets[match]|| 0) + 1
end
# sort the buckets
buckets = buckets.sort_by {|k,v| v}.reverse
buckets.each do |error_name, occurrence|
puts "Error name: #{error_name[0]}"
puts "Occurrence: #{occurrence}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment