当前位置: 首页>>代码示例>>Python>>正文


Python sentry_sdk.capture_exception方法代码示例

本文整理汇总了Python中sentry_sdk.capture_exception方法的典型用法代码示例。如果您正苦于以下问题:Python sentry_sdk.capture_exception方法的具体用法?Python sentry_sdk.capture_exception怎么用?Python sentry_sdk.capture_exception使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sentry_sdk的用法示例。


在下文中一共展示了sentry_sdk.capture_exception方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: log_exception

# 需要导入模块: import sentry_sdk [as 别名]
# 或者: from sentry_sdk import capture_exception [as 别名]
def log_exception(exception=None, context: commands.Context = None):
        if config.SENTRY_DSN is None:
            return

        with sentry_sdk.push_scope() as scope:
            if context:
                # noinspection PyDunderSlots,PyUnresolvedReferences
                # for some reason pycharm doesn't pick up the attribute setter here
                scope.user = {"id": context.author.id, "username": str(context.author)}
                scope.set_tag("message.content", context.message.content)
                scope.set_tag("is_private_message", context.guild is None)
                scope.set_tag("channel.id", context.channel.id)
                scope.set_tag("channel.name", str(context.channel))
                if context.guild is not None:
                    scope.set_tag("guild.id", context.guild.id)
                    scope.set_tag("guild.name", str(context.guild))
            sentry_sdk.capture_exception(exception) 
开发者ID:avrae,项目名称:avrae,代码行数:19,代码来源:dbot.py

示例2: push_admin_credit_transfer

# 需要导入模块: import sentry_sdk [as 别名]
# 或者: from sentry_sdk import capture_exception [as 别名]
def push_admin_credit_transfer(transfers):
    # If we only get one transfer, make it a list
    if not isinstance(transfers, list):
        transfers = [transfers]

    # Build prepared list of transfers we want to send
    pusher_batch_payload = []
    for transfer in transfers:
        for org in transfer.organisations:
            pusher_transfer_payload = {}
            pusher_transfer_payload['data'] = {}
            pusher_transfer_payload['data']['credit_transfer'] = credit_transfer_schema.dump(transfer).data
            pusher_transfer_payload['name'] = 'credit_transfer'
            pusher_transfer_payload['channel'] = current_app.config['PUSHER_ENV_CHANNEL'] + '-' + str(org.id)
            pusher_batch_payload.append(pusher_transfer_payload)

    # Break the list of prepared transfers into MAX_BATCH_SIZE chunks and send each batch to the API
    for pusher_payload_chunk in misc.chunk_list(pusher_batch_payload, PUSHER_MAX_BATCH_SIZE):
        try:
            async_pusher_trigger_batch.submit(pusher_payload_chunk)
        except Exception as e:
            print(e)
            sentry_sdk.capture_exception(e) 
开发者ID:teamsempo,项目名称:SempoBlockchain,代码行数:25,代码来源:pusher.py

示例3: get_usd_to_satoshi_rate

# 需要导入模块: import sentry_sdk [as 别名]
# 或者: from sentry_sdk import capture_exception [as 别名]
def get_usd_to_satoshi_rate():

    blockchain_task = celery_app.signature('worker.celery_tasks.get_usd_to_satoshi_rate')
    # TODO: Convert to task_runner
    result = blockchain_task.apply_async()

    try:
        conversion_rate = result.wait(timeout=3, propagate=True, interval=0.5)

    except Exception as e:
        print(e)
        sentry_sdk.capture_exception(e)
        raise BlockchainError("Blockchain Error")

    finally:
        result.forget()

    return conversion_rate 
开发者ID:teamsempo,项目名称:SempoBlockchain,代码行数:20,代码来源:blockchain_transaction.py

示例4: test_500

# 需要导入模块: import sentry_sdk [as 别名]
# 或者: from sentry_sdk import capture_exception [as 别名]
def test_500(sentry_init, capture_events):
    sentry_init(integrations=[FalconIntegration()])

    app = falcon.API()

    class Resource:
        def on_get(self, req, resp):
            1 / 0

    app.add_route("/", Resource())

    def http500_handler(ex, req, resp, params):
        sentry_sdk.capture_exception(ex)
        resp.media = {"message": "Sentry error: %s" % sentry_sdk.last_event_id()}

    app.add_error_handler(Exception, http500_handler)

    events = capture_events()

    client = falcon.testing.TestClient(app)
    response = client.simulate_get("/")

    (event,) = events
    assert response.json == {"message": "Sentry error: %s" % event["event_id"]} 
开发者ID:getsentry,项目名称:sentry-python,代码行数:26,代码来源:test_falcon.py

示例5: test_initialization_order

# 需要导入模块: import sentry_sdk [as 别名]
# 或者: from sentry_sdk import capture_exception [as 别名]
def test_initialization_order(run_lambda_function):
    """Zappa lazily imports our code, so by the time we monkeypatch the handler
    as seen by AWS already runs. At this point at least draining the queue
    should work."""

    events, _response = run_lambda_function(
        LAMBDA_PRELUDE
        + dedent(
            """
            def test_handler(event, context):
                init_sdk()
                sentry_sdk.capture_exception(Exception("something went wrong"))
        """
        ),
        b'{"foo": "bar"}',
    )

    (event,) = events
    assert event["level"] == "error"
    (exception,) = event["exception"]["values"]
    assert exception["type"] == "Exception"
    assert exception["value"] == "something went wrong" 
开发者ID:getsentry,项目名称:sentry-python,代码行数:24,代码来源:test_aws.py

示例6: _handle_sentry

# 需要导入模块: import sentry_sdk [as 别名]
# 或者: from sentry_sdk import capture_exception [as 别名]
def _handle_sentry(self):
        """Handle exceptions using Sentry."""
        from sentry_sdk import capture_exception, configure_scope
        from sentry_sdk.utils import capture_internal_exceptions

        with configure_scope() as scope:
            with capture_internal_exceptions():
                from git import Repo
                from renku.core.commands import get_git_home
                from renku.core.models.provenance.agents import Person

                repo = Repo(get_git_home())
                user = Person.from_git(repo)

                scope.user = {'name': user.name, 'email': user.email}

            event_id = capture_exception()
            click.echo(
                _BUG + 'Recorded in Sentry with ID: {0}\n'.format(event_id),
                err=True,
            )
            raise 
开发者ID:SwissDataScienceCenter,项目名称:renku-python,代码行数:24,代码来源:exception_handler.py

示例7: log_exception

# 需要导入模块: import sentry_sdk [as 别名]
# 或者: from sentry_sdk import capture_exception [as 别名]
def log_exception(request, exception, tb):
    if sentry_sdk is not None:
        sentry_sdk.capture_exception(exception)
        return

    # Send email to admins with details about exception
    ip_type = (
        request.META.get("REMOTE_ADDR") in settings.INTERNAL_IPS
        and "internal"
        or "EXTERNAL"
    )
    msg_args = {
        "ip_type": ip_type,
        "path": request.path,
    }
    subject = "Error (%(ip_type)s IP): %(path)s" % msg_args

    try:
        request_repr = repr(request)
    except:
        request_repr = "Request repr() unavailable"

    msg_args = (str(exception.args[0]), tb, request_repr)
    message = "%s\n\n%s\n\n%s" % msg_args
    mail_admins(subject, message, fail_silently=True) 
开发者ID:evernote,项目名称:zing,代码行数:27,代码来源:errorpages.py

示例8: custom_exception_handler

# 需要导入模块: import sentry_sdk [as 别名]
# 或者: from sentry_sdk import capture_exception [as 别名]
def custom_exception_handler(exc, context):
    """
    Custom exception handler for rest api views
    """
    # Call REST framework's default exception handler first,
    # to get the standard error response.
    log.exception("An exception was intercepted by custom_exception_handler")
    response = exception_handler(exc, context)

    # if it is handled, just return the response
    if response is not None:
        return response

    # Otherwise format the exception only in specific cases
    if isinstance(exc, ImproperlyConfigured):
        # send the exception to Sentry anyway
        client.capture_exception()

        formatted_exception_string = "{0}: {1}".format(type(exc).__name__, str(exc))
        return Response(
            status=status.HTTP_500_INTERNAL_SERVER_ERROR,
            data=[formatted_exception_string]
        )
    return None 
开发者ID:mitodl,项目名称:micromasters,代码行数:26,代码来源:utils.py

示例9: handle_kyc_documents

# 需要导入模块: import sentry_sdk [as 别名]
# 或者: from sentry_sdk import capture_exception [as 别名]
def handle_kyc_documents(data=None,document_country=None,document_type=None,kyc_details=None):
    for (key, value) in data.items():
        if set([key]).intersection(set(['document_front_base64', 'document_back_base64', 'selfie_base64'])) and value is not None:
            try:
                new_filename = generate_new_filename(original_filename="{}-{}.jpg".format(key, document_country), file_type='jpg')
                save_to_s3_from_image_base64(image_base64=value, new_filename=new_filename)
                uploaded_document = UploadedResource(filename=new_filename, reference=document_type,
                                                     user_filename=key)
                db.session.add(uploaded_document)
                # tie document to kyc application
                uploaded_document.kyc_application_id = kyc_details.id
            except Exception as e:
                print(e)
                sentry_sdk.capture_exception(e)
                pass 
开发者ID:teamsempo,项目名称:SempoBlockchain,代码行数:17,代码来源:kyc_application_api.py

示例10: save_photo_and_check_for_duplicate

# 需要导入模块: import sentry_sdk [as 别名]
# 或者: from sentry_sdk import capture_exception [as 别名]
def save_photo_and_check_for_duplicate(url, new_filename, image_id):
    save_to_s3_from_url(url, new_filename)

    try:
        rekognition_task = celery_app.signature('worker.celery_tasks.check_for_duplicate_person',
                                                args=(new_filename, image_id))
        # TODO: Standardize this task (pipe through execute_synchronous_celery)
        rekognition_task.delay()
    except Exception as e:
        print(e)
        sentry_sdk.capture_exception(e)
        pass 
开发者ID:teamsempo,项目名称:SempoBlockchain,代码行数:14,代码来源:user.py

示例11: push_user_transfer_confirmation

# 需要导入模块: import sentry_sdk [as 别名]
# 或者: from sentry_sdk import capture_exception [as 别名]
def push_user_transfer_confirmation(receive_user, transfer_random_key):
    try:
        async_pusher_trigger.submit(
            'private-user-{}-{}'.format(current_app.config['DEPLOYMENT_NAME'], receive_user.id),
            'payment_confirmed',
            {'transfer_random_key': transfer_random_key}
        )
    except Exception as e:
        print(e)
        sentry_sdk.capture_exception(e) 
开发者ID:teamsempo,项目名称:SempoBlockchain,代码行数:12,代码来源:pusher.py

示例12: ip

# 需要导入模块: import sentry_sdk [as 别名]
# 或者: from sentry_sdk import capture_exception [as 别名]
def ip(self, ip):

        self._ip = ip

        if ip is not None:

            try:
                mt.set_ip_location(self.id, ip)
            except Exception as e:
                print(e)
                sentry_sdk.capture_exception(e)
                pass 
开发者ID:teamsempo,项目名称:SempoBlockchain,代码行数:14,代码来源:ip_address.py

示例13: test_basic

# 需要导入模块: import sentry_sdk [as 别名]
# 或者: from sentry_sdk import capture_exception [as 别名]
def test_basic(sentry_init, capture_events):
    sentry_init(integrations=[ModulesIntegration()])
    events = capture_events()

    sentry_sdk.capture_exception(ValueError())

    (event,) = events
    assert "sentry-sdk" in event["modules"]
    assert "pytest" in event["modules"] 
开发者ID:getsentry,项目名称:sentry-python,代码行数:11,代码来源:test_modules.py

示例14: handle

# 需要导入模块: import sentry_sdk [as 别名]
# 或者: from sentry_sdk import capture_exception [as 别名]
def handle(self, exc_type, exc_value, enriched_tb):
        if self._rate_limiter.please():
            sentry_sdk.capture_exception((exc_type, exc_value, enriched_tb)) 
开发者ID:mherrmann,项目名称:fbs,代码行数:5,代码来源:sentry.py

示例15: send_to_sentry

# 需要导入模块: import sentry_sdk [as 别名]
# 或者: from sentry_sdk import capture_exception [as 别名]
def send_to_sentry(ex):
    # so that we don't have to have sentry sdk installed locally
    import sentry_sdk

    sentry_sdk.capture_exception(ex) 
开发者ID:packit-service,项目名称:packit-service,代码行数:7,代码来源:sentry_integration.py


注:本文中的sentry_sdk.capture_exception方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。