从Heroku上的污染日志中停止新的遗物/芹菜

时间:2012-11-07 01:50:38

标签: python django celery newrelic

问题

如何阻止New Relic / Celery不断将下面的内容打印到Heroku的日志中。

app[scheduler.1]: [INFO/MainProcess] Starting new HTTP connection (1): collector-6.newrelic.com
app[scheduler.1]: [INFO/MainProcess] Starting new HTTP connection (1): collector-6.newrelic.com
app[scheduler.1]: [INFO/MainProcess] Starting new HTTP connection (1): collector-6.newrelic.com
app[scheduler.1]: [INFO/MainProcess] Starting new HTTP connection (1): collector-6.newrelic.com

设置

以上日志条目每分钟都会出现一次。报告此情况的应用程序是通过Procfile启动的芹菜工作者,其读取(部分):

scheduler: newrelic-admin run-program python manage.py celery worker --loglevel=ERROR -B -E --maxtasksperchild=1000

尽管将loglevel设置为ERROR,但似乎芹菜忽略了这个论点。有趣的是,在我的本地机器上,这个设置得到了尊重。

版本

celery==3.0.12
django-celery==3.0.11
newrelic==1.6.0.13

1 个答案:

答案 0 :(得分:1)

根据New Relic支持,临时解决方案是将以下内容添加到您的settings.py或celeryconfig.py(取决于您用于芹菜设置的那些)。

import logging
class RequestsConnectionFilter(logging.Filter):
    def filter(self, record):
        return False
logging.getLogger('newrelic.lib.requests.packages.urllib3.connectionpool').addFilter(RequestsConnectionFilter())

NR支持告诉我他们计划在未来版本的python代理中构建这种抑制。