mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-07-30 21:56:07 +08:00
Fix lint issues
This commit is contained in:
@ -74,6 +74,7 @@ def get_excluded_urls():
|
||||
|
||||
_excluded_urls = get_excluded_urls()
|
||||
|
||||
|
||||
def get_default_span_name():
|
||||
span_name = None
|
||||
try:
|
||||
@ -82,6 +83,7 @@ def get_default_span_name():
|
||||
span_name = otel_wsgi.get_default_span_name(flask.request.environ)
|
||||
return span_name
|
||||
|
||||
|
||||
def _rewrapped_app(wsgi_app):
|
||||
def _wrapped_app(environ, start_response):
|
||||
# We want to measure the time for route matching, etc.
|
||||
@ -111,6 +113,7 @@ def _rewrapped_app(wsgi_app):
|
||||
|
||||
return _wrapped_app
|
||||
|
||||
|
||||
def _wrapped_before_request(name_callback):
|
||||
def _before_request():
|
||||
if _excluded_urls.url_disabled(flask.request.url):
|
||||
@ -143,8 +146,10 @@ def _wrapped_before_request(name_callback):
|
||||
environ[_ENVIRON_ACTIVATION_KEY] = activation
|
||||
environ[_ENVIRON_SPAN_KEY] = span
|
||||
environ[_ENVIRON_TOKEN] = token
|
||||
|
||||
return _before_request
|
||||
|
||||
|
||||
def _teardown_request(exc):
|
||||
if _excluded_urls.url_disabled(flask.request.url):
|
||||
return
|
||||
@ -191,7 +196,9 @@ class FlaskInstrumentor(BaseInstrumentor):
|
||||
self._original_flask = flask.Flask
|
||||
flask.Flask = _InstrumentedFlask
|
||||
|
||||
def instrument_app(self, app, name_callback=get_default_span_name): # pylint: disable=no-self-use
|
||||
def instrument_app(
|
||||
self, app, name_callback=get_default_span_name
|
||||
): # pylint: disable=no-self-use
|
||||
if not hasattr(app, "_is_instrumented"):
|
||||
app._is_instrumented = False
|
||||
|
||||
|
@ -179,7 +179,10 @@ class TestProgrammatic(InstrumentationTest, TestBase, WsgiTestBase):
|
||||
span_list = self.memory_exporter.get_finished_spans()
|
||||
self.assertEqual(len(span_list), 1)
|
||||
|
||||
class TestProgrammaticCustomSpanName(InstrumentationTest, TestBase, WsgiTestBase):
|
||||
|
||||
class TestProgrammaticCustomSpanName(
|
||||
InstrumentationTest, TestBase, WsgiTestBase
|
||||
):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
@ -188,7 +191,9 @@ class TestProgrammaticCustomSpanName(InstrumentationTest, TestBase, WsgiTestBase
|
||||
|
||||
self.app = Flask(__name__)
|
||||
|
||||
FlaskInstrumentor().instrument_app(self.app, name_callback=custom_span_name)
|
||||
FlaskInstrumentor().instrument_app(
|
||||
self.app, name_callback=custom_span_name
|
||||
)
|
||||
|
||||
self._common_initialization()
|
||||
|
||||
|
Reference in New Issue
Block a user