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.
Files changed (12) hide show
  1. {opentelemetry_instrumentation_requests-0.54b1 → opentelemetry_instrumentation_requests-0.55b1}/PKG-INFO +5 -6
  2. {opentelemetry_instrumentation_requests-0.54b1 → opentelemetry_instrumentation_requests-0.55b1}/pyproject.toml +4 -5
  3. {opentelemetry_instrumentation_requests-0.54b1 → opentelemetry_instrumentation_requests-0.55b1}/src/opentelemetry/instrumentation/requests/__init__.py +6 -3
  4. {opentelemetry_instrumentation_requests-0.54b1 → opentelemetry_instrumentation_requests-0.55b1}/src/opentelemetry/instrumentation/requests/version.py +1 -1
  5. {opentelemetry_instrumentation_requests-0.54b1 → opentelemetry_instrumentation_requests-0.55b1}/tests/test_requests_integration.py +60 -53
  6. {opentelemetry_instrumentation_requests-0.54b1 → opentelemetry_instrumentation_requests-0.55b1}/.gitignore +0 -0
  7. {opentelemetry_instrumentation_requests-0.54b1 → opentelemetry_instrumentation_requests-0.55b1}/LICENSE +0 -0
  8. {opentelemetry_instrumentation_requests-0.54b1 → opentelemetry_instrumentation_requests-0.55b1}/README.rst +0 -0
  9. {opentelemetry_instrumentation_requests-0.54b1 → opentelemetry_instrumentation_requests-0.55b1}/src/opentelemetry/instrumentation/requests/package.py +0 -0
  10. {opentelemetry_instrumentation_requests-0.54b1 → opentelemetry_instrumentation_requests-0.55b1}/src/opentelemetry/instrumentation/requests/py.typed +0 -0
  11. {opentelemetry_instrumentation_requests-0.54b1 → opentelemetry_instrumentation_requests-0.55b1}/tests/__init__.py +0 -0
  12. {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.54b1
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.8
20
+ Requires-Python: >=3.9
22
21
  Requires-Dist: opentelemetry-api~=1.12
23
- Requires-Dist: opentelemetry-instrumentation==0.54b1
24
- Requires-Dist: opentelemetry-semantic-conventions==0.54b1
25
- Requires-Dist: opentelemetry-util-http==0.54b1
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.8"
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.54b1",
31
- "opentelemetry-semantic-conventions == 0.54b1",
32
- "opentelemetry-util-http == 0.54b1",
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 tracer.start_as_current_span(
291
- span_name, kind=SpanKind.CLIENT, attributes=span_attributes
292
- ) as span, set_ip_on_next_http_connection(span):
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)
@@ -12,4 +12,4 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- __version__ = "0.54b1"
15
+ __version__ = "0.55b1"
@@ -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
- SpanAttributes.HTTP_METHOD: "GET",
165
- SpanAttributes.HTTP_URL: self.URL,
166
- SpanAttributes.HTTP_STATUS_CODE: 200,
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
- SpanAttributes.SCHEMA_URL,
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
- SpanAttributes.SCHEMA_URL,
237
+ "https://opentelemetry.io/schemas/1.21.0",
227
238
  )
228
239
  self.assertEqual(
229
240
  span.attributes,
230
241
  {
231
- SpanAttributes.HTTP_METHOD: "GET",
242
+ HTTP_METHOD: "GET",
232
243
  HTTP_REQUEST_METHOD: "GET",
233
- SpanAttributes.HTTP_URL: url_with_port,
244
+ HTTP_URL: url_with_port,
234
245
  URL_FULL: url_with_port,
235
- SpanAttributes.HTTP_HOST: "mock",
246
+ HTTP_HOST: "mock",
236
247
  SERVER_ADDRESS: "mock",
237
248
  NETWORK_PEER_ADDRESS: "mock",
238
- SpanAttributes.NET_PEER_PORT: 80,
239
- SpanAttributes.HTTP_STATUS_CODE: 200,
249
+ NET_PEER_PORT: 80,
250
+ HTTP_STATUS_CODE: 200,
240
251
  HTTP_RESPONSE_STATUS_CODE: 200,
241
- SpanAttributes.HTTP_FLAVOR: "1.1",
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
- SpanAttributes.HTTP_METHOD: "_OTHER",
266
- SpanAttributes.HTTP_URL: self.URL,
267
- SpanAttributes.HTTP_STATUS_CODE: 405,
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
- SpanAttributes.HTTP_METHOD: "GET",
527
- SpanAttributes.HTTP_URL: self.URL,
528
- SpanAttributes.HTTP_STATUS_CODE: 200,
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
- SpanAttributes.HTTP_METHOD: "GET",
559
- SpanAttributes.HTTP_URL: self.URL,
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
- SpanAttributes.HTTP_METHOD: "GET",
608
- SpanAttributes.HTTP_URL: self.URL,
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
- SpanAttributes.HTTP_METHOD: "GET",
630
- SpanAttributes.HTTP_URL: self.URL,
631
- SpanAttributes.HTTP_STATUS_CODE: 500,
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[SpanAttributes.HTTP_URL], self.URL)
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
- SpanAttributes.HTTP_STATUS_CODE: 200,
749
- SpanAttributes.HTTP_HOST: "examplehost",
750
- SpanAttributes.NET_PEER_PORT: 8000,
751
- SpanAttributes.NET_PEER_NAME: "examplehost",
752
- SpanAttributes.HTTP_METHOD: "GET",
753
- SpanAttributes.HTTP_FLAVOR: "1.1",
754
- SpanAttributes.HTTP_SCHEME: "http",
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
- SpanAttributes.HTTP_STATUS_CODE: 200,
813
- SpanAttributes.HTTP_HOST: "examplehost",
814
- SpanAttributes.NET_PEER_PORT: 8000,
815
- SpanAttributes.NET_PEER_NAME: "examplehost",
816
- SpanAttributes.HTTP_METHOD: "GET",
817
- SpanAttributes.HTTP_FLAVOR: "1.1",
818
- SpanAttributes.HTTP_SCHEME: "http",
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
- SpanAttributes.HTTP_STATUS_CODE: 200,
883
- SpanAttributes.HTTP_HOST: "examplehost",
884
- SpanAttributes.NET_PEER_PORT: 8000,
885
- SpanAttributes.NET_PEER_NAME: "examplehost",
886
- SpanAttributes.HTTP_METHOD: "GET",
887
- SpanAttributes.HTTP_FLAVOR: "1.1",
888
- SpanAttributes.HTTP_SCHEME: "http",
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: