ref(boto3): Split integration into internal modules - #7537
pabloDeputter wants to merge 1 commit into
Conversation
Codecov Results 📊✅ 128339 passed | ⏭️ 7148 skipped | Total: 135487 | Pass Rate: 94.72% | Execution Time: 405m 30s 📊 Comparison with Base Branch
All tests are passing successfully. ✅ Patch coverage is 94.12%. Project has 2534 uncovered lines. Files with missing lines (1)
Coverage diff@@ Coverage Diff @@
## master #PR +/-##
==========================================
+ Coverage 90.17% 90.17% —%
==========================================
Files 193 195 +2
Lines 25773 25786 +13
Branches 9532 9532 —
==========================================
+ Hits 23241 23252 +11
- Misses 2532 2534 +2
- Partials 1431 1431 —Generated by Codecov Action |
| @staticmethod | ||
| def setup_once() -> None: | ||
| # local import to avoid import cycle | ||
| from sentry_sdk.integrations.boto3._client import _patch_botocore_client |
There was a problem hiding this comment.
@pabloDeputter and I chatted a bit about this offline, leaving notes here for other reviewers and so we don't forget about this when we come back to this on Monday:
We're going to look to reorganize things a little bit in order to remove this dynamic import and the one on line 24 in the _client.py file below .
The import cycle can be mitigated by moving the values for identifier and origin that currently live on the Boto3Integration to a consts.py file, and having the _instrumentation.py file import those values from there.
We can also look to pull up the minimum version check from within _client.py to here.
So this file would look like the following after these changes:
from sentry_sdk.integrations import DidNotEnable, Integration, _check_minimum_version
from sentry_sdk.integrations.boto3._client import _patch_botocore_client
from sentry_sdk.integrations.boto3.consts import IDENTIFIER, ORIGIN
from sentry_sdk.utils import parse_version
try:
from botocore import __version__ as BOTOCORE_VERSION
except ImportError:
raise DidNotEnable("botocore is not installed")
class Boto3Integration(Integration):
identifier = IDENTIFIER
origin = ORIGIN
@staticmethod
def setup_once() -> None:
version = parse_version(BOTOCORE_VERSION)
_check_minimum_version(Boto3Integration, version, "botocore")
_patch_botocore_client()
Description
Move
Boto3Integrationfrom single module into package with smaller internal modules._client.py._instrumentation.py.from sentry_sdk.integrations.boto3 import Boto3Integration.