Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audit and test opentelemetry-instrumentation-flask NoOpTracerProvider #1614

Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -78,3 +79,18 @@ 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/<int:helloid>")(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)