Skip to content

ref(boto3): Split integration into internal modules - #7537

Open
pabloDeputter wants to merge 1 commit into
masterfrom
pablo/refactor-boto3-integration
Open

pabloDeputter wants to merge 1 commit into
masterfrom
pablo/refactor-boto3-integration

Conversation

@pabloDeputter

Copy link
Copy Markdown
Member

Description

Move Boto3Integration from single module into package with smaller internal modules.

  • botocore client patching is moved into _client.py.
  • request instrumentation and event handlers into _instrumentation.py.
  • existing public import is kept unchanged: from sentry_sdk.integrations.boto3 import Boto3Integration.

@pabloDeputter
pabloDeputter added this pull request to stack #7539 September 18, 2026 14:23
@github-actions

github-actions Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

128339 passed | ⏭️ 7148 skipped | Total: 135487 | Pass Rate: 94.72% | Execution Time: 405m 30s

📊 Comparison with Base Branch

Metric Change
Total Tests 📈 +30
Passed Tests 📈 +13
Failed Tests
Skipped Tests 📈 +17

All tests are passing successfully.

✅ Patch coverage is 94.12%. Project has 2534 uncovered lines.
✅ Project coverage is 90.17%. Comparing base (494ecb3) to head (68c2877).

Files with missing lines (1)
File Patch % Lines
sentry_sdk/integrations/boto3/_client.py 91.67% ⚠️ 2 Missing
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

@pabloDeputter
pabloDeputter removed this pull request from stack #7539 September 18, 2026 15:08
@pabloDeputter
pabloDeputter added this pull request to stack #7541 September 18, 2026 15:08
@pabloDeputter
pabloDeputter marked this pull request as ready for review September 18, 2026 15:12
@pabloDeputter
pabloDeputter requested a review from a team as a code owner September 18, 2026 15:12
@staticmethod
def setup_once() -> None:
# local import to avoid import cycle
from sentry_sdk.integrations.boto3._client import _patch_botocore_client

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants