opentelemetry-instrumentation-requests 0.54b1__tar.gz → 0.55b1__tar.gz
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-0.54b1 → opentelemetry_instrumentation_requests-0.55b1}/PKG-INFO +5 -6
- {opentelemetry_instrumentation_requests-0.54b1 → opentelemetry_instrumentation_requests-0.55b1}/pyproject.toml +4 -5
- {opentelemetry_instrumentation_requests-0.54b1 → opentelemetry_instrumentation_requests-0.55b1}/src/opentelemetry/instrumentation/requests/__init__.py +6 -3
- {opentelemetry_instrumentation_requests-0.54b1 → opentelemetry_instrumentation_requests-0.55b1}/src/opentelemetry/instrumentation/requests/version.py +1 -1
- {opentelemetry_instrumentation_requests-0.54b1 → opentelemetry_instrumentation_requests-0.55b1}/tests/test_requests_integration.py +60 -53
- {opentelemetry_instrumentation_requests-0.54b1 → opentelemetry_instrumentation_requests-0.55b1}/.gitignore +0 -0
- {opentelemetry_instrumentation_requests-0.54b1 → opentelemetry_instrumentation_requests-0.55b1}/LICENSE +0 -0
- {opentelemetry_instrumentation_requests-0.54b1 → opentelemetry_instrumentation_requests-0.55b1}/README.rst +0 -0
- {opentelemetry_instrumentation_requests-0.54b1 → opentelemetry_instrumentation_requests-0.55b1}/src/opentelemetry/instrumentation/requests/package.py +0 -0
- {opentelemetry_instrumentation_requests-0.54b1 → opentelemetry_instrumentation_requests-0.55b1}/src/opentelemetry/instrumentation/requests/py.typed +0 -0
- {opentelemetry_instrumentation_requests-0.54b1 → opentelemetry_instrumentation_requests-0.55b1}/tests/__init__.py +0 -0
- {opentelemetry_instrumentation_requests-0.54b1 → opentelemetry_instrumentation_requests-0.55b1}/tests/test_requests_ip_support.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: opentelemetry-instrumentation-requests
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.55b1
|
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
|
Project-URL: Repository, https://github.com/open-telemetry/opentelemetry-python-contrib
|
@@ -12,17 +12,16 @@ Classifier: Intended Audience :: Developers
|
|
12
12
|
Classifier: License :: OSI Approved :: Apache Software License
|
13
13
|
Classifier: Programming Language :: Python
|
14
14
|
Classifier: Programming Language :: Python :: 3
|
15
|
-
Classifier: Programming Language :: Python :: 3.8
|
16
15
|
Classifier: Programming Language :: Python :: 3.9
|
17
16
|
Classifier: Programming Language :: Python :: 3.10
|
18
17
|
Classifier: Programming Language :: Python :: 3.11
|
19
18
|
Classifier: Programming Language :: Python :: 3.12
|
20
19
|
Classifier: Programming Language :: Python :: 3.13
|
21
|
-
Requires-Python: >=3.
|
20
|
+
Requires-Python: >=3.9
|
22
21
|
Requires-Dist: opentelemetry-api~=1.12
|
23
|
-
Requires-Dist: opentelemetry-instrumentation==0.
|
24
|
-
Requires-Dist: opentelemetry-semantic-conventions==0.
|
25
|
-
Requires-Dist: opentelemetry-util-http==0.
|
22
|
+
Requires-Dist: opentelemetry-instrumentation==0.55b1
|
23
|
+
Requires-Dist: opentelemetry-semantic-conventions==0.55b1
|
24
|
+
Requires-Dist: opentelemetry-util-http==0.55b1
|
26
25
|
Provides-Extra: instruments
|
27
26
|
Requires-Dist: requests~=2.0; extra == 'instruments'
|
28
27
|
Description-Content-Type: text/x-rst
|
@@ -8,7 +8,7 @@ dynamic = ["version"]
|
|
8
8
|
description = "OpenTelemetry requests instrumentation"
|
9
9
|
readme = "README.rst"
|
10
10
|
license = "Apache-2.0"
|
11
|
-
requires-python = ">=3.
|
11
|
+
requires-python = ">=3.9"
|
12
12
|
authors = [
|
13
13
|
{ name = "OpenTelemetry Authors", email = "cncf-opentelemetry-contributors@lists.cncf.io" },
|
14
14
|
]
|
@@ -18,7 +18,6 @@ classifiers = [
|
|
18
18
|
"License :: OSI Approved :: Apache Software License",
|
19
19
|
"Programming Language :: Python",
|
20
20
|
"Programming Language :: Python :: 3",
|
21
|
-
"Programming Language :: Python :: 3.8",
|
22
21
|
"Programming Language :: Python :: 3.9",
|
23
22
|
"Programming Language :: Python :: 3.10",
|
24
23
|
"Programming Language :: Python :: 3.11",
|
@@ -27,9 +26,9 @@ classifiers = [
|
|
27
26
|
]
|
28
27
|
dependencies = [
|
29
28
|
"opentelemetry-api ~= 1.12",
|
30
|
-
"opentelemetry-instrumentation == 0.
|
31
|
-
"opentelemetry-semantic-conventions == 0.
|
32
|
-
"opentelemetry-util-http == 0.
|
29
|
+
"opentelemetry-instrumentation == 0.55b1",
|
30
|
+
"opentelemetry-semantic-conventions == 0.55b1",
|
31
|
+
"opentelemetry-util-http == 0.55b1",
|
33
32
|
]
|
34
33
|
|
35
34
|
[project.optional-dependencies]
|
@@ -287,9 +287,12 @@ def _instrument(
|
|
287
287
|
except ValueError:
|
288
288
|
pass
|
289
289
|
|
290
|
-
with
|
291
|
-
|
292
|
-
|
290
|
+
with (
|
291
|
+
tracer.start_as_current_span(
|
292
|
+
span_name, kind=SpanKind.CLIENT, attributes=span_attributes
|
293
|
+
) as span,
|
294
|
+
set_ip_on_next_http_connection(span),
|
295
|
+
):
|
293
296
|
exception = None
|
294
297
|
if callable(request_hook):
|
295
298
|
request_hook(span, request)
|
@@ -35,6 +35,18 @@ from opentelemetry.instrumentation.utils import (
|
|
35
35
|
)
|
36
36
|
from opentelemetry.propagate import get_global_textmap, set_global_textmap
|
37
37
|
from opentelemetry.sdk import resources
|
38
|
+
from opentelemetry.semconv._incubating.attributes.http_attributes import (
|
39
|
+
HTTP_FLAVOR,
|
40
|
+
HTTP_HOST,
|
41
|
+
HTTP_METHOD,
|
42
|
+
HTTP_SCHEME,
|
43
|
+
HTTP_STATUS_CODE,
|
44
|
+
HTTP_URL,
|
45
|
+
)
|
46
|
+
from opentelemetry.semconv._incubating.attributes.net_attributes import (
|
47
|
+
NET_PEER_NAME,
|
48
|
+
NET_PEER_PORT,
|
49
|
+
)
|
38
50
|
from opentelemetry.semconv.attributes.error_attributes import ERROR_TYPE
|
39
51
|
from opentelemetry.semconv.attributes.http_attributes import (
|
40
52
|
HTTP_REQUEST_METHOD,
|
@@ -51,7 +63,6 @@ from opentelemetry.semconv.attributes.server_attributes import (
|
|
51
63
|
SERVER_PORT,
|
52
64
|
)
|
53
65
|
from opentelemetry.semconv.attributes.url_attributes import URL_FULL
|
54
|
-
from opentelemetry.semconv.trace import SpanAttributes
|
55
66
|
from opentelemetry.test.mock_textmap import MockTextMapPropagator
|
56
67
|
from opentelemetry.test.test_base import TestBase
|
57
68
|
from opentelemetry.trace import StatusCode
|
@@ -161,9 +172,9 @@ class RequestsIntegrationTestBase(abc.ABC):
|
|
161
172
|
self.assertEqual(
|
162
173
|
span.attributes,
|
163
174
|
{
|
164
|
-
|
165
|
-
|
166
|
-
|
175
|
+
HTTP_METHOD: "GET",
|
176
|
+
HTTP_URL: self.URL,
|
177
|
+
HTTP_STATUS_CODE: 200,
|
167
178
|
},
|
168
179
|
)
|
169
180
|
|
@@ -187,7 +198,7 @@ class RequestsIntegrationTestBase(abc.ABC):
|
|
187
198
|
|
188
199
|
self.assertEqual(
|
189
200
|
span.instrumentation_scope.schema_url,
|
190
|
-
|
201
|
+
"https://opentelemetry.io/schemas/1.21.0",
|
191
202
|
)
|
192
203
|
self.assertEqual(
|
193
204
|
span.attributes,
|
@@ -223,22 +234,22 @@ class RequestsIntegrationTestBase(abc.ABC):
|
|
223
234
|
|
224
235
|
self.assertEqual(
|
225
236
|
span.instrumentation_scope.schema_url,
|
226
|
-
|
237
|
+
"https://opentelemetry.io/schemas/1.21.0",
|
227
238
|
)
|
228
239
|
self.assertEqual(
|
229
240
|
span.attributes,
|
230
241
|
{
|
231
|
-
|
242
|
+
HTTP_METHOD: "GET",
|
232
243
|
HTTP_REQUEST_METHOD: "GET",
|
233
|
-
|
244
|
+
HTTP_URL: url_with_port,
|
234
245
|
URL_FULL: url_with_port,
|
235
|
-
|
246
|
+
HTTP_HOST: "mock",
|
236
247
|
SERVER_ADDRESS: "mock",
|
237
248
|
NETWORK_PEER_ADDRESS: "mock",
|
238
|
-
|
239
|
-
|
249
|
+
NET_PEER_PORT: 80,
|
250
|
+
HTTP_STATUS_CODE: 200,
|
240
251
|
HTTP_RESPONSE_STATUS_CODE: 200,
|
241
|
-
|
252
|
+
HTTP_FLAVOR: "1.1",
|
242
253
|
NETWORK_PROTOCOL_VERSION: "1.1",
|
243
254
|
SERVER_PORT: 80,
|
244
255
|
NETWORK_PEER_PORT: 80,
|
@@ -262,9 +273,9 @@ class RequestsIntegrationTestBase(abc.ABC):
|
|
262
273
|
self.assertEqual(
|
263
274
|
span.attributes,
|
264
275
|
{
|
265
|
-
|
266
|
-
|
267
|
-
|
276
|
+
HTTP_METHOD: "_OTHER",
|
277
|
+
HTTP_URL: self.URL,
|
278
|
+
HTTP_STATUS_CODE: 405,
|
268
279
|
},
|
269
280
|
)
|
270
281
|
|
@@ -365,9 +376,7 @@ class RequestsIntegrationTestBase(abc.ABC):
|
|
365
376
|
|
366
377
|
span = self.assert_span()
|
367
378
|
|
368
|
-
self.assertEqual(
|
369
|
-
span.attributes.get(SpanAttributes.HTTP_STATUS_CODE), 404
|
370
|
-
)
|
379
|
+
self.assertEqual(span.attributes.get(HTTP_STATUS_CODE), 404)
|
371
380
|
|
372
381
|
self.assertIs(
|
373
382
|
span.status.status_code,
|
@@ -406,9 +415,7 @@ class RequestsIntegrationTestBase(abc.ABC):
|
|
406
415
|
|
407
416
|
span = self.assert_span()
|
408
417
|
|
409
|
-
self.assertEqual(
|
410
|
-
span.attributes.get(SpanAttributes.HTTP_STATUS_CODE), 404
|
411
|
-
)
|
418
|
+
self.assertEqual(span.attributes.get(HTTP_STATUS_CODE), 404)
|
412
419
|
self.assertEqual(span.attributes.get(HTTP_RESPONSE_STATUS_CODE), 404)
|
413
420
|
self.assertEqual(span.attributes.get(ERROR_TYPE), "404")
|
414
421
|
|
@@ -523,9 +530,9 @@ class RequestsIntegrationTestBase(abc.ABC):
|
|
523
530
|
self.assertEqual(
|
524
531
|
span.attributes,
|
525
532
|
{
|
526
|
-
|
527
|
-
|
528
|
-
|
533
|
+
HTTP_METHOD: "GET",
|
534
|
+
HTTP_URL: self.URL,
|
535
|
+
HTTP_STATUS_CODE: 200,
|
529
536
|
"http.response.body": "Hello!",
|
530
537
|
},
|
531
538
|
)
|
@@ -555,8 +562,8 @@ class RequestsIntegrationTestBase(abc.ABC):
|
|
555
562
|
self.assertEqual(
|
556
563
|
span.attributes,
|
557
564
|
{
|
558
|
-
|
559
|
-
|
565
|
+
HTTP_METHOD: "GET",
|
566
|
+
HTTP_URL: self.URL,
|
560
567
|
},
|
561
568
|
)
|
562
569
|
self.assertEqual(span.status.status_code, StatusCode.ERROR)
|
@@ -604,8 +611,8 @@ class RequestsIntegrationTestBase(abc.ABC):
|
|
604
611
|
self.assertEqual(
|
605
612
|
span.attributes,
|
606
613
|
{
|
607
|
-
|
608
|
-
|
614
|
+
HTTP_METHOD: "GET",
|
615
|
+
HTTP_URL: self.URL,
|
609
616
|
},
|
610
617
|
)
|
611
618
|
self.assertEqual(span.status.status_code, StatusCode.ERROR)
|
@@ -626,9 +633,9 @@ class RequestsIntegrationTestBase(abc.ABC):
|
|
626
633
|
self.assertEqual(
|
627
634
|
span.attributes,
|
628
635
|
{
|
629
|
-
|
630
|
-
|
631
|
-
|
636
|
+
HTTP_METHOD: "GET",
|
637
|
+
HTTP_URL: self.URL,
|
638
|
+
HTTP_STATUS_CODE: 500,
|
632
639
|
},
|
633
640
|
)
|
634
641
|
self.assertEqual(span.status.status_code, StatusCode.ERROR)
|
@@ -684,7 +691,7 @@ class TestRequestsIntegration(RequestsIntegrationTestBase, TestBase):
|
|
684
691
|
self.perform_request(new_url)
|
685
692
|
span = self.assert_span()
|
686
693
|
|
687
|
-
self.assertEqual(span.attributes[
|
694
|
+
self.assertEqual(span.attributes[HTTP_URL], self.URL)
|
688
695
|
|
689
696
|
def test_if_headers_equals_none(self):
|
690
697
|
result = requests.get(self.URL, headers=None, timeout=5)
|
@@ -745,13 +752,13 @@ class TestRequestsIntergrationMetric(TestBase):
|
|
745
752
|
self.perform_request(self.URL)
|
746
753
|
|
747
754
|
expected_attributes = {
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
+
HTTP_STATUS_CODE: 200,
|
756
|
+
HTTP_HOST: "examplehost",
|
757
|
+
NET_PEER_PORT: 8000,
|
758
|
+
NET_PEER_NAME: "examplehost",
|
759
|
+
HTTP_METHOD: "GET",
|
760
|
+
HTTP_FLAVOR: "1.1",
|
761
|
+
HTTP_SCHEME: "http",
|
755
762
|
}
|
756
763
|
|
757
764
|
for (
|
@@ -809,13 +816,13 @@ class TestRequestsIntergrationMetric(TestBase):
|
|
809
816
|
self.perform_request(self.URL)
|
810
817
|
|
811
818
|
expected_attributes_old = {
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
+
HTTP_STATUS_CODE: 200,
|
820
|
+
HTTP_HOST: "examplehost",
|
821
|
+
NET_PEER_PORT: 8000,
|
822
|
+
NET_PEER_NAME: "examplehost",
|
823
|
+
HTTP_METHOD: "GET",
|
824
|
+
HTTP_FLAVOR: "1.1",
|
825
|
+
HTTP_SCHEME: "http",
|
819
826
|
}
|
820
827
|
|
821
828
|
expected_attributes_new = {
|
@@ -879,13 +886,13 @@ class TestRequestsIntergrationMetric(TestBase):
|
|
879
886
|
|
880
887
|
def test_basic_metric_non_recording_span(self):
|
881
888
|
expected_attributes = {
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
+
HTTP_STATUS_CODE: 200,
|
890
|
+
HTTP_HOST: "examplehost",
|
891
|
+
NET_PEER_PORT: 8000,
|
892
|
+
NET_PEER_NAME: "examplehost",
|
893
|
+
HTTP_METHOD: "GET",
|
894
|
+
HTTP_FLAVOR: "1.1",
|
895
|
+
HTTP_SCHEME: "http",
|
889
896
|
}
|
890
897
|
|
891
898
|
with mock.patch("opentelemetry.trace.INVALID_SPAN") as mock_span:
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|