aws / aws/aws-xray-sdk-python

`import aws_xray_sdk.core` attempts to establish session

Offen
#273 5 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
enhancement
Vorherrschende Sprache
Python
Sterne
338
Forks
147
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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](https://github.com/awslabs/aws-lambda-powertools-python/issues/294) 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 "", line 1, in
File "/home/loren/.local/lib/python3.6/site-packages/aws_xray_sdk/core/__init__.py", line 10, in
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
```

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Reproduziere den Import mit AWS_PROFILE=profiletypo, lies anschließend aws_xray_sdk/core/__init__.py und verfolge die Initialisierung durch recorder.py, sampling/sampler.py und sampling/connector.py. Ermittle, wie die Sitzungseinrichtung bis zur expliziten Verwendung von X-Ray verzögert werden kann, und überprüfe, dass der Import des Pakets nicht mehr ProfileNotFound auslöst, während die normale Verwendung des Recorders weiterhin erfolgreich initialisiert wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
aws, python
Bereich
backend, cloud
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
42/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.