Repository navigation
ref(boto3): Split integration into internal modules #7537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4d1d3f5
ref(boto3): split integration into internal modules
pabloDeputter 0c23830
ref(boto3): Move consts to
pabloDeputter b45f76c
fix(boto3): Move imports
pabloDeputter ab843bc
ref(boto3): Remove dupliocate `_check_minimum_version()`
pabloDeputter b21b888
ref(boto3): Update integration checks to use IDENTIFIER constant
pabloDeputter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| 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() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| from functools import partial | ||
| from typing import TYPE_CHECKING | ||
|
|
||
| from sentry_sdk.integrations import DidNotEnable | ||
| from sentry_sdk.integrations.boto3._instrumentation import ( | ||
| _sentry_after_call, | ||
| _sentry_after_call_error, | ||
| _sentry_before_sign, | ||
| _sentry_request_created, | ||
| ) | ||
|
|
||
| if TYPE_CHECKING: | ||
| from typing import Any | ||
|
|
||
| try: | ||
| from botocore.client import BaseClient | ||
| except ImportError: | ||
| raise DidNotEnable("botocore is not installed") | ||
|
|
||
|
|
||
| def _patch_botocore_client() -> None: | ||
| orig_init = BaseClient.__init__ | ||
|
|
||
| def sentry_patched_init(self: "BaseClient", *args: "Any", **kwargs: "Any") -> None: | ||
| orig_init(self, *args, **kwargs) | ||
| meta = self.meta | ||
| service_id = meta.service_model.service_id | ||
| meta.events.register( | ||
| "request-created", | ||
| partial(_sentry_request_created, service_id=service_id), | ||
| ) | ||
| # run after other `before-sign` handlers, allowing it to see and preserve existing baggage. | ||
| meta.events.register_last("before-sign", _sentry_before_sign) | ||
| meta.events.register("after-call", _sentry_after_call) | ||
| meta.events.register("after-call-error", _sentry_after_call_error) | ||
|
|
||
| BaseClient.__init__ = sentry_patched_init # type: ignore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| IDENTIFIER = "boto3" | ||
| ORIGIN = f"auto.http.{IDENTIFIER}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| from sentry_sdk.integrations.boto3 import Boto3Integration | ||
|
|
||
|
|
||
| def test_public_api(): | ||
| assert Boto3Integration.__module__ == "sentry_sdk.integrations.boto3" | ||
| assert Boto3Integration.identifier == "boto3" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.