Skip to content

Commit 7745952

Browse files
committed
Replace slow json filename resolver
1 parent b5b99b7 commit 7745952

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

aws_xray_sdk/core/sampling/local/sampler.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import json
2+
import pkgutil
23
from random import Random
34

4-
from pkg_resources import resource_filename
55
from .sampling_rule import SamplingRule
66
from ...exceptions.exceptions import InvalidSamplingManifestError
77

8-
9-
with open(resource_filename(__name__, 'sampling_rule.json')) as f:
10-
local_sampling_rule = json.load(f)
8+
local_sampling_rule = json.loads(pkgutil.get_data(__name__, 'sampling_rule.json'))
119

1210
SUPPORTED_RULE_VERSION = (1, 2)
1311

aws_xray_sdk/ext/boto_utils.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from __future__ import absolute_import
22
# Need absolute import as botocore is also in the current folder for py27
33
import json
4+
import pkgutil
45

5-
from pkg_resources import resource_filename
66
from botocore.exceptions import ClientError
77

88
from aws_xray_sdk.core import xray_recorder
@@ -12,8 +12,7 @@
1212
from aws_xray_sdk.ext.util import inject_trace_header, to_snake_case
1313

1414

15-
with open(resource_filename(__name__, 'resources/aws_para_whitelist.json'), 'r') as data_file:
16-
whitelist = json.load(data_file)
15+
whitelist = json.loads(pkgutil.get_data(__name__, 'resources/aws_para_whitelist.json'))
1716

1817

1918
def inject_header(wrapped, instance, args, kwargs):

0 commit comments

Comments
 (0)