From 260df4dc6db865e0725c7d101b01a3323dd9cdd5 Mon Sep 17 00:00:00 2001 From: Akochavi <121871419+Akochavi@users.noreply.github.com> Date: Mon, 13 Feb 2023 11:49:17 +0200 Subject: [PATCH] Audit and test opentelemetry-instrumentation-flask NoOpTracerProvider (#1614) --- .../tests/test_automatic.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/instrumentation/opentelemetry-instrumentation-flask/tests/test_automatic.py b/instrumentation/opentelemetry-instrumentation-flask/tests/test_automatic.py index b4ed9eb0b..16d299085 100644 --- a/instrumentation/opentelemetry-instrumentation-flask/tests/test_automatic.py +++ b/instrumentation/opentelemetry-instrumentation-flask/tests/test_automatic.py @@ -16,6 +16,7 @@ import flask 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,18 @@ class TestAutomatic(InstrumentationTest, WsgiTestBase): 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)