Created
October 3, 2017 18:00
-
-
Save radixdev/24b603aea015d296ef8029a36560e3ab to your computer and use it in GitHub Desktop.
Grabs the error class from the papertrail daily reports
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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