$35 GRAYBYTE WORDPRESS FILE MANAGER $94

SERVER : vnpttt-amd7f72-h1.vietnix.vn #1 SMP Fri May 24 12:42:50 UTC 2024
SERVER IP : 103.200.23.149 | ADMIN IP 216.73.216.22
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/opt/alt/python37/lib/python3.7/site-packages/sentry_sdk/integrations/

HOME
Current File : /opt/alt/python37/lib/python3.7/site-packages/sentry_sdk/integrations//boto3.py
from __future__ import absolute_import

from sentry_sdk import Hub
from sentry_sdk.integrations import Integration, DidNotEnable
from sentry_sdk.tracing import Span

from sentry_sdk._functools import partial
from sentry_sdk._types import MYPY

if MYPY:
    from typing import Any
    from typing import Dict
    from typing import Optional
    from typing import Type

try:
    from botocore import __version__ as BOTOCORE_VERSION  # type: ignore
    from botocore.client import BaseClient  # type: ignore
    from botocore.response import StreamingBody  # type: ignore
    from botocore.awsrequest import AWSRequest  # type: ignore
except ImportError:
    raise DidNotEnable("botocore is not installed")


class Boto3Integration(Integration):
    identifier = "boto3"

    @staticmethod
    def setup_once():
        # type: () -> None
        try:
            version = tuple(map(int, BOTOCORE_VERSION.split(".")[:3]))
        except (ValueError, TypeError):
            raise DidNotEnable(
                "Unparsable botocore version: {}".format(BOTOCORE_VERSION)
            )
        if version < (1, 12):
            raise DidNotEnable("Botocore 1.12 or newer is required.")
        orig_init = BaseClient.__init__

        def sentry_patched_init(self, *args, **kwargs):
            # type: (Type[BaseClient], *Any, **Any) -> None
            orig_init(self, *args, **kwargs)
            meta = self.meta
            service_id = meta.service_model.service_id.hyphenize()
            meta.events.register(
                "request-created",
                partial(_sentry_request_created, service_id=service_id),
            )
            meta.events.register("after-call", _sentry_after_call)
            meta.events.register("after-call-error", _sentry_after_call_error)

        BaseClient.__init__ = sentry_patched_init


def _sentry_request_created(service_id, request, operation_name, **kwargs):
    # type: (str, AWSRequest, str, **Any) -> None
    hub = Hub.current
    if hub.get_integration(Boto3Integration) is None:
        return

    description = "aws.%s.%s" % (service_id, operation_name)
    span = hub.start_span(
        hub=hub,
        op="aws.request",
        description=description,
    )
    span.set_tag("aws.service_id", service_id)
    span.set_tag("aws.operation_name", operation_name)
    span.set_data("aws.request.url", request.url)

    # We do it in order for subsequent http calls/retries be
    # attached to this span.
    span.__enter__()

    # request.context is an open-ended data-structure
    # where we can add anything useful in request life cycle.
    request.context["_sentrysdk_span"] = span


def _sentry_after_call(context, parsed, **kwargs):
    # type: (Dict[str, Any], Dict[str, Any], **Any) -> None
    span = context.pop("_sentrysdk_span", None)  # type: Optional[Span]

    # Span could be absent if the integration is disabled.
    if span is None:
        return
    span.__exit__(None, None, None)

    body = parsed.get("Body")
    if not isinstance(body, StreamingBody):
        return

    streaming_span = span.start_child(
        op="aws.request.stream",
        description=span.description,
    )

    orig_read = body.read
    orig_close = body.close

    def sentry_streaming_body_read(*args, **kwargs):
        # type: (*Any, **Any) -> bytes
        try:
            ret = orig_read(*args, **kwargs)
            if not ret:
                streaming_span.finish()
            return ret
        except Exception:
            streaming_span.finish()
            raise

    body.read = sentry_streaming_body_read

    def sentry_streaming_body_close(*args, **kwargs):
        # type: (*Any, **Any) -> None
        streaming_span.finish()
        orig_close(*args, **kwargs)

    body.close = sentry_streaming_body_close


def _sentry_after_call_error(context, exception, **kwargs):
    # type: (Dict[str, Any], Type[BaseException], **Any) -> None
    span = context.pop("_sentrysdk_span", None)  # type: Optional[Span]

    # Span could be absent if the integration is disabled.
    if span is None:
        return
    span.__exit__(type(exception), exception, None)

Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
31 Aug 2024 6.48 AM
root / 996
0755
__pycache__
--
31 Aug 2024 6.48 AM
root / 996
0755
django
--
31 Aug 2024 6.48 AM
root / 996
0755
spark
--
31 Aug 2024 6.48 AM
root / 996
0755
__init__.py
6.356 KB
27 Jul 2021 9.04 PM
root / 996
0644
_wsgi_common.py
4.651 KB
27 Jul 2021 9.04 PM
root / 996
0644
aiohttp.py
7.766 KB
27 Jul 2021 9.04 PM
root / 996
0644
argv.py
0.923 KB
27 Jul 2021 9.04 PM
root / 996
0644
asgi.py
8.257 KB
27 Jul 2021 9.04 PM
root / 996
0644
atexit.py
1.794 KB
27 Jul 2021 9.04 PM
root / 996
0644
aws_lambda.py
14.987 KB
27 Jul 2021 9.04 PM
root / 996
0644
beam.py
5.529 KB
27 Jul 2021 9.04 PM
root / 996
0644
boto3.py
4.048 KB
27 Jul 2021 9.04 PM
root / 996
0644
bottle.py
6.062 KB
27 Jul 2021 9.04 PM
root / 996
0644
celery.py
9.312 KB
27 Jul 2021 9.04 PM
root / 996
0644
chalice.py
4.502 KB
27 Jul 2021 9.04 PM
root / 996
0644
dedupe.py
1.139 KB
27 Jul 2021 9.04 PM
root / 996
0644
excepthook.py
2.139 KB
27 Jul 2021 9.04 PM
root / 996
0644
executing.py
1.976 KB
27 Jul 2021 9.04 PM
root / 996
0644
falcon.py
6.637 KB
27 Jul 2021 9.04 PM
root / 996
0644
flask.py
7.296 KB
27 Jul 2021 9.04 PM
root / 996
0644
gcp.py
7.842 KB
27 Jul 2021 9.04 PM
root / 996
0644
gnu_backtrace.py
2.844 KB
27 Jul 2021 9.04 PM
root / 996
0644
httpx.py
2.552 KB
27 Jul 2021 9.04 PM
root / 996
0644
logging.py
7.543 KB
27 Jul 2021 9.04 PM
root / 996
0644
modules.py
1.36 KB
27 Jul 2021 9.04 PM
root / 996
0644
pure_eval.py
4.414 KB
27 Jul 2021 9.04 PM
root / 996
0644
pyramid.py
6.906 KB
27 Jul 2021 9.04 PM
root / 996
0644
redis.py
3.004 KB
27 Jul 2021 9.04 PM
root / 996
0644
rq.py
4.838 KB
27 Jul 2021 9.04 PM
root / 996
0644
sanic.py
8.444 KB
27 Jul 2021 9.04 PM
root / 996
0644
serverless.py
1.925 KB
27 Jul 2021 9.04 PM
root / 996
0644
sqlalchemy.py
2.87 KB
27 Jul 2021 9.04 PM
root / 996
0644
stdlib.py
7.245 KB
27 Jul 2021 9.04 PM
root / 996
0644
threading.py
2.789 KB
27 Jul 2021 9.04 PM
root / 996
0644
tornado.py
7.018 KB
27 Jul 2021 9.04 PM
root / 996
0644
trytond.py
1.688 KB
27 Jul 2021 9.04 PM
root / 996
0644
wsgi.py
10.888 KB
27 Jul 2021 9.04 PM
root / 996
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF