Python 的应用程序性能指标

发布于 2024-12-03 11:12:03 字数 385 浏览 0 评论 0原文

我们正在编写一个 Python Web 应用程序,我们想了解用户正在做什么的大致数据。

举个例子,我们有一堆遗留模式来设置所使用的区域设置; url-参数,使用不同格式的不同cookie,Accpet-Language-headers &c。我们真的很想以某种方式来衡量这一点(但记录它只是太多的数据)。

我尝试过寻找像 Metrics for Node.js 这样的库,但我似乎找不到任何东西对于Python。现在,我认为我们可以使用一堆类似 UNIX 负载的计数器。 (但越多越好,对吧?)

我是否错过了一些明显的库或某处的一些智能技术?

We're writing a Python web-application, where we'd like to know general-ballpark-figures about what our users are doing.

As an example, we have a bunch of legacy-modes for setting the used locale; url-parameter, using different cookies in different formats, Accpet-Language-headers &c. We would really like to measure this in some way (but logging it is simply too much data).

I've tried looking for libraries like Metrics for Node.js, but I can't seem to find anything for Python. Right now, I think we can make do with a bunch of UNIX-load-like counters. (But more is always better, right?)

Have I missed some obvious library or some smart technique somewhere?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

三生路 2024-12-10 11:12:03

刚刚找到 PyCounters 项目,它看起来就像我开始需要的那样。

Just found the PyCounters project, which looks just like what I needed to begin with.

流云如水 2024-12-10 11:12:03

名为 Graphite 的 Python 项目与名为 Statsd 可以做你想做的事情。很多时候,人们也使用这些项目来衡量软件性能指标和业务指标。

顺便说一句,有些托管应用程序版本提供了许多与 GraphiteStatsd。我公司的产品 Instrumental 将为您进行指标托管前端和图形生成;在Python中,您可以使用 Python statsd 客户端< /a> 与我们的 Statsd 到 Instrumental 代理 一致向我们的服务报告您的指标。

由于接受的答案是进行基于文件的日志记录(默认情况下至少:)),我会注意到传输层在这些不同的事物中很有趣: statsd 服务器(无论是 官方我们的代理)使用 UDP 将您的指标信息发送到服务器。您还可以联系 GraphiteInstrumental 直接使用基于线路的 TCP 协议;其他商业服务,例如 librato MetricsStathat 使用 HTTP 消息获取您的指标。根据您发送的消息的规模,这些工具中的任何一种可能或多或少对您有吸引力。

A Python project called Graphite coupled with a Node.js project called Statsd can do exactly the thing you want. Many times people use these projects for software performance metrics and business metrics as well.

Incidentally there are hosted app versions that provide a lot of the same functionality as Graphite and Statsd. My company's product, Instrumental, will do the metric hosting frontend and graph generation for you; in Python, you'd use a Python statsd client in concert w/ our Statsd to Instrumental proxy to report your metrics to our service.

Since the accepted answer was doing file-based logging (by default at least:) ), I'll note the transportation layer is interesting among these different things: A statsd server (whether the official or our proxy) uses UDP to send your metric information to the server. You can also contact Graphite or Instrumental directly using a line based TCP protocol; other commercial services out there like librato Metrics or Stathat take in your metrics using HTTP messages. Depending on the scale of messages you're sending, any one of these tools may be more or less attractive to you.

下壹個目標 2024-12-10 11:12:03

查看多个日志。

我们有许多单独的日志(单独的句柄、单独的格式),并使用 Python 日志记录将这些事件记录到单独的日志中。

我们有很多类似这样的功能。

def some_feature( ... ):
    customer_log.info( "Requested some_feature" )
    ...
    vendor_x_log.info( "Got foo" )
    ...
    vendor_y_log.info( "Got bar" )

现在我们有了详细的日志。由于日志记录模块可以写入数据库(或执行任何其他看似合适的操作),因此我们可以通过一个简单且易于配置的界面获得所有详细信息。

Look into multiple logs.

We have many separate logs (separate handles, separate formats) and use the Python logging to log these events into separate logs.

We have lots of functions with things like this.

def some_feature( ... ):
    customer_log.info( "Requested some_feature" )
    ...
    vendor_x_log.info( "Got foo" )
    ...
    vendor_y_log.info( "Got bar" )

Now we have detailed logs. Since the logging module can write to the database (or do any other thing that seems appropriate) we have all the details through a simple, easily-configured interface.

浅唱々樱花落 2024-12-10 11:12:03

您可以尝试托管指标服务Metrics At。您可以记录您想要度量的数据,例如 url-parameter、Accpet-Language-headers ...等。然后你可以在Metrics At中输入正则表达式。 Metrics At 将自动提取数据并为您进行度量。

You can try a hosting metrics service Metrics At. You can log the data you want to metric, e.g. url-parameter, Accpet-Language-headers ...etc. Then you can input a regular express in Metrics At. Metrics At will automatically extract data and metric it for you.

童话里做英雄 2024-12-10 11:12:03

PyCounters 的一种新替代方案是 Scales:
https://github.com/Cue/scales/

它有一些很酷的额外功能,例如启动服务器提供当前统计数据或发送到 Graphite。

One newer alternative to PyCounters is Scales:
https://github.com/Cue/scales/

It has a few cool extra features like launching a server to serve current stats or sending to graphite.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文