How to use the bugsnag.notify function in bugsnag

To help you get started, we’ve selected a few bugsnag examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bugsnag / bugsnag-python / tests / test_notify.py View on Github external
def test_notify_configured_api_key(self):
        bugsnag.notify(ScaryException('unexpected failover'))
        headers = self.server.received[0]['headers']
        self.assertEqual('tomatoes', headers['Bugsnag-Api-Key'])
github bugsnag / bugsnag-python / tests / test_notify.py View on Github external
def test_notify_recursive_metadata_array(self):
        a = ['foo', 'bar']
        a.append(a)
        bugsnag.add_metadata_tab('a', {'b': a})
        bugsnag.notify(ScaryException('unexpected failover'))
        json_body = self.server.received[0]['json_body']
        event = json_body['events'][0]
        self.assertEqual(['foo', 'bar', '[RECURSIVE]'],
                         event['metaData']['a']['b'])
github bugsnag / bugsnag-python / tests / test_notify.py View on Github external
def test_notify_override_metadata_sections(self):
        bugsnag.add_metadata_tab('food', {'beans': 3, 'corn': 'purple'})
        bugsnag.notify(ScaryException('unexpected failover'),
                       meta_data={'food': {'beans': 5},
                                  'skills': {'spear': 6}})
        json_body = self.server.received[0]['json_body']
        event = json_body['events'][0]
        self.assertEqual(6, event['metaData']['skills']['spear'])
        self.assertEqual('purple', event['metaData']['food']['corn'])
        self.assertEqual(5, event['metaData']['food']['beans'])
github bugsnag / bugsnag-python / tests / test_notify.py View on Github external
def test_notify_device_filter(self):
        bugsnag.configure(params_filters=['hostname'])
        bugsnag.notify(ScaryException('unexpected failover'))
        json_body = self.server.received[0]['json_body']
        event = json_body['events'][0]
        self.assertEqual('[FILTERED]', event['device']['hostname'])
github bugsnag / bugsnag-python / tests / test_notify.py View on Github external
def test_notify_recursive_metadata_dict(self):
        a = {'foo': 'bar'}
        a['baz'] = a
        bugsnag.add_metadata_tab('a', a)
        bugsnag.notify(ScaryException('unexpected failover'))
        json_body = self.server.received[0]['json_body']
        event = json_body['events'][0]
        self.assertEqual('bar', event['metaData']['a']['foo'])
        self.assertEqual('[RECURSIVE]', event['metaData']['a']['baz']['baz'])
github bugsnag / bugsnag-python / tests / test_notify.py View on Github external
def test_middleware_stack_order_legacy(self):
        def first_callback(notification):
            notification.meta_data['test']['array'].append(1)

        def second_callback(notification):
            notification.meta_data['test']['array'].append(2)

        # Add a regular callback function
        bugsnag.before_notify(second_callback)

        # Simulate an internal middleware
        bugsnag.legacy.configuration.internal_middleware.before_notify(
                first_callback)

        bugsnag.notify(ScaryException('unexpected failover'),
                       test={'array': []})
        json_body = self.server.received[0]['json_body']
        event = json_body['events'][0]

        self.assertEqual(event['metaData']['test']['array'], [1, 2])
github bugsnag / bugsnag-python / tests / test_notify.py View on Github external
def test_notify_override_user(self):
        bugsnag.notify(ScaryException('unexpected failover'),
                       user={'name': 'bob',
                             'email': 'mcbob@example.com',
                             'id': '542347329'})
        json_body = self.server.received[0]['json_body']
        event = json_body['events'][0]
        self.assertEqual('bob', event['user']['name'])
        self.assertEqual('542347329', event['user']['id'])
        self.assertEqual('mcbob@example.com', event['user']['email'])
github bugsnag / bugsnag-python / tests / fixtures / tornado / server.py View on Github external
def get(self):
        msg = "Bugsnag Tornado demo says: False alarm, your application "
        msg += "didn't crash"
        bugsnag.notify(Exception(msg))
        self.write(
            "Bugsnag Tornado demo says: It didn't crash! But still go  " +
            "check <a href="\&quot;bugsnag.com\&quot;">bugsnag.com</a> for a new " +
            "notification.")
github bugsnag / bugsnag-python / example / flask / server.py View on Github external
def handle_zero_div():
    """Deliberately triggers a handled exception, and reports it to Bugsnag.
    """
    try:
        x = 1/0
    except Exception as e:
        bugsnag.notify(e)

    return 'The app hasn\'t crashed, but check <a href="\&quot;https://app.bugsnag.com\&quot;">app.bugsnag.com</a> to view notifications'
github bugsnag / bugsnag-python / example / flask / server.py View on Github external
def notifywithcontext():
    """Notifies Bugsnag of a handled exception, which has a modified 'context' attribute for the purpose of improving how these exceptions will group together in the Bugsnag dashboard, and a severity attribute that has been modifed to overwrite the default level (warning).
    """
    bugsnag.notify(
        Exception('Flask demo: Manual notification with context and severity'),
        context = 'notifywithcontext',
        severity = 'info'
    )
    return 'The context and severity were changed.'