|
24 | 24 | * The ``http.route`` Span attribute is set so that one can see which URL rule |
25 | 25 | matched a request. |
26 | 26 |
|
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 | | -
|
79 | 27 | Usage |
80 | 28 | ----- |
81 | 29 |
|
@@ -241,6 +189,55 @@ def response_hook(span: Span, status: str, response_headers: List): |
241 | 189 | Note: |
242 | 190 | The environment variable names used to capture HTTP headers are still experimental, and thus are subject to change. |
243 | 191 |
|
| 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 | +
|
244 | 241 | API |
245 | 242 | --- |
246 | 243 | """ |
|
0 commit comments