Skip to content

Commit c0dfe73

Browse files
Fix readthedocs headers
1 parent 51da0a7 commit c0dfe73

File tree

8 files changed

+219
-225
lines changed
  • instrumentation
    • opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django
    • opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask
    • opentelemetry-instrumentation-mysqlclient/src/opentelemetry/instrumentation/mysqlclient
    • opentelemetry-instrumentation-mysql/src/opentelemetry/instrumentation/mysql
    • opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2
    • opentelemetry-instrumentation-psycopg/src/opentelemetry/instrumentation/psycopg
    • opentelemetry-instrumentation-pymysql/src/opentelemetry/instrumentation/pymysql
    • opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy

8 files changed

+219
-225
lines changed

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

Lines changed: 59 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -17,68 +17,6 @@
1717
1818
.. _django: https://pypi.org/project/django/
1919
20-
SQLCOMMENTER
21-
*****************************************
22-
You can optionally configure Django instrumentation to enable sqlcommenter which enriches
23-
the query with contextual information.
24-
25-
Usage
26-
-----
27-
28-
.. code:: python
29-
30-
from opentelemetry.instrumentation.django import DjangoInstrumentor
31-
32-
DjangoInstrumentor().instrument(is_sql_commentor_enabled=True)
33-
34-
35-
For example,
36-
::
37-
38-
Invoking Users().objects.all() will lead to sql query "select * from auth_users" but when SQLCommenter is enabled
39-
the query will get appended with some configurable tags like "select * from auth_users /*metrics=value*/;"
40-
41-
42-
SQLCommenter Configurations
43-
***************************
44-
We can configure the tags to be appended to the sqlquery log by adding below variables to the settings.py
45-
46-
SQLCOMMENTER_WITH_FRAMEWORK = True(Default) or False
47-
48-
For example,
49-
::
50-
Enabling this flag will add django framework and it's version which is /*framework='django%3A2.2.3*/
51-
52-
SQLCOMMENTER_WITH_CONTROLLER = True(Default) or False
53-
54-
For example,
55-
::
56-
Enabling this flag will add controller name that handles the request /*controller='index'*/
57-
58-
SQLCOMMENTER_WITH_ROUTE = True(Default) or False
59-
60-
For example,
61-
::
62-
Enabling this flag will add url path that handles the request /*route='polls/'*/
63-
64-
SQLCOMMENTER_WITH_APP_NAME = True(Default) or False
65-
66-
For example,
67-
::
68-
Enabling this flag will add app name that handles the request /*app_name='polls'*/
69-
70-
SQLCOMMENTER_WITH_OPENTELEMETRY = True(Default) or False
71-
72-
For example,
73-
::
74-
Enabling this flag will add opentelemetry traceparent /*traceparent='00-fd720cffceba94bbf75940ff3caaf3cc-4fd1a2bdacf56388-01'*/
75-
76-
SQLCOMMENTER_WITH_DB_DRIVER = True(Default) or False
77-
78-
For example,
79-
::
80-
Enabling this flag will add name of the db driver /*db_driver='django.db.backends.postgresql'*/
81-
8220
Usage
8321
-----
8422
@@ -232,6 +170,65 @@ def response_hook(span, request, response):
232170
Note:
233171
The environment variable names used to capture HTTP headers are still experimental, and thus are subject to change.
234172
173+
SQLCOMMENTER
174+
*****************************************
175+
You can optionally configure Django instrumentation to enable sqlcommenter which enriches
176+
the query with contextual information.
177+
178+
.. code:: python
179+
180+
from opentelemetry.instrumentation.django import DjangoInstrumentor
181+
182+
DjangoInstrumentor().instrument(is_sql_commentor_enabled=True)
183+
184+
185+
For example,
186+
::
187+
188+
Invoking Users().objects.all() will lead to sql query "select * from auth_users" but when SQLCommenter is enabled
189+
the query will get appended with some configurable tags like "select * from auth_users /*metrics=value*/;"
190+
191+
192+
SQLCommenter Configurations
193+
***************************
194+
We can configure the tags to be appended to the sqlquery log by adding below variables to the settings.py
195+
196+
SQLCOMMENTER_WITH_FRAMEWORK = True(Default) or False
197+
198+
For example,
199+
::
200+
Enabling this flag will add django framework and it's version which is /*framework='django%3A2.2.3*/
201+
202+
SQLCOMMENTER_WITH_CONTROLLER = True(Default) or False
203+
204+
For example,
205+
::
206+
Enabling this flag will add controller name that handles the request /*controller='index'*/
207+
208+
SQLCOMMENTER_WITH_ROUTE = True(Default) or False
209+
210+
For example,
211+
::
212+
Enabling this flag will add url path that handles the request /*route='polls/'*/
213+
214+
SQLCOMMENTER_WITH_APP_NAME = True(Default) or False
215+
216+
For example,
217+
::
218+
Enabling this flag will add app name that handles the request /*app_name='polls'*/
219+
220+
SQLCOMMENTER_WITH_OPENTELEMETRY = True(Default) or False
221+
222+
For example,
223+
::
224+
Enabling this flag will add opentelemetry traceparent /*traceparent='00-fd720cffceba94bbf75940ff3caaf3cc-4fd1a2bdacf56388-01'*/
225+
226+
SQLCOMMENTER_WITH_DB_DRIVER = True(Default) or False
227+
228+
For example,
229+
::
230+
Enabling this flag will add name of the db driver /*db_driver='django.db.backends.postgresql'*/
231+
235232
API
236233
---
237234

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

Lines changed: 49 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -24,58 +24,6 @@
2424
* The ``http.route`` Span attribute is set so that one can see which URL rule
2525
matched a request.
2626
27-
SQLCOMMENTER
28-
*****************************************
29-
You can optionally configure Flask instrumentation to enable sqlcommenter which enriches
30-
the query with contextual information.
31-
32-
Usage
33-
-----
34-
35-
.. code:: python
36-
37-
from opentelemetry.instrumentation.flask import FlaskInstrumentor
38-
39-
FlaskInstrumentor().instrument(enable_commenter=True, commenter_options={})
40-
41-
For example, FlaskInstrumentor when used with SQLAlchemyInstrumentor or Psycopg2Instrumentor,
42-
invoking ``cursor.execute("select * from auth_users")`` will lead to sql query
43-
``select * from auth_users`` but when SQLCommenter is enabled the query will get appended with
44-
some configurable tags like:
45-
46-
.. code::
47-
48-
select * from auth_users /*metrics=value*/;"
49-
50-
Inorder for the commenter to append flask related tags to sql queries, the commenter needs
51-
to enabled on the respective SQLAlchemyInstrumentor or Psycopg2Instrumentor framework too.
52-
53-
SQLCommenter Configurations
54-
***************************
55-
We can configure the tags to be appended to the sqlquery log by adding configuration
56-
inside ``commenter_options={}`` dict.
57-
58-
For example, enabling this flag will add flask and it's version which
59-
is ``/*flask%%3A2.9.3*/`` to the SQL query as a comment (default is True):
60-
61-
.. code:: python
62-
63-
framework = True
64-
65-
For example, enabling this flag will add route uri ``/*route='/home'*/``
66-
to the SQL query as a comment (default is True):
67-
68-
.. code:: python
69-
70-
route = True
71-
72-
For example, enabling this flag will add controller name ``/*controller='home_view'*/``
73-
to the SQL query as a comment (default is True):
74-
75-
.. code:: python
76-
77-
controller = True
78-
7927
Usage
8028
-----
8129
@@ -241,6 +189,55 @@ def response_hook(span: Span, status: str, response_headers: List):
241189
Note:
242190
The environment variable names used to capture HTTP headers are still experimental, and thus are subject to change.
243191
192+
SQLCOMMENTER
193+
*****************************************
194+
You can optionally configure Flask instrumentation to enable sqlcommenter which enriches
195+
the query with contextual information.
196+
197+
.. code:: python
198+
199+
from opentelemetry.instrumentation.flask import FlaskInstrumentor
200+
201+
FlaskInstrumentor().instrument(enable_commenter=True, commenter_options={})
202+
203+
For example, FlaskInstrumentor when used with SQLAlchemyInstrumentor or Psycopg2Instrumentor,
204+
invoking ``cursor.execute("select * from auth_users")`` will lead to sql query
205+
``select * from auth_users`` but when SQLCommenter is enabled the query will get appended with
206+
some configurable tags like:
207+
208+
.. code::
209+
210+
select * from auth_users /*metrics=value*/;"
211+
212+
Inorder for the commenter to append flask related tags to sql queries, the commenter needs
213+
to enabled on the respective SQLAlchemyInstrumentor or Psycopg2Instrumentor framework too.
214+
215+
SQLCommenter Configurations
216+
***************************
217+
We can configure the tags to be appended to the sqlquery log by adding configuration
218+
inside ``commenter_options={}`` dict.
219+
220+
For example, enabling this flag will add flask and it's version which
221+
is ``/*flask%%3A2.9.3*/`` to the SQL query as a comment (default is True):
222+
223+
.. code:: python
224+
225+
framework = True
226+
227+
For example, enabling this flag will add route uri ``/*route='/home'*/``
228+
to the SQL query as a comment (default is True):
229+
230+
.. code:: python
231+
232+
route = True
233+
234+
For example, enabling this flag will add controller name ``/*controller='home_view'*/``
235+
to the SQL query as a comment (default is True):
236+
237+
.. code:: python
238+
239+
controller = True
240+
244241
API
245242
---
246243
"""

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@
5050
cursor.close()
5151
instrumented_cnx.close()
5252
53+
Configuration
54+
-------------
55+
5356
SQLCOMMENTER
5457
*****************************************
5558
You can optionally configure mysql-connector instrumentation to enable sqlcommenter which enriches the query with contextual information.
5659
57-
Usage
58-
-----
59-
6060
.. code:: python
6161
6262
import mysql.connector
@@ -70,7 +70,6 @@
7070
cursor.close()
7171
cnx.close()
7272
73-
7473
For example,
7574
::
7675

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
cursor.close()
3737
cnx.close()
3838
39+
Configuration
40+
-------------
41+
3942
SQLCOMMENTER
4043
*****************************************
4144
You can optionally configure MySQLClient instrumentation to enable sqlcommenter which enriches

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

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,48 @@
1818
1919
.. _Psycopg: http://initd.org/psycopg/
2020
21+
Usage
22+
-----
23+
24+
.. code-block:: python
25+
26+
import psycopg
27+
from opentelemetry.instrumentation.psycopg import PsycopgInstrumentor
28+
29+
# Call instrument() to wrap all database connections
30+
PsycopgInstrumentor().instrument()
31+
32+
cnx = psycopg.connect(database='Database')
33+
34+
cursor = cnx.cursor()
35+
cursor.execute("CREATE TABLE IF NOT EXISTS test (testField INTEGER)")
36+
cursor.execute("INSERT INTO test (testField) VALUES (123)")
37+
cursor.close()
38+
cnx.close()
39+
40+
.. code-block:: python
41+
42+
import psycopg
43+
from opentelemetry.instrumentation.psycopg import PsycopgInstrumentor
44+
45+
# Alternatively, use instrument_connection for an individual connection
46+
cnx = psycopg.connect(database='Database')
47+
instrumented_cnx = PsycopgInstrumentor().instrument_connection(cnx)
48+
cursor = instrumented_cnx.cursor()
49+
cursor.execute("CREATE TABLE IF NOT EXISTS test (testField INTEGER)")
50+
cursor.execute("INSERT INTO test (testField) VALUES (123)")
51+
cursor.close()
52+
instrumented_cnx.close()
53+
54+
55+
Configuration
56+
-------------
57+
2158
SQLCOMMENTER
2259
*****************************************
2360
You can optionally configure Psycopg instrumentation to enable sqlcommenter which enriches
2461
the query with contextual information.
2562
26-
Usage
27-
-----
28-
2963
.. code:: python
3064
3165
from opentelemetry.instrumentation.psycopg import PsycopgInstrumentor
@@ -93,45 +127,12 @@
93127
enable_attribute_commenter=True,
94128
)
95129
96-
97130
For example,
98131
::
99132
100133
Invoking cursor.execute("select * from auth_users") will lead to postgresql query "select * from auth_users" but when SQLCommenter and attribute_commenter are enabled
101134
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.
102135
103-
Usage
104-
-----
105-
106-
.. code-block:: python
107-
108-
import psycopg
109-
from opentelemetry.instrumentation.psycopg import PsycopgInstrumentor
110-
111-
# Call instrument() to wrap all database connections
112-
PsycopgInstrumentor().instrument()
113-
114-
cnx = psycopg.connect(database='Database')
115-
116-
cursor = cnx.cursor()
117-
cursor.execute("CREATE TABLE IF NOT EXISTS test (testField INTEGER)")
118-
cursor.execute("INSERT INTO test (testField) VALUES (123)")
119-
cursor.close()
120-
cnx.close()
121-
122-
.. code-block:: python
123-
124-
import psycopg
125-
from opentelemetry.instrumentation.psycopg import PsycopgInstrumentor
126-
127-
# Alternatively, use instrument_connection for an individual connection
128-
cnx = psycopg.connect(database='Database')
129-
instrumented_cnx = PsycopgInstrumentor().instrument_connection(cnx)
130-
cursor = instrumented_cnx.cursor()
131-
cursor.execute("CREATE TABLE IF NOT EXISTS test (testField INTEGER)")
132-
cursor.execute("INSERT INTO test (testField) VALUES (123)")
133-
cursor.close()
134-
instrumented_cnx.close()
135136
136137
API
137138
---

0 commit comments

Comments
 (0)