Example #1
0
    def init_app(self, app):
        self.app = app
        if not self.client:
            self.client = make_client(
                self.client_cls,
                app,
                self.organization_id,
                self.app_id,
                self.secret_token,
            )

        if self.logging:
            setup_logging(OpbeatHandler(self.client))

        signals.got_request_exception.connect(self.handle_exception,
                                              sender=app,
                                              weak=False)

        # Instrument to get traces
        skip_env_var = 'SKIP_INSTRUMENT'
        if skip_env_var in os.environ:
            logger.debug("Skipping instrumentation. %s is set.", skip_env_var)
        else:
            opbeat.instrumentation.control.instrument()

            signals.request_started.connect(self.request_started)
            signals.request_finished.connect(self.request_finished)
Example #2
0
    def init_app(self, app):
        self.app = app
        if not self.client:
            self.client = make_client(
                self.client_cls, app,
                self.organization_id, self.app_id, self.secret_token
            )

        if self.logging:
            setup_logging(OpbeatHandler(self.client))

        got_request_exception.connect(self.handle_exception, sender=app, weak=False)
Example #3
0
    def init_app(self, app):
        self.app = app
        if not self.client:
            self.client = make_client(
                self.client_cls, app,
                self.organization_id, self.app_id, self.secret_token
            )

        if self.logging:
            setup_logging(OpbeatHandler(self.client))

        got_request_exception.connect(self.handle_exception, sender=app, weak=False)
Example #4
0
 def test_basic_not_configured(self):
     with mock.patch('logging.getLogger', spec=logging.getLogger) as getLogger:
         logger = getLogger()
         logger.handlers = []
         handler = mock.Mock()
         result = setup_logging(handler)
         self.assertTrue(result)
Example #5
0
 def test_basic_already_configured(self):
     with mock.patch('logging.getLogger', spec=logging.getLogger) as getLogger:
         handler = mock.Mock()
         logger = getLogger()
         logger.handlers = [handler]
         result = setup_logging(handler)
         self.assertFalse(result)
Example #6
0
    def init_app(self, app):
        self.app = app
        if not self.client:
            self.client = make_client(
                self.client_cls, app, self.organization_id,
                self.app_id, self.secret_token,
            )

        if self.logging:
            setup_logging(OpbeatHandler(self.client))

        signals.got_request_exception.connect(self.handle_exception, sender=app, weak=False)

        # Instrument to get traces
        skip_env_var = 'SKIP_INSTRUMENT'
        if skip_env_var in os.environ:
            logger.debug("Skipping instrumentation. %s is set.", skip_env_var)
        else:
            opbeat.instrumentation.control.instrument()

            signals.request_started.connect(self.request_started, sender=app)
            signals.request_finished.connect(self.request_finished, sender=app)