Fix docker tests

This commit is contained in:
Srikanth Chekuri
2020-11-18 01:41:59 +05:30
parent bd39b36b82
commit 2228573bf3
4 changed files with 90 additions and 86 deletions

View File

@ -20,11 +20,11 @@ from opentelemetry import trace as trace_api
from opentelemetry.instrumentation.mysql import MySQLInstrumentor from opentelemetry.instrumentation.mysql import MySQLInstrumentor
from opentelemetry.test.test_base import TestBase from opentelemetry.test.test_base import TestBase
MYSQL_USER = os.getenv("MYSQL_USER ", "testuser") MYSQL_USER = os.getenv("MYSQL_USER", "testuser")
MYSQL_PASSWORD = os.getenv("MYSQL_PASSWORD ", "testpassword") MYSQL_PASSWORD = os.getenv("MYSQL_PASSWORD", "testpassword")
MYSQL_HOST = os.getenv("MYSQL_HOST ", "localhost") MYSQL_HOST = os.getenv("MYSQL_HOST", "localhost")
MYSQL_PORT = int(os.getenv("MYSQL_PORT ", "3306")) MYSQL_PORT = int(os.getenv("MYSQL_PORT", "3306"))
MYSQL_DB_NAME = os.getenv("MYSQL_DB_NAME ", "opentelemetry-tests") MYSQL_DB_NAME = os.getenv("MYSQL_DB_NAME", "opentelemetry-tests")
class TestFunctionalMysql(TestBase): class TestFunctionalMysql(TestBase):
@ -53,7 +53,7 @@ class TestFunctionalMysql(TestBase):
) )
self._cursor = self._connection.cursor() self._cursor = self._connection.cursor()
def validate_spans(self): def validate_spans(self, span_name):
spans = self.memory_exporter.get_finished_spans() spans = self.memory_exporter.get_finished_spans()
self.assertEqual(len(spans), 2) self.assertEqual(len(spans), 2)
for span in spans: for span in spans:
@ -66,42 +66,47 @@ class TestFunctionalMysql(TestBase):
self.assertIsNotNone(root_span) self.assertIsNotNone(root_span)
self.assertIsNotNone(db_span) self.assertIsNotNone(db_span)
self.assertEqual(root_span.name, "rootSpan") self.assertEqual(root_span.name, "rootSpan")
self.assertEqual(db_span.name, "mysql.opentelemetry-tests") self.assertEqual(db_span.name, span_name)
self.assertIsNotNone(db_span.parent) self.assertIsNotNone(db_span.parent)
self.assertIs(db_span.parent, root_span.get_span_context()) self.assertIs(db_span.parent, root_span.get_span_context())
self.assertIs(db_span.kind, trace_api.SpanKind.CLIENT) self.assertIs(db_span.kind, trace_api.SpanKind.CLIENT)
self.assertEqual(db_span.attributes["db.instance"], MYSQL_DB_NAME) self.assertEqual(db_span.attributes["db.system"], "mysql")
self.assertEqual(db_span.attributes["db.name"], MYSQL_DB_NAME)
self.assertEqual(db_span.attributes["db.user"], MYSQL_USER)
self.assertEqual(db_span.attributes["net.peer.name"], MYSQL_HOST) self.assertEqual(db_span.attributes["net.peer.name"], MYSQL_HOST)
self.assertEqual(db_span.attributes["net.peer.port"], MYSQL_PORT) self.assertEqual(db_span.attributes["net.peer.port"], MYSQL_PORT)
def test_execute(self): def test_execute(self):
"""Should create a child span for execute""" """Should create a child span for execute"""
stmt = "CREATE TABLE IF NOT EXISTS test (id INT)"
with self._tracer.start_as_current_span("rootSpan"): with self._tracer.start_as_current_span("rootSpan"):
self._cursor.execute("CREATE TABLE IF NOT EXISTS test (id INT)") self._cursor.execute(stmt)
self.validate_spans() self.validate_spans(stmt)
def test_execute_with_connection_context_manager(self): def test_execute_with_connection_context_manager(self):
"""Should create a child span for execute with connection context""" """Should create a child span for execute with connection context"""
stmt = "CREATE TABLE IF NOT EXISTS test (id INT)"
with self._tracer.start_as_current_span("rootSpan"): with self._tracer.start_as_current_span("rootSpan"):
with self._connection as conn: with self._connection as conn:
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute("CREATE TABLE IF NOT EXISTS test (id INT)") cursor.execute(stmt)
self.validate_spans() self.validate_spans(stmt)
def test_execute_with_cursor_context_manager(self): def test_execute_with_cursor_context_manager(self):
"""Should create a child span for execute with cursor context""" """Should create a child span for execute with cursor context"""
stmt = "CREATE TABLE IF NOT EXISTS test (id INT)"
with self._tracer.start_as_current_span("rootSpan"): with self._tracer.start_as_current_span("rootSpan"):
with self._connection.cursor() as cursor: with self._connection.cursor() as cursor:
cursor.execute("CREATE TABLE IF NOT EXISTS test (id INT)") cursor.execute(stmt)
self.validate_spans() self.validate_spans(stmt)
def test_executemany(self): def test_executemany(self):
"""Should create a child span for executemany""" """Should create a child span for executemany"""
stmt = "INSERT INTO test (id) VALUES (%s)"
with self._tracer.start_as_current_span("rootSpan"): with self._tracer.start_as_current_span("rootSpan"):
data = (("1",), ("2",), ("3",)) data = (("1",), ("2",), ("3",))
stmt = "INSERT INTO test (id) VALUES (%s)"
self._cursor.executemany(stmt, data) self._cursor.executemany(stmt, data)
self.validate_spans() self.validate_spans(stmt)
def test_callproc(self): def test_callproc(self):
"""Should create a child span for callproc""" """Should create a child span for callproc"""
@ -109,4 +114,4 @@ class TestFunctionalMysql(TestBase):
Exception Exception
): ):
self._cursor.callproc("test", ()) self._cursor.callproc("test", ())
self.validate_spans() self.validate_spans("test")

View File

@ -22,11 +22,11 @@ from opentelemetry import trace as trace_api
from opentelemetry.instrumentation.aiopg import AiopgInstrumentor from opentelemetry.instrumentation.aiopg import AiopgInstrumentor
from opentelemetry.test.test_base import TestBase from opentelemetry.test.test_base import TestBase
POSTGRES_HOST = os.getenv("POSTGRESQL_HOST ", "localhost") POSTGRES_HOST = os.getenv("POSTGRESQL_HOST", "localhost")
POSTGRES_PORT = int(os.getenv("POSTGRESQL_PORT ", "5432")) POSTGRES_PORT = int(os.getenv("POSTGRESQL_PORT", "5432"))
POSTGRES_DB_NAME = os.getenv("POSTGRESQL_DB_NAME ", "opentelemetry-tests") POSTGRES_DB_NAME = os.getenv("POSTGRESQL_DB_NAME", "opentelemetry-tests")
POSTGRES_PASSWORD = os.getenv("POSTGRESQL_HOST ", "testpassword") POSTGRES_PASSWORD = os.getenv("POSTGRESQL_PASSWORD", "testpassword")
POSTGRES_USER = os.getenv("POSTGRESQL_HOST ", "testuser") POSTGRES_USER = os.getenv("POSTGRESQL_USER", "testuser")
def async_call(coro): def async_call(coro):
@ -61,7 +61,7 @@ class TestFunctionalAiopgConnect(TestBase):
cls._connection.close() cls._connection.close()
AiopgInstrumentor().uninstrument() AiopgInstrumentor().uninstrument()
def validate_spans(self): def validate_spans(self, span_name):
spans = self.memory_exporter.get_finished_spans() spans = self.memory_exporter.get_finished_spans()
self.assertEqual(len(spans), 2) self.assertEqual(len(spans), 2)
for span in spans: for span in spans:
@ -74,34 +74,31 @@ class TestFunctionalAiopgConnect(TestBase):
self.assertIsNotNone(root_span) self.assertIsNotNone(root_span)
self.assertIsNotNone(child_span) self.assertIsNotNone(child_span)
self.assertEqual(root_span.name, "rootSpan") self.assertEqual(root_span.name, "rootSpan")
self.assertEqual(child_span.name, "postgresql.opentelemetry-tests") self.assertEqual(child_span.name, span_name)
self.assertIsNotNone(child_span.parent) self.assertIsNotNone(child_span.parent)
self.assertIs(child_span.parent, root_span.get_span_context()) self.assertIs(child_span.parent, root_span.get_span_context())
self.assertIs(child_span.kind, trace_api.SpanKind.CLIENT) self.assertIs(child_span.kind, trace_api.SpanKind.CLIENT)
self.assertEqual( self.assertEqual(child_span.attributes["db.system"], "postgresql")
child_span.attributes["db.instance"], POSTGRES_DB_NAME self.assertEqual(child_span.attributes["db.name"], POSTGRES_DB_NAME)
) self.assertEqual(child_span.attributes["db.user"], POSTGRES_USER)
self.assertEqual(child_span.attributes["net.peer.name"], POSTGRES_HOST) self.assertEqual(child_span.attributes["net.peer.name"], POSTGRES_HOST)
self.assertEqual(child_span.attributes["net.peer.port"], POSTGRES_PORT) self.assertEqual(child_span.attributes["net.peer.port"], POSTGRES_PORT)
def test_execute(self): def test_execute(self):
"""Should create a child span for execute method""" """Should create a child span for execute method"""
stmt = "CREATE TABLE IF NOT EXISTS test (id integer)"
with self._tracer.start_as_current_span("rootSpan"): with self._tracer.start_as_current_span("rootSpan"):
async_call( async_call(self._cursor.execute(stmt))
self._cursor.execute( self.validate_spans(stmt)
"CREATE TABLE IF NOT EXISTS test (id integer)"
)
)
self.validate_spans()
def test_executemany(self): def test_executemany(self):
"""Should create a child span for executemany""" """Should create a child span for executemany"""
stmt = "INSERT INTO test (id) VALUES (%s)"
with pytest.raises(psycopg2.ProgrammingError): with pytest.raises(psycopg2.ProgrammingError):
with self._tracer.start_as_current_span("rootSpan"): with self._tracer.start_as_current_span("rootSpan"):
data = (("1",), ("2",), ("3",)) data = (("1",), ("2",), ("3",))
stmt = "INSERT INTO test (id) VALUES (%s)"
async_call(self._cursor.executemany(stmt, data)) async_call(self._cursor.executemany(stmt, data))
self.validate_spans() self.validate_spans(stmt)
def test_callproc(self): def test_callproc(self):
"""Should create a child span for callproc""" """Should create a child span for callproc"""
@ -109,7 +106,7 @@ class TestFunctionalAiopgConnect(TestBase):
Exception Exception
): ):
async_call(self._cursor.callproc("test", ())) async_call(self._cursor.callproc("test", ()))
self.validate_spans() self.validate_spans("test")
class TestFunctionalAiopgCreatePool(TestBase): class TestFunctionalAiopgCreatePool(TestBase):
@ -142,7 +139,7 @@ class TestFunctionalAiopgCreatePool(TestBase):
cls._pool.close() cls._pool.close()
AiopgInstrumentor().uninstrument() AiopgInstrumentor().uninstrument()
def validate_spans(self): def validate_spans(self, span_name):
spans = self.memory_exporter.get_finished_spans() spans = self.memory_exporter.get_finished_spans()
self.assertEqual(len(spans), 2) self.assertEqual(len(spans), 2)
for span in spans: for span in spans:
@ -155,34 +152,31 @@ class TestFunctionalAiopgCreatePool(TestBase):
self.assertIsNotNone(root_span) self.assertIsNotNone(root_span)
self.assertIsNotNone(child_span) self.assertIsNotNone(child_span)
self.assertEqual(root_span.name, "rootSpan") self.assertEqual(root_span.name, "rootSpan")
self.assertEqual(child_span.name, "postgresql.opentelemetry-tests") self.assertEqual(child_span.name, span_name)
self.assertIsNotNone(child_span.parent) self.assertIsNotNone(child_span.parent)
self.assertIs(child_span.parent, root_span.get_span_context()) self.assertIs(child_span.parent, root_span.get_span_context())
self.assertIs(child_span.kind, trace_api.SpanKind.CLIENT) self.assertIs(child_span.kind, trace_api.SpanKind.CLIENT)
self.assertEqual( self.assertEqual(child_span.attributes["db.system"], "postgresql")
child_span.attributes["db.instance"], POSTGRES_DB_NAME self.assertEqual(child_span.attributes["db.name"], POSTGRES_DB_NAME)
) self.assertEqual(child_span.attributes["db.user"], POSTGRES_USER)
self.assertEqual(child_span.attributes["net.peer.name"], POSTGRES_HOST) self.assertEqual(child_span.attributes["net.peer.name"], POSTGRES_HOST)
self.assertEqual(child_span.attributes["net.peer.port"], POSTGRES_PORT) self.assertEqual(child_span.attributes["net.peer.port"], POSTGRES_PORT)
def test_execute(self): def test_execute(self):
"""Should create a child span for execute method""" """Should create a child span for execute method"""
stmt = "CREATE TABLE IF NOT EXISTS test (id integer)"
with self._tracer.start_as_current_span("rootSpan"): with self._tracer.start_as_current_span("rootSpan"):
async_call( async_call(self._cursor.execute(stmt))
self._cursor.execute( self.validate_spans(stmt)
"CREATE TABLE IF NOT EXISTS test (id integer)"
)
)
self.validate_spans()
def test_executemany(self): def test_executemany(self):
"""Should create a child span for executemany""" """Should create a child span for executemany"""
stmt = "INSERT INTO test (id) VALUES (%s)"
with pytest.raises(psycopg2.ProgrammingError): with pytest.raises(psycopg2.ProgrammingError):
with self._tracer.start_as_current_span("rootSpan"): with self._tracer.start_as_current_span("rootSpan"):
data = (("1",), ("2",), ("3",)) data = (("1",), ("2",), ("3",))
stmt = "INSERT INTO test (id) VALUES (%s)"
async_call(self._cursor.executemany(stmt, data)) async_call(self._cursor.executemany(stmt, data))
self.validate_spans() self.validate_spans(stmt)
def test_callproc(self): def test_callproc(self):
"""Should create a child span for callproc""" """Should create a child span for callproc"""
@ -190,4 +184,4 @@ class TestFunctionalAiopgCreatePool(TestBase):
Exception Exception
): ):
async_call(self._cursor.callproc("test", ())) async_call(self._cursor.callproc("test", ()))
self.validate_spans() self.validate_spans("test")

View File

@ -20,11 +20,11 @@ from opentelemetry import trace as trace_api
from opentelemetry.instrumentation.psycopg2 import Psycopg2Instrumentor from opentelemetry.instrumentation.psycopg2 import Psycopg2Instrumentor
from opentelemetry.test.test_base import TestBase from opentelemetry.test.test_base import TestBase
POSTGRES_HOST = os.getenv("POSTGRESQL_HOST ", "localhost") POSTGRES_HOST = os.getenv("POSTGRESQL_HOST", "localhost")
POSTGRES_PORT = int(os.getenv("POSTGRESQL_PORT ", "5432")) POSTGRES_PORT = int(os.getenv("POSTGRESQL_PORT", "5432"))
POSTGRES_DB_NAME = os.getenv("POSTGRESQL_DB_NAME ", "opentelemetry-tests") POSTGRES_DB_NAME = os.getenv("POSTGRESQL_DB_NAME", "opentelemetry-tests")
POSTGRES_PASSWORD = os.getenv("POSTGRESQL_HOST ", "testpassword") POSTGRES_PASSWORD = os.getenv("POSTGRESQL_PASSWORD", "testpassword")
POSTGRES_USER = os.getenv("POSTGRESQL_HOST ", "testuser") POSTGRES_USER = os.getenv("POSTGRESQL_USER", "testuser")
class TestFunctionalPsycopg(TestBase): class TestFunctionalPsycopg(TestBase):
@ -53,7 +53,7 @@ class TestFunctionalPsycopg(TestBase):
cls._connection.close() cls._connection.close()
Psycopg2Instrumentor().uninstrument() Psycopg2Instrumentor().uninstrument()
def validate_spans(self): def validate_spans(self, span_name):
spans = self.memory_exporter.get_finished_spans() spans = self.memory_exporter.get_finished_spans()
self.assertEqual(len(spans), 2) self.assertEqual(len(spans), 2)
for span in spans: for span in spans:
@ -66,47 +66,48 @@ class TestFunctionalPsycopg(TestBase):
self.assertIsNotNone(root_span) self.assertIsNotNone(root_span)
self.assertIsNotNone(child_span) self.assertIsNotNone(child_span)
self.assertEqual(root_span.name, "rootSpan") self.assertEqual(root_span.name, "rootSpan")
self.assertEqual(child_span.name, "postgresql.opentelemetry-tests") self.assertEqual(child_span.name, span_name)
self.assertIsNotNone(child_span.parent) self.assertIsNotNone(child_span.parent)
self.assertIs(child_span.parent, root_span.get_span_context()) self.assertIs(child_span.parent, root_span.get_span_context())
self.assertIs(child_span.kind, trace_api.SpanKind.CLIENT) self.assertIs(child_span.kind, trace_api.SpanKind.CLIENT)
self.assertEqual( self.assertEqual(child_span.attributes["db.system"], "postgresql")
child_span.attributes["db.instance"], POSTGRES_DB_NAME self.assertEqual(child_span.attributes["db.name"], POSTGRES_DB_NAME)
) self.assertEqual(child_span.attributes["db.user"], POSTGRES_USER)
self.assertEqual(child_span.attributes["net.peer.name"], POSTGRES_HOST) self.assertEqual(child_span.attributes["net.peer.name"], POSTGRES_HOST)
self.assertEqual(child_span.attributes["net.peer.port"], POSTGRES_PORT) self.assertEqual(child_span.attributes["net.peer.port"], POSTGRES_PORT)
def test_execute(self): def test_execute(self):
"""Should create a child span for execute method""" """Should create a child span for execute method"""
stmt = "CREATE TABLE IF NOT EXISTS test (id integer)"
with self._tracer.start_as_current_span("rootSpan"): with self._tracer.start_as_current_span("rootSpan"):
self._cursor.execute( self._cursor.execute(stmt)
"CREATE TABLE IF NOT EXISTS test (id integer)" self.validate_spans(stmt)
)
self.validate_spans()
def test_execute_with_connection_context_manager(self): def test_execute_with_connection_context_manager(self):
"""Should create a child span for execute with connection context""" """Should create a child span for execute with connection context"""
stmt = "CREATE TABLE IF NOT EXISTS test (id INT)"
with self._tracer.start_as_current_span("rootSpan"): with self._tracer.start_as_current_span("rootSpan"):
with self._connection as conn: with self._connection as conn:
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute("CREATE TABLE IF NOT EXISTS test (id INT)") cursor.execute(stmt)
self.validate_spans() self.validate_spans(stmt)
def test_execute_with_cursor_context_manager(self): def test_execute_with_cursor_context_manager(self):
"""Should create a child span for execute with cursor context""" """Should create a child span for execute with cursor context"""
stmt = "CREATE TABLE IF NOT EXISTS test (id INT)"
with self._tracer.start_as_current_span("rootSpan"): with self._tracer.start_as_current_span("rootSpan"):
with self._connection.cursor() as cursor: with self._connection.cursor() as cursor:
cursor.execute("CREATE TABLE IF NOT EXISTS test (id INT)") cursor.execute(stmt)
self.validate_spans() self.validate_spans(stmt)
self.assertTrue(cursor.closed) self.assertTrue(cursor.closed)
def test_executemany(self): def test_executemany(self):
"""Should create a child span for executemany""" """Should create a child span for executemany"""
stmt = "INSERT INTO test (id) VALUES (%s)"
with self._tracer.start_as_current_span("rootSpan"): with self._tracer.start_as_current_span("rootSpan"):
data = (("1",), ("2",), ("3",)) data = (("1",), ("2",), ("3",))
stmt = "INSERT INTO test (id) VALUES (%s)"
self._cursor.executemany(stmt, data) self._cursor.executemany(stmt, data)
self.validate_spans() self.validate_spans(stmt)
def test_callproc(self): def test_callproc(self):
"""Should create a child span for callproc""" """Should create a child span for callproc"""
@ -114,4 +115,4 @@ class TestFunctionalPsycopg(TestBase):
Exception Exception
): ):
self._cursor.callproc("test", ()) self._cursor.callproc("test", ())
self.validate_spans() self.validate_spans("test")

View File

@ -20,11 +20,11 @@ from opentelemetry import trace as trace_api
from opentelemetry.instrumentation.pymysql import PyMySQLInstrumentor from opentelemetry.instrumentation.pymysql import PyMySQLInstrumentor
from opentelemetry.test.test_base import TestBase from opentelemetry.test.test_base import TestBase
MYSQL_USER = os.getenv("MYSQL_USER ", "testuser") MYSQL_USER = os.getenv("MYSQL_USER", "testuser")
MYSQL_PASSWORD = os.getenv("MYSQL_PASSWORD ", "testpassword") MYSQL_PASSWORD = os.getenv("MYSQL_PASSWORD", "testpassword")
MYSQL_HOST = os.getenv("MYSQL_HOST ", "localhost") MYSQL_HOST = os.getenv("MYSQL_HOST", "localhost")
MYSQL_PORT = int(os.getenv("MYSQL_PORT ", "3306")) MYSQL_PORT = int(os.getenv("MYSQL_PORT", "3306"))
MYSQL_DB_NAME = os.getenv("MYSQL_DB_NAME ", "opentelemetry-tests") MYSQL_DB_NAME = os.getenv("MYSQL_DB_NAME", "opentelemetry-tests")
class TestFunctionalPyMysql(TestBase): class TestFunctionalPyMysql(TestBase):
@ -50,7 +50,7 @@ class TestFunctionalPyMysql(TestBase):
cls._connection.close() cls._connection.close()
PyMySQLInstrumentor().uninstrument() PyMySQLInstrumentor().uninstrument()
def validate_spans(self): def validate_spans(self, span_name):
spans = self.memory_exporter.get_finished_spans() spans = self.memory_exporter.get_finished_spans()
self.assertEqual(len(spans), 2) self.assertEqual(len(spans), 2)
for span in spans: for span in spans:
@ -63,34 +63,38 @@ class TestFunctionalPyMysql(TestBase):
self.assertIsNotNone(root_span) self.assertIsNotNone(root_span)
self.assertIsNotNone(db_span) self.assertIsNotNone(db_span)
self.assertEqual(root_span.name, "rootSpan") self.assertEqual(root_span.name, "rootSpan")
self.assertEqual(db_span.name, "mysql.opentelemetry-tests") self.assertEqual(db_span.name, span_name)
self.assertIsNotNone(db_span.parent) self.assertIsNotNone(db_span.parent)
self.assertIs(db_span.parent, root_span.get_span_context()) self.assertIs(db_span.parent, root_span.get_span_context())
self.assertIs(db_span.kind, trace_api.SpanKind.CLIENT) self.assertIs(db_span.kind, trace_api.SpanKind.CLIENT)
self.assertEqual(db_span.attributes["db.instance"], MYSQL_DB_NAME) self.assertEqual(db_span.attributes["db.system"], "mysql")
self.assertEqual(db_span.attributes["db.name"], MYSQL_DB_NAME)
self.assertEqual(db_span.attributes["db.user"], MYSQL_USER)
self.assertEqual(db_span.attributes["net.peer.name"], MYSQL_HOST) self.assertEqual(db_span.attributes["net.peer.name"], MYSQL_HOST)
self.assertEqual(db_span.attributes["net.peer.port"], MYSQL_PORT) self.assertEqual(db_span.attributes["net.peer.port"], MYSQL_PORT)
def test_execute(self): def test_execute(self):
"""Should create a child span for execute""" """Should create a child span for execute"""
stmt = "CREATE TABLE IF NOT EXISTS test (id INT)"
with self._tracer.start_as_current_span("rootSpan"): with self._tracer.start_as_current_span("rootSpan"):
self._cursor.execute("CREATE TABLE IF NOT EXISTS test (id INT)") self._cursor.execute(stmt)
self.validate_spans() self.validate_spans(stmt)
def test_execute_with_cursor_context_manager(self): def test_execute_with_cursor_context_manager(self):
"""Should create a child span for execute with cursor context""" """Should create a child span for execute with cursor context"""
stmt = "CREATE TABLE IF NOT EXISTS test (id INT)"
with self._tracer.start_as_current_span("rootSpan"): with self._tracer.start_as_current_span("rootSpan"):
with self._connection.cursor() as cursor: with self._connection.cursor() as cursor:
cursor.execute("CREATE TABLE IF NOT EXISTS test (id INT)") cursor.execute(stmt)
self.validate_spans() self.validate_spans(stmt)
def test_executemany(self): def test_executemany(self):
"""Should create a child span for executemany""" """Should create a child span for executemany"""
stmt = "INSERT INTO test (id) VALUES (%s)"
with self._tracer.start_as_current_span("rootSpan"): with self._tracer.start_as_current_span("rootSpan"):
data = (("1",), ("2",), ("3",)) data = (("1",), ("2",), ("3",))
stmt = "INSERT INTO test (id) VALUES (%s)"
self._cursor.executemany(stmt, data) self._cursor.executemany(stmt, data)
self.validate_spans() self.validate_spans(stmt)
def test_callproc(self): def test_callproc(self):
"""Should create a child span for callproc""" """Should create a child span for callproc"""
@ -98,4 +102,4 @@ class TestFunctionalPyMysql(TestBase):
Exception Exception
): ):
self._cursor.callproc("test", ()) self._cursor.callproc("test", ())
self.validate_spans() self.validate_spans("test")