From 670c09aff2494eecd63094de74a304e253597cf8 Mon Sep 17 00:00:00 2001 From: Adi Kochavi Date: Tue, 31 Jan 2023 10:57:59 +0200 Subject: [PATCH 1/2] Audit and test opentelemetry-instrumentation-flask NoOpTracerProvider --- .../tests/test_automatic.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/instrumentation/opentelemetry-instrumentation-flask/tests/test_automatic.py b/instrumentation/opentelemetry-instrumentation-flask/tests/test_automatic.py index b4ed9eb0bc..1444b04f56 100644 --- a/instrumentation/opentelemetry-instrumentation-flask/tests/test_automatic.py +++ b/instrumentation/opentelemetry-instrumentation-flask/tests/test_automatic.py @@ -16,6 +16,7 @@ from werkzeug.test import Client from werkzeug.wrappers import Response +from opentelemetry import trace as trace_api from opentelemetry.instrumentation.flask import FlaskInstrumentor from opentelemetry.test.wsgitestutil import WsgiTestBase @@ -78,3 +79,16 @@ def test_exluded_urls_explicit(self): self.assertEqual([b"Hello: 456"], list(resp.response)) span_list = self.memory_exporter.get_finished_spans() self.assertEqual(len(span_list), 1) + + def test_no_op_tracer_provider(self): + FlaskInstrumentor().uninstrument() + FlaskInstrumentor().instrument(tracer_provider=trace_api.NoOpTracerProvider()) + + self.app = flask.Flask(__name__) + self.app.route("/hello/")(self._hello_endpoint) + # pylint: disable=attribute-defined-outside-init + self.client = Client(self.app, Response) + self.client.get("/hello/123") + + span_list = self.memory_exporter.get_finished_spans() + self.assertEqual(len(span_list), 0) From 0929d8b461a2398a85ecd97b31d5a0f9bbe7cb32 Mon Sep 17 00:00:00 2001 From: Adi Kochavi Date: Sun, 5 Feb 2023 08:56:45 +0200 Subject: [PATCH 2/2] wip --- .../tests/test_automatic.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/instrumentation/opentelemetry-instrumentation-flask/tests/test_automatic.py b/instrumentation/opentelemetry-instrumentation-flask/tests/test_automatic.py index 1444b04f56..16d299085d 100644 --- a/instrumentation/opentelemetry-instrumentation-flask/tests/test_automatic.py +++ b/instrumentation/opentelemetry-instrumentation-flask/tests/test_automatic.py @@ -82,7 +82,9 @@ def test_exluded_urls_explicit(self): def test_no_op_tracer_provider(self): FlaskInstrumentor().uninstrument() - FlaskInstrumentor().instrument(tracer_provider=trace_api.NoOpTracerProvider()) + FlaskInstrumentor().instrument( + tracer_provider=trace_api.NoOpTracerProvider() + ) self.app = flask.Flask(__name__) self.app.route("/hello/")(self._hello_endpoint)