def setUp(self): super().setUp() FalconInstrumentor().instrument( request_hook=getattr(self, "request_hook", None), response_hook=getattr(self, "response_hook", None), ) self.app = make_app() # pylint: disable=protected-access self.env_patch = patch.dict( "os.environ", { "OTEL_PYTHON_FALCON_EXCLUDED_URLS": "ping", "OTEL_PYTHON_FALCON_TRACED_REQUEST_ATTRS": "query_string", }, ) self.env_patch.start() self.exclude_patch = patch( "opentelemetry.instrumentation.falcon._excluded_urls", get_excluded_urls("FALCON"), ) middleware = self.app._middleware[0][ # pylint:disable=W0212 0 ].__self__ self.traced_patch = patch.object( middleware, "_traced_request_attrs", get_traced_request_attrs("FALCON"), ) self.exclude_patch.start() self.traced_patch.start()
def tearDown(self): super().tearDown() with self.disable_logging(): FalconInstrumentor().uninstrument() self.env_patch.stop() self.exclude_patch.stop() self.traced_patch.stop()
def setUp(self): super().setUp() resource = Resource.create({"resource-key": "resource-value"}) result = self.create_tracer_provider(resource=resource) tracer_provider, exporter = result self.exporter = exporter FalconInstrumentor().instrument(tracer_provider=tracer_provider) self.app = make_app()
def test_uninstrument(self): self.client().simulate_get(path="/hello") spans = self.memory_exporter.get_finished_spans() self.assertEqual(len(spans), 1) self.memory_exporter.clear() FalconInstrumentor().uninstrument() self.app = make_app() self.client().simulate_get(path="/hello") spans = self.memory_exporter.get_finished_spans() self.assertEqual(len(spans), 0)
def setUp(self): super().setUp() self.env_patch = patch.dict( "os.environ", { "OTEL_PYTHON_FALCON_EXCLUDED_URLS": "ping", "OTEL_PYTHON_FALCON_TRACED_REQUEST_ATTRS": "query_string", }, ) self.env_patch.start() FalconInstrumentor().instrument( request_hook=getattr(self, "request_hook", None), response_hook=getattr(self, "response_hook", None), ) self.app = make_app()
def tearDown(self): super().tearDown() with self.disable_logging(): FalconInstrumentor().uninstrument()
def setUp(self): super().setUp() FalconInstrumentor().instrument() self.app = make_app()