Skip to content

Instantly share code, notes, and snippets.

View brianr's full-sized avatar

Brian Rue brianr

View GitHub Profile
import rollbar.logger
class SaferRollbarHandler(rollbar.logger.RollbarHandler):
def emit(self, record):
if record.name == 'rollbar':
return
super(SaferRollbarHandler, self).emit(record)
@brianr
brianr / gist:7828ffb0bd4f2212b247
Created September 5, 2014 22:47
rollbar.js checkIgnore configuration to ignore IE7 errors
_rollbarConfig = {
accessToken: "token here",
checkIgnore: function(isUncaught, args, payload) {
var isIE7 = (window.navigator.userAgent.indexOf("MSIE 7") !== -1);
if (isUncaught && isIE7) {
// uncaught error, and we are in IE 7. return true to ignore.
return true;
}
// don't ignore anything else
return false;
@brianr
brianr / gist:5f985b7df9facc9484c4
Created July 22, 2014 20:23
rollbar.js context config
_rollbarConfig = {
accessToken: "token here",
captureUncaught: true,
payload: {
environment: "production",
// you'll be able to search for this by prefix
// i.e. searching for context:home will return items
// with occurrences where the context is home#index, home#about, etc.
context: "home#index"
}
@brianr
brianr / example.js
Created July 17, 2014 17:47
node_rollbar log server-to-server requests and responses
var rollbar = require('rollbar');
rollbar.init("access token here");
function makeRequest(url, args) {
// third param is a callback fired upon completion
doMakeRequest(url, args, function(response) {
// log the request and response to rollbar
rollbar.reportMessageWithPayloadData("Made request to " + url,
{level: 'info', custom: {request_args: args, response: response}});
})
@brianr
brianr / gist:c90e615d03da45c81fb5
Created July 15, 2014 23:46
Rollbar custom grouping to group separately by server.software
[
{
"title": "{{ default_title }} in version {{ server.software }}",
"fingerprint": "{{ default_fingerprint }} {{ server.software }}",
"condition": {"path": "server.software", "neq": null}
}
]
@brianr
brianr / request_code_as_context.diff
Created July 9, 2014 18:13
rollbar.php - diff to use request.code as 'context' so it is searchable
diff --git a/rollbar.php b/rollbar.php
index f7d7de0..858bf75 100644
--- a/rollbar.php
+++ b/rollbar.php
@@ -249,6 +249,11 @@ class RollbarNotifier {
$data['server'] = $this->build_server_data();
$data['person'] = $this->build_person_data();
+ // use request.code as 'context', so it is searchable
+ if ($data['request'] && isset($data['request']['code'])) {
@brianr
brianr / rollbar.rb
Last active August 29, 2015 14:03
Disabling logging for Rollbar in Ruby
# put all of this in config/initializers/rollbar.rb
# from http://hawkins.io/2013/08/using-the-ruby-logger/
class NullLogger < Logger
def initialize(*args)
end
def add(*args, &block)
end
end
@brianr
brianr / gist:db44a4efb99d00d0c4b1
Created July 8, 2014 06:41
Rollbar with custom php error handler
<?php
Rollbar::init($config, true, false); // config array, true to install uncaught exception handler, false to not install error handler
function my_error_handler($errno, $errstr, $errfile, $errline) {
Rollbar::report_php_error($errno, $errstr, $errfile, $errline);
// add your own error handling code here
}
set_error_handler('my_error_handler');
rollbar.reportMessageWithPayloadData("here is a string message", {
level: "info",
custom: {
"foo": "bar",
"other stuff": [1,2,3]
}
});
function ignoreRemoteUncaught(isUncaught, args, payload) {
try {
var filename = payload.data.body.trace.frames[0].filename;
if (isUncaught && !filename.match(/^https?:\/\/www\.mycompany\.com/)) {
// Ignore uncaught errors that are not from www.mycompany.com.
return true;
}
} catch (e) {
// Most likely there was no filename or the frame doesn't exist.
}