`import aws_xray_sdk.core` attempts to establish session
See original GitHub issueIt 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
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Configuring the X-Ray SDK for Python - AWS Documentation
To use a plugin, call configure on the xray_recorder . from aws_xray_sdk.core import xray_recorder from aws_xray_sdk.core import patch_all xray_recorder.
Read more >Tracing incoming requests with the X-Ray SDK for Python ...
When you add the middleware to your application and configure a segment name, the X-Ray SDK for Python creates a segment for each...
Read more >Patching libraries to instrument downstream calls - AWS X-Ray
Instrument libraries with the X-Ray SDK for Python to trace downstream calls ... by importing the SDK's version of SQLAlchemy's session and query...
Read more >Configuring the X-Ray SDK for Node.js - AWS Documentation
The SDK uses the sampling rules you define in the X-Ray console to determine which requests to record. The default rule traces the...
Read more >Instrumenting AWS Lambda functions - AWS X-Ray
var AWSXRay = require('aws-xray-sdk-core'); var AWS = AWSXRay.captureAWS( require('aws-sdk') ) ; AWS.config.update({region: process.env.AWS_REGION}); ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Adding to @lorengordon comments on Python import profile using Python Tuna to find out where the slower calls are – X-Ray SDK accounts for 75% of Lambda function import time in this hello world example
Bad stale bot