【问题标题】:How can I monitoring a flask app without modifying his code?如何在不修改代码的情况下监控烧瓶应用程序?
【发布时间】:2017-01-10 18:28:43
【问题描述】:

我一直在制作一个小系统来使用 prometheus 监控烧瓶应用程序和其他应用程序(postgres 数据库、linux 服务器等)。一切进展顺利,但我想在不修改代码的情况下监控我的烧瓶应用程序。

例如我的应用程序的监控方法:

# Create a metric to track time spent and requests made.
REQUEST_TIME = Summary('request_processing_seconds', 'Time spent processing request')

@app.route('/')
@REQUEST_TIME.time()
def index():
 myUser = User.query.all()
 return render_template('add_user.html', myUser= myUser)

我使用了this python 库。

另外,我使用other library 来监控烧瓶应用程序:

monitor(app, port=9999)

不幸的是,两者都在修改我的代码。我想在不修改他的代码的情况下监控我的烧瓶应用程序。有可能的?

【问题讨论】:

    标签: python flask prometheus


    【解决方案1】:

    真的不清楚你在问什么。但是,如果您只需要有关调用哪些请求以及它们需要多长时间的信息,您可以使用 newrelic 运行您的烧瓶应用程序:它们提供免费层(耶!)并且使用它您将获得有关您的应用程序的大量见解。但是要使用它,您需要使用他们的客户端运行您的应用程序(但不需要更改代码)。

    有关您将获得的内容的更多信息,请参见此处: https://newrelic.com/python/flask

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-11
      • 1970-01-01
      • 1970-01-01
      • 2021-11-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多