OpenTelemetry PyMySQL Instrumentation¶
The integration with PyMySQL supports the PyMySQL library and can be enabled
by using PyMySQLInstrumentor
.
Usage¶
import pymysql
from opentelemetry import trace
from opentelemetry.instrumentation.pymysql import PyMySQLInstrumentor
from opentelemetry.sdk.trace import TracerProvider
trace.set_tracer_provider(TracerProvider())
PyMySQLInstrumentor().instrument()
cnx = pymysql.connect(database="MySQL_Database")
cursor = cnx.cursor()
cursor.execute("INSERT INTO test (testField) VALUES (123)"
cnx.commit()
cursor.close()
cnx.close()
API¶
-
class
opentelemetry.instrumentation.pymysql.
PyMySQLInstrumentor
[source]¶ Bases:
opentelemetry.instrumentation.instrumentor.BaseInstrumentor