在Python中存储HTTP请求的痕迹 [英] Store traces of http requests in Python

查看:35
本文介绍了在Python中存储HTTP请求的痕迹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想存储执行HTTP处理HTTP请求的python代码的痕迹.

I want to store traces of the python code which gets executed to handle http requests.

我们使用Python和Django.

We use Python and Django.

在这种情况下是什么痕迹?

What is a trace in this context?

我希望所有已跟踪的http请求都具有此功能:

I want to have this for all traced http requests:

  • request.META,
  • request.POST
  • request.GET

对于每个跟踪,有N次代码执行的堆栈跟踪.第一步,将众所周知的python跟踪存储为字符串就足够了.第一步,不需要存储变量的值.

For every trace there are N times the stacktraces of the code execution. In the first step it would be enough to store well known python traceback as string. In the first step the value of variables does not need to be stored.

堆栈跟踪可以由主管线程创建,也可以由源代码中的方法调用显式创建.在第一步中,显式就足够了,主管线程可以在以后完成.

The stacktraces can be created by a supervisor thread or by explicit by a method call in the source code. In the first step explicit is enough, the supervisor thread can be done later.

跟踪是可选的,仅用于调试和分析.不需要它们来处理http请求.

The traces are optional and only for debugging and analyzing. They are not needed to process the http requests.

如何解决?

缺少一些东西来理解这个问题吗?如果是,请发表评论.

Is something missing to understand this question? If, yes, please leave a comment.

  • 我想实现什么?我希望有一种更好的方法来调试生产系统中的错误.我想看看发生错误之前发生了什么.
  • 所有http请求?我想我想每分钟存储大约一条痕迹.我想我会在N周后删除数据.

推荐答案

已从评论中移出

您可以查看专用解决方案 https://github.com/getsentry/sentry 用于记录错误.它还提供了一种使用raven client手动记录数据的方法.

You could look into https://github.com/getsentry/sentry which is dedicated solution for logging errors. Also it has a way of manually logging data with raven client.

这篇关于在Python中存储HTTP请求的痕迹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆