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-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/__init__.py
+42-2
Original file line number
Diff line number
Diff line change
@@ -65,6 +65,30 @@
65
65
::
66
66
Enabling this flag will add traceparent values /*traceparent='00-03afa25236b8cd948fa853d67038ac79-405ff022e8247c46-01'*/
67
67
68
+
SQLComment in span attribute
69
+
****************************
70
+
If sqlcommenter is enabled, you can further configure SQLAlchemy instrumentation to append sqlcomment to the `db.statement` span attribute for convenience of your platform.
71
+
72
+
.. code:: python
73
+
74
+
from opentelemetry.instrumentation.sqlalchemy import SQLAlchemyInstrumentor
75
+
76
+
SQLAlchemyInstrumentor().instrument(
77
+
enable_commenter=True,
78
+
commenter_options={},
79
+
enable_attribute_commenter=True,
80
+
)
81
+
82
+
83
+
For example,
84
+
::
85
+
86
+
Invoking `engine.execute("select * from auth_users")` will lead to sql query "select * from auth_users" but when SQLCommenter and `attribute_commenter` is enabled
87
+
the query will get appended with some configurable tags like "select * from auth_users /*tag=value*/;" for both server query and `db.statement` span attribute.
88
+
89
+
Warning: capture of sqlcomment in ``db.statement`` may have high cardinality without platform normalization. See `Semantic Conventions for database spans <https://opentelemetry.io/docs/specs/semconv/database/database-spans/#generating-a-summary-of-the-query-text>`_ for more information.
Copy file name to clipboardexpand all lines: instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/engine.py
0 commit comments