newrelic 代理仅在登台时不向 newrelic 服务器发送数据

newrelic agent is not sending data to newrelic servers at staging only

我有一个新的遗物代理配置如下:

newrelic==2.56.0.42

    newrelic.agent.initialize(newrelic_ini_file, newrelic_env)
    logging.info('NewRelic initialized with newrelic_env '+repr(newrelic_env))
    logging.info('NewRelic config name is '+repr(newrelic.agent.application().name))

它正在记录 staging 中的 "right" 内容,但未发送。

 NewRelic initialized with newrelic_env 'staging'
 NewRelic config name is 'My Service (Staging)'

代理从 localhostproduction 发送数据。

这是 newrelic.ini 文件中的一些配置

[newrelic]
license_key = xxxxx
app_name = My Service
monitor_mode = true
log_file = /tmp/newrelic-python-agent.log
log_level = info

这是我在 newrelic.ini

中的暂存配置
[newrelic:staging]
app_name = My Service (Staging)
monitor_mode = true
log_level = debug

一个我认为可疑的日志是这个

(14/NR-Harvest-Thread) newrelic.core.agent DEBUG - Completed harvest of all application data in 0.00 seconds.

我认为由于 0.00 seconds 部分,代理未收集任何数据。

我应该寻找什么 debug 日志,以验证从新遗物发送和接收的实际数据 200

其他详细信息: 分期是 运行 Docker alpine:3.6

根据newrelic discussFailure Base/Log/Copy可以通过配置更改解决

You can include this line in your config file, as well, which will stop them from going to the default location:

log_to_stdout: false

另一个issue可以是日志级别应该是info

log_level = info

Logging at debug can generate a lot of data very quickly. Monitor the size of your log file closely, changing log_level back to info as you finish troubleshooting.

编辑

问题已在 newrelic discuss 中提出。

答案的线索确实是 harvest of all application data in 0.00 seconds.

的调试日志

显然,newrelic.agent.initialize 必须在 app = Flask(__name__) 之前。之前移动并开始发送。