You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: instrumentation/opentelemetry-instrumentation-pymysql/src/opentelemetry/instrumentation/pymysql/__init__.py
+76-1Lines changed: 76 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -36,6 +36,70 @@
36
36
cursor.close()
37
37
cnx.close()
38
38
39
+
SQLCOMMENTER
40
+
*****************************************
41
+
You can optionally configure PyMySQL instrumentation to enable sqlcommenter which enriches
42
+
the query with contextual information.
43
+
44
+
.. code:: python
45
+
46
+
import MySQLdb
47
+
from opentelemetry.instrumentation.pymysql import PyMySQLInstrumentor
cursor.execute("INSERT INTO test (testField) VALUES (123)"
54
+
cnx.commit()
55
+
cursor.close()
56
+
cnx.close()
57
+
58
+
For example,
59
+
::
60
+
Invoking cursor.execute("INSERT INTO test (testField) VALUES (123)") will lead to sql query "INSERT INTO test (testField) VALUES (123)" but when SQLCommenter is enabled
61
+
the query will get appended with some configurable tags like "INSERT INTO test (testField) VALUES (123) /*tag=value*/;"
62
+
63
+
SQLCommenter Configurations
64
+
***************************
65
+
We can configure the tags to be appended to the sqlquery log by adding configuration inside commenter_options(default:{}) keyword
66
+
67
+
db_driver = True(Default) or False
68
+
69
+
For example,
70
+
::
71
+
Enabling this flag will add MySQLdb and its version, e.g. /*MySQLdb%%3A1.2.3*/
72
+
73
+
dbapi_threadsafety = True(Default) or False
74
+
75
+
For example,
76
+
::
77
+
Enabling this flag will add threadsafety /*dbapi_threadsafety=2*/
78
+
79
+
dbapi_level = True(Default) or False
80
+
81
+
For example,
82
+
::
83
+
Enabling this flag will add dbapi_level /*dbapi_level='2.0'*/
84
+
85
+
mysql_client_version = True(Default) or False
86
+
87
+
For example,
88
+
::
89
+
Enabling this flag will add mysql_client_version /*mysql_client_version='123'*/
90
+
91
+
driver_paramstyle = True(Default) or False
92
+
93
+
For example,
94
+
::
95
+
Enabling this flag will add driver_paramstyle /*driver_paramstyle='pyformat'*/
96
+
97
+
opentelemetry_values = True(Default) or False
98
+
99
+
For example,
100
+
::
101
+
Enabling this flag will add traceparent values /*traceparent='00-03afa25236b8cd948fa853d67038ac79-405ff022e8247c46-01'*/
0 commit comments