mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-08-02 02:52:18 +08:00
Improve mysqlclient instrumentation examples (#3470)
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
This commit is contained in:

committed by
GitHub

parent
02dc87ef73
commit
9d41f9bf10
@ -26,12 +26,12 @@ Usage
|
||||
import MySQLdb
|
||||
from opentelemetry.instrumentation.mysqlclient import MySQLClientInstrumentor
|
||||
|
||||
|
||||
MySQLClientInstrumentor().instrument()
|
||||
|
||||
cnx = MySQLdb.connect(database="MySQL_Database")
|
||||
cursor = cnx.cursor()
|
||||
cursor.execute("INSERT INTO test (testField) VALUES (123)"
|
||||
cursor.execute("CREATE TABLE IF NOT EXISTS test (testField INTEGER)")
|
||||
cursor.execute("INSERT INTO test (testField) VALUES (123)")
|
||||
cnx.commit()
|
||||
cursor.close()
|
||||
cnx.close()
|
||||
@ -52,7 +52,7 @@ the query with contextual information.
|
||||
cnx = MySQLdb.connect(database="MySQL_Database")
|
||||
cursor = cnx.cursor()
|
||||
cursor.execute("CREATE TABLE IF NOT EXISTS test (testField INTEGER)")
|
||||
cursor.execute("INSERT INTO test (testField) VALUES (123)"
|
||||
cursor.execute("INSERT INTO test (testField) VALUES (123)")
|
||||
cnx.commit()
|
||||
cursor.close()
|
||||
cnx.close()
|
||||
@ -75,7 +75,7 @@ the query with contextual information.
|
||||
)
|
||||
cursor = instrumented_cnx.cursor()
|
||||
cursor.execute("CREATE TABLE IF NOT EXISTS test (testField INTEGER)")
|
||||
cursor.execute("INSERT INTO test (testField) VALUES (123)"
|
||||
cursor.execute("INSERT INTO test (testField) VALUES (123)")
|
||||
instrumented_cnx.commit()
|
||||
cursor.close()
|
||||
instrumented_cnx.close()
|
||||
|
Reference in New Issue
Block a user