Created
September 1, 2016 02:37
-
-
Save lardcanoe/88a70694e24549fce841b590d02dc41d to your computer and use it in GitHub Desktop.
A transform function for Rollbar to remove text that creates new items
This file contains 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
def transform_payload(opts) | |
ex_msg = opts[:payload]['data'][:body][:trace][:exception][:message] rescue nil | |
if ex_msg =~ /#<(.*)(:0x[a-f0-9]{8})>$/ | |
# Convert | |
# "undefined method `blow_up!' for #<Customer:0x7b417d08>" | |
# to | |
# "undefined method `blow_up!' for #<Customer>" | |
# to prevent rollbar storms when each message has a different hash | |
opts[:payload]['data'][:body][:trace][:exception][:message].gsub! $2, '' | |
end | |
frames = opts[:payload]['data'][:body][:trace][:frames] rescue nil | |
frames.each do |f| | |
# Convert '/engine-5b4dd9344243/' to '/engine/' to prevent rollbar from creating new items after each update | |
if f[:filename] =~ /(\-[0-9a-z]{12})\// | |
f[:filename].gsub $1, '' | |
end | |
# This next one strips out the unique id in JRuby land that is in the first frame | |
# "org/jruby/gen/InterfaceImpl725942136.gen" | |
if f[:filename] =~ /InterfaceImpl([\d]{8,12})\.gen/ | |
f[:filename].gsub $1, '' | |
end | |
# This is for our web app, which has the commit in the path, and also causes a new rollbar after each deploy | |
# "/home/user/app/releases/c4c9ac2c2e35a3e9b62a77f5105c22862726b701/Rakefile" | |
if f[:filename] =~ /releases\/([0-9a-f]{36,44})\// | |
f[:filename].gsub $1, 'redacted-commit-id' | |
end | |
end if frames | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment