|
47 | 47 | # Example: pyodbc |
48 | 48 | trace_integration(pyodbc, "Connection", "odbc") |
49 | 49 |
|
50 | | - # Or, directly call wrap_connect for more configurability |
| 50 | + # Or, directly call wrap_connect for more configurability. |
51 | 51 | wrap_connect(__name__, mysql.connector, "connect", "mysql") |
52 | 52 | wrap_connect(__name__, pyodbc, "Connection", "odbc") |
53 | 53 |
|
|
57 | 57 |
|
58 | 58 | SQLCOMMENTER |
59 | 59 | ************ |
60 | | -You can optionally configure DB-API instrumentation to enable sqlcommenter which |
| 60 | +sqlcommenter is supported by several database client framework/ORM-specific |
| 61 | +instrumentors. See their respective docs for how to opt into this feature at |
| 62 | +`instrumentation`_. There is no need to opt in at the DB-API level unless setting up |
| 63 | +its integration directly. |
| 64 | +
|
| 65 | +.. _instrumentation: https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/instrumentation |
| 66 | +
|
| 67 | +If using DB-API instrumentation directly, you can optionally enable sqlcommenter which |
61 | 68 | enriches the query with contextual information. Queries made after setting up |
62 | 69 | trace integration with sqlcommenter enabled will have configurable key-value pairs |
63 | 70 | appended to them, e.g. ``"select * from auth_users; /*metrics=value*/"``. This |
|
74 | 81 | from opentelemetry.instrumentation.dbapi import wrap_connect |
75 | 82 |
|
76 | 83 |
|
77 | | - # Opts into sqlcomment for MySQL trace integration |
| 84 | + # Opts into sqlcomment for MySQL trace integration. |
78 | 85 | wrap_connect( |
79 | 86 | __name__, |
80 | 87 | mysql.connector, |
|
86 | 93 |
|
87 | 94 | SQLCommenter Configurations |
88 | 95 | *************************** |
89 | | -When using ``wrap_connect`` for DB-API trace integration, the key-value pairs appended to the query can be configured using ``commenter_options``. When sqlcommenter is enabled, all available KVs/tags calculated by default. ``commenter_options`` supports opting out of specific KVs. |
| 96 | +sqlcommenter is supported by several database client framework/ORM-specific |
| 97 | +instrumentors. See their respective docs for how to configure this feature at |
| 98 | +`instrumentation`_. There is no need to configure at the DB-API level unless setting up |
| 99 | +its integration directly. |
| 100 | +
|
| 101 | +.. _instrumentation: https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/instrumentation |
| 102 | +
|
| 103 | +If using DB-API instrumentation directly, the key-value pairs appended to the query |
| 104 | +can be configured using ``commenter_options``. When sqlcommenter is enabled, all |
| 105 | +available KVs/tags are calculated by default. ``commenter_options`` supports *opting out* |
| 106 | +of specific KVs. |
90 | 107 |
|
91 | 108 | .. code:: python |
92 | 109 |
|
|
95 | 112 | from opentelemetry.instrumentation.dbapi import wrap_connect |
96 | 113 |
|
97 | 114 |
|
98 | | - # Opts into sqlcomment for MySQL trace integration |
99 | | - # Opts out of tags for libpq_version |
| 115 | + # Opts into sqlcomment for MySQL trace integration. |
| 116 | + # Opts out of tags for libpq_version, db_driver. |
100 | 117 | wrap_connect( |
101 | 118 | __name__, |
102 | 119 | mysql.connector, |
|
0 commit comments