L
L
LakeForest2022-01-20 00:53:01
Python
LakeForest, 2022-01-20 00:53:01

How to fix transaction creation error in sentry "grpc._common Exception serializing message!" and "httplib POST reason: Forbidden"?

grpc._common
Exception serializing message!
--------------------------
httplib
POST /api/1/envelope/ [403]
{
reason: Forbidden
}
Info
--------------------------
httplib
POST /api/1/store/ [200]
{
reason: OK
}
--------------------------


The transaction on the sentry server was not created...
At the end:
descriptor 'SerializeToString' requires a 'google.protobuf.pyext._message.CMessage' object but received a 'bytes'

61e8873e66ba5575559741.png

What is the problem?

Code for transactions:
def transaction_sentry(logger):
    def debug_request(func):
        @wraps(func)
        def inner(*args, **kwargs):
            task_name = f"{func.__name__}"
            logger.warn("Создана транзакция: `{}`".format(task_name))
            try:
                span = sentry_sdk.Hub.current.scope.span
                if span is None:
                    # нет выполняемых интервалов, создайте новую транзакцию
                    with sentry_sdk.start_transaction(name=task_name):
                        response = func(*args, **kwargs)
                        logger.warn(response)
                else:
                    # дочерняя задача транзакции
                    with span.start_child(op=task_name):
                        response = func(*args, **kwargs)
                return response
            except Exception as e:
                logger.warn(e)
                logger.exception(
                    "Ошибка при выполнении транзакции: `{}`".format(task_name))
                sentry_sdk.capture_exception(error=e)
                raise e
        return inner
    return debug_request

Call:
LOG = get_logger(__name__)
class TestService(
    stt_pb2_grpc.TestService
):
    @transaction_sentry(LOG)
    def _sub_func(request):
        #....
        return TestResponse(text=request.text)

    def Method(
        self, request,
        context
    ):
            return self._sub_func(request)


sentry version==1.3.1

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question