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)
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)
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)
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)
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)