You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/__init__.py
+72-26
Original file line number
Diff line number
Diff line change
@@ -94,8 +94,9 @@
94
94
95
95
Exclude lists
96
96
*************
97
-
To exclude certain URLs from being tracked, set the environment variable ``OTEL_PYTHON_DJANGO_EXCLUDED_URLS``
98
-
(or ``OTEL_PYTHON_EXCLUDED_URLS`` as fallback) with comma delimited regexes representing which URLs to exclude.
97
+
To exclude certain URLs from tracking, set the environment variable ``OTEL_PYTHON_DJANGO_EXCLUDED_URLS``
98
+
(or ``OTEL_PYTHON_EXCLUDED_URLS`` to cover all instrumentations) to a string of comma delimited regexes that match the
99
+
URLs.
99
100
100
101
For example,
101
102
@@ -107,23 +108,24 @@
107
108
108
109
Request attributes
109
110
********************
110
-
To extract certain attributes from Django's request object and use them as span attributes, set the environment variable ``OTEL_PYTHON_DJANGO_TRACED_REQUEST_ATTRS`` to a comma
111
-
delimited list of request attribute names.
111
+
To extract attributes from Django's request object and use them as span attributes, set the environment variable
112
+
``OTEL_PYTHON_DJANGO_TRACED_REQUEST_ATTRS`` to a comma delimited list of request attribute names.
The instrumentation supports specifying request and response hooks. These are functions that get called back by the instrumentation right after a Span is created for a request
126
-
and right before the span is finished while processing a response. The hooks can be configured as follows:
126
+
This instrumentation supports request and response hooks. These are functions that get called
127
+
right after a span is created for a request and right before the span is finished for the response.
You can configure the agent to capture predefined HTTP headers as span attributes, according to the `semantic convention <https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/http.md#http-request-and-response-headers>`_.
145
+
You can configure the agent to capture specified HTTP headers as span attributes, according to the
To capture predefined HTTP request headers as span attributes, set the environment variable ``OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_REQUEST``
148
-
to a comma-separated list of HTTP header names.
150
+
To capture HTTP request headers as span attributes, set the environment variable
151
+
``OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_REQUEST`` to a comma delimited list of HTTP header names.
will extract content_type and custom_request_header from request headers and add them as span attributes.
158
+
will extract ``content-type`` and ``custom_request_header`` from the request headers and add them as span attributes.
156
159
157
-
It is recommended that you should give the correct names of the headers to be captured in the environment variable.
158
-
Request header names in django are case insensitive. So, giving header name as ``CUStom_Header`` in environment variable will be able capture header with name ``custom-header``.
160
+
Request header names in Django are case-insensitive. So, giving the header name as ``CUStom-Header`` in the environment
161
+
variable will capture the header named ``custom-header``.
159
162
160
-
The name of the added span attribute will follow the format ``http.request.header.<header_name>`` where ``<header_name>`` being the normalized HTTP header name (lowercase, with - characters replaced by _ ).
161
-
The value of the attribute will be single item list containing all the header values.
163
+
Regular expressions may also be used to match multiple headers that correspond to the given pattern. For example:
To capture predefined HTTP response headers as span attributes, set the environment variable ``OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_RESPONSE``
169
-
to a comma-separated list of HTTP header names.
184
+
To capture HTTP response headers as span attributes, set the environment variable
185
+
``OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_RESPONSE`` to a comma delimited list of HTTP header names.
will extract ``content-type`` and ``custom_response_header`` from the response headers and add them as span attributes.
175
193
176
-
will extract content_type and custom_response_header from response headers and add them as span attributes.
194
+
Response header names in Django are case-insensitive. So, giving the header name as ``CUStom-Header`` in the environment
195
+
variable will capture the header named ``custom-header``.
177
196
178
-
It is recommended that you should give the correct names of the headers to be captured in the environment variable.
179
-
Response header names captured in django are case insensitive. So, giving header name as ``CUStomHeader`` in environment variable will be able capture header with name ``customheader``.
197
+
Regular expressions may also be used to match multiple headers that correspond to the given pattern. For example:
198
+
::
180
199
181
-
The name of the added span attribute will follow the format ``http.response.header.<header_name>`` where ``<header_name>`` being the normalized HTTP header name (lowercase, with - characters replaced by _ ).
182
-
The value of the attribute will be single item list containing all the header values.
0 commit comments