Add callback for direct instrument

This commit is contained in:
Srikanth Chekuri
2020-11-18 19:06:25 +05:30
parent 4567715032
commit cee66ec04f
2 changed files with 38 additions and 1 deletions

View File

@ -208,3 +208,32 @@ class TestProgrammaticCustomSpanName(
span_list = self.memory_exporter.get_finished_spans()
self.assertEqual(len(span_list), 1)
self.assertEqual(span_list[0].name, "flask-custom-span-name")
class TestProgrammaticCustomSpanNameCallbackWithoutApp(
InstrumentationTest, TestBase, WsgiTestBase
):
def setUp(self):
super().setUp()
def custom_span_name():
return "instrument-without-app"
FlaskInstrumentor().instrument(name_callback=custom_span_name)
from flask import Flask
self.app = Flask(__name__)
self._common_initialization()
def tearDown(self):
super().tearDown()
with self.disable_logging():
FlaskInstrumentor().uninstrument()
def test_custom_span_name(self):
self.client.get("/hello/123")
span_list = self.memory_exporter.get_finished_spans()
self.assertEqual(len(span_list), 1)
self.assertEqual(span_list[0].name, "instrument-without-app")