opentelemetry-instrumentation-requests 0.45b0__py3-none-any.whl → 0.46b0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- opentelemetry/instrumentation/requests/__init__.py +44 -31
- opentelemetry/instrumentation/requests/package.py +2 -0
- opentelemetry/instrumentation/requests/version.py +1 -1
- {opentelemetry_instrumentation_requests-0.45b0.dist-info → opentelemetry_instrumentation_requests-0.46b0.dist-info}/METADATA +4 -4
- opentelemetry_instrumentation_requests-0.46b0.dist-info/RECORD +8 -0
- {opentelemetry_instrumentation_requests-0.45b0.dist-info → opentelemetry_instrumentation_requests-0.46b0.dist-info}/WHEEL +1 -1
- {opentelemetry_instrumentation_requests-0.45b0.dist-info → opentelemetry_instrumentation_requests-0.46b0.dist-info}/licenses/LICENSE +1 -1
- opentelemetry_instrumentation_requests-0.45b0.dist-info/RECORD +0 -8
- {opentelemetry_instrumentation_requests-0.45b0.dist-info → opentelemetry_instrumentation_requests-0.46b0.dist-info}/entry_points.txt +0 -0
@@ -63,18 +63,20 @@ from opentelemetry.instrumentation._semconv import (
|
|
63
63
|
_SPAN_ATTRIBUTES_ERROR_TYPE,
|
64
64
|
_SPAN_ATTRIBUTES_NETWORK_PEER_ADDRESS,
|
65
65
|
_SPAN_ATTRIBUTES_NETWORK_PEER_PORT,
|
66
|
-
|
66
|
+
_client_duration_attrs_new,
|
67
|
+
_client_duration_attrs_old,
|
68
|
+
_filter_semconv_duration_attrs,
|
67
69
|
_get_schema_url,
|
70
|
+
_HTTPStabilityMode,
|
68
71
|
_OpenTelemetrySemanticConventionStability,
|
69
|
-
_OpenTelemetryStabilityMode,
|
70
72
|
_OpenTelemetryStabilitySignalType,
|
71
73
|
_report_new,
|
72
74
|
_report_old,
|
73
|
-
|
75
|
+
_set_http_host,
|
74
76
|
_set_http_method,
|
75
|
-
|
77
|
+
_set_http_net_peer_name_client,
|
76
78
|
_set_http_network_protocol_version,
|
77
|
-
|
79
|
+
_set_http_peer_port_client,
|
78
80
|
_set_http_scheme,
|
79
81
|
_set_http_status_code,
|
80
82
|
_set_http_url,
|
@@ -117,7 +119,7 @@ def _instrument(
|
|
117
119
|
request_hook: _RequestHookT = None,
|
118
120
|
response_hook: _ResponseHookT = None,
|
119
121
|
excluded_urls: ExcludeList = None,
|
120
|
-
sem_conv_opt_in_mode:
|
122
|
+
sem_conv_opt_in_mode: _HTTPStabilityMode = _HTTPStabilityMode.DEFAULT,
|
121
123
|
):
|
122
124
|
"""Enables tracing of all requests calls that go through
|
123
125
|
:code:`requests.session.Session.request` (this includes
|
@@ -170,38 +172,40 @@ def _instrument(
|
|
170
172
|
try:
|
171
173
|
parsed_url = urlparse(url)
|
172
174
|
if parsed_url.scheme:
|
173
|
-
|
174
|
-
|
175
|
-
|
175
|
+
if _report_old(sem_conv_opt_in_mode):
|
176
|
+
# TODO: Support opt-in for url.scheme in new semconv
|
177
|
+
_set_http_scheme(
|
178
|
+
metric_labels, parsed_url.scheme, sem_conv_opt_in_mode
|
179
|
+
)
|
176
180
|
if parsed_url.hostname:
|
177
|
-
|
181
|
+
_set_http_host(
|
178
182
|
metric_labels, parsed_url.hostname, sem_conv_opt_in_mode
|
179
183
|
)
|
180
|
-
|
184
|
+
_set_http_net_peer_name_client(
|
181
185
|
metric_labels, parsed_url.hostname, sem_conv_opt_in_mode
|
182
186
|
)
|
183
187
|
if _report_new(sem_conv_opt_in_mode):
|
184
|
-
|
188
|
+
_set_http_host(
|
185
189
|
span_attributes,
|
186
190
|
parsed_url.hostname,
|
187
191
|
sem_conv_opt_in_mode,
|
188
192
|
)
|
189
193
|
# Use semconv library when available
|
190
|
-
span_attributes[
|
191
|
-
|
192
|
-
|
194
|
+
span_attributes[_SPAN_ATTRIBUTES_NETWORK_PEER_ADDRESS] = (
|
195
|
+
parsed_url.hostname
|
196
|
+
)
|
193
197
|
if parsed_url.port:
|
194
|
-
|
198
|
+
_set_http_peer_port_client(
|
195
199
|
metric_labels, parsed_url.port, sem_conv_opt_in_mode
|
196
200
|
)
|
197
201
|
if _report_new(sem_conv_opt_in_mode):
|
198
|
-
|
202
|
+
_set_http_peer_port_client(
|
199
203
|
span_attributes, parsed_url.port, sem_conv_opt_in_mode
|
200
204
|
)
|
201
205
|
# Use semconv library when available
|
202
|
-
span_attributes[
|
203
|
-
|
204
|
-
|
206
|
+
span_attributes[_SPAN_ATTRIBUTES_NETWORK_PEER_PORT] = (
|
207
|
+
parsed_url.port
|
208
|
+
)
|
205
209
|
except ValueError:
|
206
210
|
pass
|
207
211
|
|
@@ -225,9 +229,7 @@ def _instrument(
|
|
225
229
|
exception = exc
|
226
230
|
result = getattr(exc, "response", None)
|
227
231
|
finally:
|
228
|
-
elapsed_time = max(
|
229
|
-
round((default_timer() - start_time) * 1000), 0
|
230
|
-
)
|
232
|
+
elapsed_time = max(default_timer() - start_time, 0)
|
231
233
|
|
232
234
|
if isinstance(result, Response):
|
233
235
|
span_attributes = {}
|
@@ -284,16 +286,22 @@ def _instrument(
|
|
284
286
|
).__qualname__
|
285
287
|
|
286
288
|
if duration_histogram_old is not None:
|
287
|
-
duration_attrs_old =
|
288
|
-
metric_labels,
|
289
|
+
duration_attrs_old = _filter_semconv_duration_attrs(
|
290
|
+
metric_labels,
|
291
|
+
_client_duration_attrs_old,
|
292
|
+
_client_duration_attrs_new,
|
293
|
+
_HTTPStabilityMode.DEFAULT,
|
289
294
|
)
|
290
295
|
duration_histogram_old.record(
|
291
296
|
max(round(elapsed_time * 1000), 0),
|
292
297
|
attributes=duration_attrs_old,
|
293
298
|
)
|
294
299
|
if duration_histogram_new is not None:
|
295
|
-
duration_attrs_new =
|
296
|
-
metric_labels,
|
300
|
+
duration_attrs_new = _filter_semconv_duration_attrs(
|
301
|
+
metric_labels,
|
302
|
+
_client_duration_attrs_old,
|
303
|
+
_client_duration_attrs_new,
|
304
|
+
_HTTPStabilityMode.HTTP,
|
297
305
|
)
|
298
306
|
duration_histogram_new.record(
|
299
307
|
elapsed_time, attributes=duration_attrs_new
|
@@ -341,7 +349,10 @@ def get_default_span_name(method):
|
|
341
349
|
Returns:
|
342
350
|
span name
|
343
351
|
"""
|
344
|
-
|
352
|
+
method = sanitize_method(method.upper().strip())
|
353
|
+
if method == "_OTHER":
|
354
|
+
return "HTTP"
|
355
|
+
return method
|
345
356
|
|
346
357
|
|
347
358
|
class RequestsInstrumentor(BaseInstrumentor):
|
@@ -402,9 +413,11 @@ class RequestsInstrumentor(BaseInstrumentor):
|
|
402
413
|
duration_histogram_new,
|
403
414
|
request_hook=kwargs.get("request_hook"),
|
404
415
|
response_hook=kwargs.get("response_hook"),
|
405
|
-
excluded_urls=
|
406
|
-
|
407
|
-
|
416
|
+
excluded_urls=(
|
417
|
+
_excluded_urls_from_env
|
418
|
+
if excluded_urls is None
|
419
|
+
else parse_excluded_urls(excluded_urls)
|
420
|
+
),
|
408
421
|
sem_conv_opt_in_mode=semconv_opt_in_mode,
|
409
422
|
)
|
410
423
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: opentelemetry-instrumentation-requests
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.46b0
|
4
4
|
Summary: OpenTelemetry requests instrumentation
|
5
5
|
Project-URL: Homepage, https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/instrumentation/opentelemetry-instrumentation-requests
|
6
6
|
Author-email: OpenTelemetry Authors <cncf-opentelemetry-contributors@lists.cncf.io>
|
@@ -17,9 +17,9 @@ Classifier: Programming Language :: Python :: 3.10
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.11
|
18
18
|
Requires-Python: >=3.8
|
19
19
|
Requires-Dist: opentelemetry-api~=1.12
|
20
|
-
Requires-Dist: opentelemetry-instrumentation==0.
|
21
|
-
Requires-Dist: opentelemetry-semantic-conventions==0.
|
22
|
-
Requires-Dist: opentelemetry-util-http==0.
|
20
|
+
Requires-Dist: opentelemetry-instrumentation==0.46b0
|
21
|
+
Requires-Dist: opentelemetry-semantic-conventions==0.46b0
|
22
|
+
Requires-Dist: opentelemetry-util-http==0.46b0
|
23
23
|
Provides-Extra: instruments
|
24
24
|
Requires-Dist: requests~=2.0; extra == 'instruments'
|
25
25
|
Description-Content-Type: text/x-rst
|
@@ -0,0 +1,8 @@
|
|
1
|
+
opentelemetry/instrumentation/requests/__init__.py,sha256=vOwOPFyTC_QVJyCxdbjgImFmSXaUuQear832eOQgobw,15971
|
2
|
+
opentelemetry/instrumentation/requests/package.py,sha256=84lK70NyCoRefASXKjU5f4byJhf5qWDL6IdYjch-UTM,679
|
3
|
+
opentelemetry/instrumentation/requests/version.py,sha256=asa7q2ly73330-K1Q7vujpvZk7hfhasEZUzSFDPu1N8,608
|
4
|
+
opentelemetry_instrumentation_requests-0.46b0.dist-info/METADATA,sha256=RXSlzKIEUw5rHboRnl0SktLiQJQrzC8KOhtJmjUuIok,2480
|
5
|
+
opentelemetry_instrumentation_requests-0.46b0.dist-info/WHEEL,sha256=zEMcRr9Kr03x1ozGwg5v9NQBKn3kndp6LSoSlVg-jhU,87
|
6
|
+
opentelemetry_instrumentation_requests-0.46b0.dist-info/entry_points.txt,sha256=w_cFVp9h9IXzWm2YeBaOEUANSn9iuUlNAl0QC3PDf94,100
|
7
|
+
opentelemetry_instrumentation_requests-0.46b0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
8
|
+
opentelemetry_instrumentation_requests-0.46b0.dist-info/RECORD,,
|
@@ -186,7 +186,7 @@
|
|
186
186
|
same "printed page" as the copyright notice for easier
|
187
187
|
identification within third-party archives.
|
188
188
|
|
189
|
-
Copyright
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
190
190
|
|
191
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
192
192
|
you may not use this file except in compliance with the License.
|
@@ -1,8 +0,0 @@
|
|
1
|
-
opentelemetry/instrumentation/requests/__init__.py,sha256=bHMyUOO5x7CW8Tlrs34RB4SuM0BZC6bKMogCufkEB10,15466
|
2
|
-
opentelemetry/instrumentation/requests/package.py,sha256=ULOZ8NBcPPzs-WzXMXwwoMJcc2GmNARO-nzRR1gEAMU,648
|
3
|
-
opentelemetry/instrumentation/requests/version.py,sha256=HyCKkZGb11xsSYPWI9CHcfWAYU5IqDVTDpTmCwMvfu0,608
|
4
|
-
opentelemetry_instrumentation_requests-0.45b0.dist-info/METADATA,sha256=QTXSZBRHuxiJnWXIGn3lmzA8j2Ka8tw7hGYCd6TaAUI,2480
|
5
|
-
opentelemetry_instrumentation_requests-0.45b0.dist-info/WHEEL,sha256=uNdcs2TADwSd5pVaP0Z_kcjcvvTUklh2S7bxZMF8Uj0,87
|
6
|
-
opentelemetry_instrumentation_requests-0.45b0.dist-info/entry_points.txt,sha256=w_cFVp9h9IXzWm2YeBaOEUANSn9iuUlNAl0QC3PDf94,100
|
7
|
-
opentelemetry_instrumentation_requests-0.45b0.dist-info/licenses/LICENSE,sha256=h8jwqxShIeVkc8vOo9ynxGYW16f4fVPxLhZKZs0H5U8,11350
|
8
|
-
opentelemetry_instrumentation_requests-0.45b0.dist-info/RECORD,,
|