Answer the question
In order to leave comments, you need to log in
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
}
--------------------------
descriptor 'SerializeToString' requires a 'google.protobuf.pyext._message.CMessage' object but received a 'bytes'
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
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)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question