Skip to content

Commit 3b2df2a

Browse files
Dunedanhaotianw465
authored andcommitted
Remove the dependency on requests (#112)
This removes the use of `requests` from the core functionality, which results in `requests` being only used as extension, therefore not being necessary as dependency anymore. The motivation for this change is to get rid of all the dependencies of `requests`, whose size sums up quite a bit, when not requiring to patch `requests`. It follows the removal of `requests` from `botocore`, which was done as part of v1.11.0.
1 parent 5b35427 commit 3b2df2a

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

aws_xray_sdk/core/plugins/ec2_plugin.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import logging
2-
import requests
2+
from future.standard_library import install_aliases
3+
install_aliases()
4+
from urllib.request import urlopen
35

46
log = logging.getLogger(__name__)
57

@@ -18,11 +20,12 @@ def initialize():
1820
try:
1921
runtime_context = {}
2022

21-
r = requests.get('http://169.254.169.254/latest/meta-data/instance-id', timeout=1)
22-
runtime_context['instance_id'] = r.text
23+
r = urlopen('http://169.254.169.254/latest/meta-data/instance-id', timeout=1)
24+
runtime_context['instance_id'] = r.read().decode('utf-8')
2325

24-
r = requests.get('http://169.254.169.254/latest/meta-data/placement/availability-zone', timeout=1)
25-
runtime_context['availability_zone'] = r.text
26+
r = urlopen('http://169.254.169.254/latest/meta-data/placement/availability-zone',
27+
timeout=1)
28+
runtime_context['availability_zone'] = r.read().decode('utf-8')
2629

2730
except Exception:
2831
runtime_context = None

setup.py

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
'jsonpickle',
4646
'enum34;python_version<"3.4"',
4747
'wrapt',
48-
'requests',
4948
'future',
5049
'botocore>=1.11.3',
5150
],

0 commit comments

Comments
 (0)