opentelemetry-instrumentation-requests 0.49b2__py3-none-any.whl → 0.51b0__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 +16 -12
- opentelemetry/instrumentation/requests/py.typed +0 -0
- opentelemetry/instrumentation/requests/version.py +1 -1
- {opentelemetry_instrumentation_requests-0.49b2.dist-info → opentelemetry_instrumentation_requests-0.51b0.dist-info}/METADATA +9 -6
- opentelemetry_instrumentation_requests-0.51b0.dist-info/RECORD +9 -0
- {opentelemetry_instrumentation_requests-0.49b2.dist-info → opentelemetry_instrumentation_requests-0.51b0.dist-info}/WHEEL +1 -1
- opentelemetry_instrumentation_requests-0.49b2.dist-info/RECORD +0 -8
- {opentelemetry_instrumentation_requests-0.49b2.dist-info → opentelemetry_instrumentation_requests-0.51b0.dist-info}/entry_points.txt +0 -0
- {opentelemetry_instrumentation_requests-0.49b2.dist-info → opentelemetry_instrumentation_requests-0.51b0.dist-info}/licenses/LICENSE +0 -0
@@ -72,10 +72,12 @@ API
|
|
72
72
|
---
|
73
73
|
"""
|
74
74
|
|
75
|
+
from __future__ import annotations
|
76
|
+
|
75
77
|
import functools
|
76
78
|
import types
|
77
79
|
from timeit import default_timer
|
78
|
-
from typing import Callable, Collection, Optional
|
80
|
+
from typing import Any, Callable, Collection, Optional
|
79
81
|
from urllib.parse import urlparse
|
80
82
|
|
81
83
|
from requests.models import PreparedRequest, Response
|
@@ -87,7 +89,6 @@ from opentelemetry.instrumentation._semconv import (
|
|
87
89
|
_client_duration_attrs_old,
|
88
90
|
_filter_semconv_duration_attrs,
|
89
91
|
_get_schema_url,
|
90
|
-
_HTTPStabilityMode,
|
91
92
|
_OpenTelemetrySemanticConventionStability,
|
92
93
|
_OpenTelemetryStabilitySignalType,
|
93
94
|
_report_new,
|
@@ -100,6 +101,7 @@ from opentelemetry.instrumentation._semconv import (
|
|
100
101
|
_set_http_scheme,
|
101
102
|
_set_http_status_code,
|
102
103
|
_set_http_url,
|
104
|
+
_StabilityMode,
|
103
105
|
)
|
104
106
|
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
105
107
|
from opentelemetry.instrumentation.requests.package import _instruments
|
@@ -146,8 +148,8 @@ def _instrument(
|
|
146
148
|
duration_histogram_new: Histogram,
|
147
149
|
request_hook: _RequestHookT = None,
|
148
150
|
response_hook: _ResponseHookT = None,
|
149
|
-
excluded_urls: ExcludeList = None,
|
150
|
-
sem_conv_opt_in_mode:
|
151
|
+
excluded_urls: ExcludeList | None = None,
|
152
|
+
sem_conv_opt_in_mode: _StabilityMode = _StabilityMode.DEFAULT,
|
151
153
|
):
|
152
154
|
"""Enables tracing of all requests calls that go through
|
153
155
|
:code:`requests.session.Session.request` (this includes
|
@@ -164,7 +166,9 @@ def _instrument(
|
|
164
166
|
|
165
167
|
# pylint: disable-msg=too-many-locals,too-many-branches
|
166
168
|
@functools.wraps(wrapped_send)
|
167
|
-
def instrumented_send(
|
169
|
+
def instrumented_send(
|
170
|
+
self: Session, request: PreparedRequest, **kwargs: Any
|
171
|
+
):
|
168
172
|
if excluded_urls and excluded_urls.url_disabled(request.url):
|
169
173
|
return wrapped_send(self, request, **kwargs)
|
170
174
|
|
@@ -312,7 +316,7 @@ def _instrument(
|
|
312
316
|
metric_labels,
|
313
317
|
_client_duration_attrs_old,
|
314
318
|
_client_duration_attrs_new,
|
315
|
-
|
319
|
+
_StabilityMode.DEFAULT,
|
316
320
|
)
|
317
321
|
duration_histogram_old.record(
|
318
322
|
max(round(elapsed_time * 1000), 0),
|
@@ -323,7 +327,7 @@ def _instrument(
|
|
323
327
|
metric_labels,
|
324
328
|
_client_duration_attrs_old,
|
325
329
|
_client_duration_attrs_new,
|
326
|
-
|
330
|
+
_StabilityMode.HTTP,
|
327
331
|
)
|
328
332
|
duration_histogram_new.record(
|
329
333
|
elapsed_time, attributes=duration_attrs_new
|
@@ -345,7 +349,7 @@ def _uninstrument():
|
|
345
349
|
_uninstrument_from(Session)
|
346
350
|
|
347
351
|
|
348
|
-
def _uninstrument_from(instr_root, restore_as_bound_func=False):
|
352
|
+
def _uninstrument_from(instr_root, restore_as_bound_func: bool = False):
|
349
353
|
for instr_func_name in ("request", "send"):
|
350
354
|
instr_func = getattr(instr_root, instr_func_name)
|
351
355
|
if not getattr(
|
@@ -361,7 +365,7 @@ def _uninstrument_from(instr_root, restore_as_bound_func=False):
|
|
361
365
|
setattr(instr_root, instr_func_name, original)
|
362
366
|
|
363
367
|
|
364
|
-
def get_default_span_name(method):
|
368
|
+
def get_default_span_name(method: str) -> str:
|
365
369
|
"""
|
366
370
|
Default implementation for name_callback, returns HTTP {method_name}.
|
367
371
|
https://opentelemetry.io/docs/reference/specification/trace/semantic_conventions/http/#name
|
@@ -385,7 +389,7 @@ class RequestsInstrumentor(BaseInstrumentor):
|
|
385
389
|
def instrumentation_dependencies(self) -> Collection[str]:
|
386
390
|
return _instruments
|
387
391
|
|
388
|
-
def _instrument(self, **kwargs):
|
392
|
+
def _instrument(self, **kwargs: Any):
|
389
393
|
"""Instruments requests module
|
390
394
|
|
391
395
|
Args:
|
@@ -443,10 +447,10 @@ class RequestsInstrumentor(BaseInstrumentor):
|
|
443
447
|
sem_conv_opt_in_mode=semconv_opt_in_mode,
|
444
448
|
)
|
445
449
|
|
446
|
-
def _uninstrument(self, **kwargs):
|
450
|
+
def _uninstrument(self, **kwargs: Any):
|
447
451
|
_uninstrument()
|
448
452
|
|
449
453
|
@staticmethod
|
450
|
-
def uninstrument_session(session):
|
454
|
+
def uninstrument_session(session: Session):
|
451
455
|
"""Disables instrumentation on the session object."""
|
452
456
|
_uninstrument_from(session, restore_as_bound_func=True)
|
File without changes
|
@@ -1,10 +1,12 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: opentelemetry-instrumentation-requests
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.51b0
|
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
|
+
Project-URL: Repository, https://github.com/open-telemetry/opentelemetry-python-contrib
|
6
7
|
Author-email: OpenTelemetry Authors <cncf-opentelemetry-contributors@lists.cncf.io>
|
7
|
-
License: Apache-2.0
|
8
|
+
License-Expression: Apache-2.0
|
9
|
+
License-File: LICENSE
|
8
10
|
Classifier: Development Status :: 4 - Beta
|
9
11
|
Classifier: Intended Audience :: Developers
|
10
12
|
Classifier: License :: OSI Approved :: Apache Software License
|
@@ -15,11 +17,12 @@ Classifier: Programming Language :: Python :: 3.9
|
|
15
17
|
Classifier: Programming Language :: Python :: 3.10
|
16
18
|
Classifier: Programming Language :: Python :: 3.11
|
17
19
|
Classifier: Programming Language :: Python :: 3.12
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
18
21
|
Requires-Python: >=3.8
|
19
22
|
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.
|
23
|
+
Requires-Dist: opentelemetry-instrumentation==0.51b0
|
24
|
+
Requires-Dist: opentelemetry-semantic-conventions==0.51b0
|
25
|
+
Requires-Dist: opentelemetry-util-http==0.51b0
|
23
26
|
Provides-Extra: instruments
|
24
27
|
Requires-Dist: requests~=2.0; extra == 'instruments'
|
25
28
|
Description-Content-Type: text/x-rst
|
@@ -0,0 +1,9 @@
|
|
1
|
+
opentelemetry/instrumentation/requests/__init__.py,sha256=24iS_STwslzfaCXzZlQYJrbiF4MHvHUsb8oafsB2UFU,16735
|
2
|
+
opentelemetry/instrumentation/requests/package.py,sha256=84lK70NyCoRefASXKjU5f4byJhf5qWDL6IdYjch-UTM,679
|
3
|
+
opentelemetry/instrumentation/requests/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
|
+
opentelemetry/instrumentation/requests/version.py,sha256=xU54GoF0aIm8WYGdGIfcg45s1dMdG2m5bpBCICAKNEo,608
|
5
|
+
opentelemetry_instrumentation_requests-0.51b0.dist-info/METADATA,sha256=dZlBI5uIujBpPOy20SHZ1RIofSLqmOoOvbQiUO4z0Hs,2670
|
6
|
+
opentelemetry_instrumentation_requests-0.51b0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
7
|
+
opentelemetry_instrumentation_requests-0.51b0.dist-info/entry_points.txt,sha256=w_cFVp9h9IXzWm2YeBaOEUANSn9iuUlNAl0QC3PDf94,100
|
8
|
+
opentelemetry_instrumentation_requests-0.51b0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
9
|
+
opentelemetry_instrumentation_requests-0.51b0.dist-info/RECORD,,
|
@@ -1,8 +0,0 @@
|
|
1
|
-
opentelemetry/instrumentation/requests/__init__.py,sha256=GGN5ykITzJitPTZJX76PjBUvLxNWXjUx9Ap7UNaV7mM,16623
|
2
|
-
opentelemetry/instrumentation/requests/package.py,sha256=84lK70NyCoRefASXKjU5f4byJhf5qWDL6IdYjch-UTM,679
|
3
|
-
opentelemetry/instrumentation/requests/version.py,sha256=Axuk6SG7SQR82yhUQ-qxl0W3DkT1XdtfwpB4A3PI6pM,608
|
4
|
-
opentelemetry_instrumentation_requests-0.49b2.dist-info/METADATA,sha256=_SGZzXeMxGK8veD5tifmBq2RIjywvmiR8rTnMKsScbk,2498
|
5
|
-
opentelemetry_instrumentation_requests-0.49b2.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
6
|
-
opentelemetry_instrumentation_requests-0.49b2.dist-info/entry_points.txt,sha256=w_cFVp9h9IXzWm2YeBaOEUANSn9iuUlNAl0QC3PDf94,100
|
7
|
-
opentelemetry_instrumentation_requests-0.49b2.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
8
|
-
opentelemetry_instrumentation_requests-0.49b2.dist-info/RECORD,,
|
File without changes
|