Skip to content

Commit fd21563

Browse files
Fix ReadTheDocs headers and sections order for 8 Instrumentors (#3719)
* Fix readthedocs headers * Changelog * Add header
1 parent 6393e84 commit fd21563

File tree

9 files changed

+225
-227
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

9 files changed

+225
-227
lines changed

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818
- `opentelemetry-instrumentation-asgi`: Make all user hooks failsafe and record exceptions in hooks.
1919
([#3664](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3664))
2020
- `opentelemetry-instrumentation-fastapi`: Fix memory leak in `uninstrument_app()` by properly removing apps from the tracking set
21-
([#3688](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3688)
22-
- `opentelemetry-instrumentation-tornado`: Fix server (request) duration metric calculation
21+
([#3688](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3688))
22+
- `opentelemetry-instrumentation-tornado` Fix server (request) duration metric calculation
2323
([#3679](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3679))
2424
- `opentelemetry-instrumentation-tornado`: Fix to properly skip all server telemetry when URL excluded.
2525
([#3680](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3680))
2626
- `opentelemetry-instrumentation`: Avoid calls to `context.detach` with `None` token.
2727
([#3673](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3673))
2828
- `opentelemetry-instrumentation-starlette`/`opentelemetry-instrumentation-fastapi`: Fixes a crash when host-based routing is used
2929
([#3507](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3507))
30+
- Fix documentation order of sections and headers for Django, Flask, MySQL, mysqlclient, psycopg, psycopg2, pymysql, sqlalchemy instrumentations.
31+
([#3719](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3719))
3032

3133
### Added
3234

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

0 commit comments

Comments
 (0)