Skip to content

Commit 893ed45

Browse files
Add docs SQLComment in span attribute
1 parent 709efbf commit 893ed45

File tree

1 file changed

+33
-0
lines changed
  • instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi

1 file changed

+33
-0
lines changed

instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,39 @@
149149
| ``opentelemetry_values`` | OpenTelemetry context as traceparent at time of query. | ``traceparent='00-03afa25236b8cd948fa853d67038ac79-405ff022e8247c46-01'`` |
150150
+---------------------------+-----------------------------------------------------------+---------------------------------------------------------------------------+
151151
152+
SQLComment in span attribute
153+
****************************
154+
sqlcommenter is supported by several Python database client framework/ORM-specific
155+
instrumentors. See their respective docs for how to opt into this feature at
156+
`instrumentation`_. There is no need to opt in at the DB-API level unless setting up
157+
its integration directly.
158+
159+
.. _instrumentation: https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/instrumentation
160+
161+
If using DB-API instrumentation directly and sqlcommenter is enabled, you can opt into
162+
the inclusion of sqlcomment in the query span ``db.statement`` attribute for your needs.
163+
If ``commenter_options`` have been set, the span attribute comment will also be configured
164+
by this setting.
165+
166+
.. code:: python
167+
168+
import mysql.connector
169+
170+
from opentelemetry.instrumentation.dbapi import wrap_connect
171+
172+
173+
# Opts into sqlcomment for MySQL trace integration.
174+
# Opts into sqlcomment for `db.statement` span attribute.
175+
wrap_connect(
176+
__name__,
177+
mysql.connector,
178+
"connect",
179+
"mysql",
180+
enable_commenter=True,
181+
enable_attribute_commenter=True,
182+
)
183+
184+
152185
API
153186
---
154187
"""

0 commit comments

Comments
 (0)