Skip to content

import aws_xray_sdk.core attempts to establish session #273

Open
@lorengordon

Description

@lorengordon

It feels a little odd for a library to establish a session on import. Is that truly necessary, or would it be possible to gate that setup on an explicit call to an xray class/method?

I only discovered the session is being setup because I happened to have an incorrect/null AWS_PROFILE configured locally, while testing a logging config using the aws-lambda-powertools-python library. I opened an issue there, but it seemed more appropriate for the xray team.

$ AWS_PROFILE=profiletypo python -c 'import aws_xray_sdk.core'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/loren/.local/lib/python3.6/site-packages/aws_xray_sdk/core/__init__.py", line 10, in <module>
    xray_recorder = AsyncAWSXRayRecorder()
  File "/home/loren/.local/lib/python3.6/site-packages/aws_xray_sdk/core/recorder.py", line 66, in __init__
    self._sampler = DefaultSampler()
  File "/home/loren/.local/lib/python3.6/site-packages/aws_xray_sdk/core/sampling/sampler.py", line 25, in __init__
    self._connector = ServiceConnector()
  File "/home/loren/.local/lib/python3.6/site-packages/aws_xray_sdk/core/sampling/connector.py", line 23, in __init__
    self._xray_client = self._create_xray_client()
  File "/home/loren/.local/lib/python3.6/site-packages/aws_xray_sdk/core/sampling/connector.py", line 164, in _create_xray_client
    aws_access_key_id='', aws_secret_access_key=''
  File "/home/loren/.local/lib/python3.6/site-packages/botocore/session.py", line 802, in create_client
    verify = self.get_config_variable('ca_bundle')
  File "/home/loren/.local/lib/python3.6/site-packages/botocore/session.py", line 241, in get_config_variable
    logical_name)
  File "/home/loren/.local/lib/python3.6/site-packages/botocore/configprovider.py", line 313, in get_config_variable
    return provider.provide()
  File "/home/loren/.local/lib/python3.6/site-packages/botocore/configprovider.py", line 410, in provide
    value = provider.provide()
  File "/home/loren/.local/lib/python3.6/site-packages/botocore/configprovider.py", line 471, in provide
    scoped_config = self._session.get_scoped_config()
  File "/home/loren/.local/lib/python3.6/site-packages/botocore/session.py", line 340, in get_scoped_config
    raise ProfileNotFound(profile=profile_name)
botocore.exceptions.ProfileNotFound: The config profile () could not be found

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions