gpt4 book ai didi

python - 使用 Python 实现 StatsD/Graphite

转载 作者:太空宇宙 更新时间:2023-11-03 18:21:19 39 4
gpt4 key购买 nike

所以我有 Etsy 的 StatsD和 Graphite 在 OS X 10.9.3 上运行。

我现在正在尝试使用 Python 来实现它们,但我不想使用 python-statsd ,因为我想在求助于库之前了解如何单独使用该技术(如果我稍后需要使用 Ruby/PHP,那么我就无法理解基 native 制了)。

即我正在尝试使用 Python 将应用程序数据发送到 StatsD,然后该数据将显示在 Graphite 中。

在我的应用程序中,我使用的是 Steve Ivy 的 python_example.py 的精确副本.

在我的代码中,我这样调用增量函数:

from statsd import StatsdClient
client = StatsdClient()
client.increment('somename.someval')

这是引发的错误:

File "/Users/bengrunfeld/Desktop/Work/code/wf-ghconsole/console/statsd.py", line 163, in send
udp_sock.sendto(":".join(item).encode('utf-8'), addr)
....
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 234, in _MakeRealSyncCall
raise pickle.loads(response_pb.exception())
RuntimeError: error('illegal IP address string passed to inet_pton',)

以下是 udp_sock.sendto 发送的值:('somename.someval:1|c', ('localhost', 8125))

链接到我的代码:https://github.com/bengrunfeld-wf/gae-github-console/blob/statsd/console/statsd.py

最佳答案

您的代码看起来不错,但要做的第一件事是尝试在应用程序引擎之外运行代码。如果他的工作,然后确认应用程序引擎是否会执行 UDP - 如果我没记错的话,它不会 - 我上次使用应用程序引擎实现此功能时必须创建一个 http 代理。

关于python - 使用 Python 实现 StatsD/Graphite,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24091497/

39 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com