Skip to content

Commit

Permalink
Replace slow json filename resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanielRN committed Jun 28, 2021
1 parent b5b99b7 commit 10d72f2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
6 changes: 2 additions & 4 deletions aws_xray_sdk/core/sampling/local/sampler.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import json
import pkgutil
from random import Random

from pkg_resources import resource_filename
from .sampling_rule import SamplingRule
from ...exceptions.exceptions import InvalidSamplingManifestError


with open(resource_filename(__name__, 'sampling_rule.json')) as f:
local_sampling_rule = json.load(f)
local_sampling_rule = json.loads(pkgutil.get_data(__name__, 'sampling_rule.json'))

SUPPORTED_RULE_VERSION = (1, 2)

Expand Down
5 changes: 2 additions & 3 deletions aws_xray_sdk/ext/boto_utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from __future__ import absolute_import
# Need absolute import as botocore is also in the current folder for py27
import json
import pkgutil

from pkg_resources import resource_filename
from botocore.exceptions import ClientError

from aws_xray_sdk.core import xray_recorder
Expand All @@ -12,8 +12,7 @@
from aws_xray_sdk.ext.util import inject_trace_header, to_snake_case


with open(resource_filename(__name__, 'resources/aws_para_whitelist.json'), 'r') as data_file:
whitelist = json.load(data_file)
whitelist = json.load(pkgutil.get_data(__name__, 'resources/aws_para_whitelist.json'))


def inject_header(wrapped, instance, args, kwargs):
Expand Down

0 comments on commit 10d72f2

Please sign in to comment.