赞
踩
文章中,我通过一下步骤和配置来体验这两个功能:
apm-server.yml
,打开RUM功能(Distributed tracing是默认功能)我之前写过一个数字货币的回测程序,刚好用来测试。该程序的架构如下:
先下载安装包
curl -L -O https://artifacts.elastic.co/downloads/apm-server/apm-server-6.5.0-darwin-x86_64.tar.gz
tar xzvf apm-server-6.5.0-darwin-x86_64.tar.gz
cd apm-server-6.5.0-darwin-x86_64/
先修改目录下的apm-server.yml
,enable RUM
rum:
# To enable real user monitoring (RUM) support set this to true.
enabled: true
启动服务器:
./apm-server -e
先下载flask的客户端
pip install elastic-apm[flask]
因为是侵入式的,需要修改代码:
# or configure to use ELASTIC_APM in your application's settings
from elasticapm.contrib.flask import ElasticAPM
app.config['ELASTIC_APM'] = {
'SERVICE_NAME': 'python-backend',
}
apm = ElasticAPM(app)
注意,这里如果不配置SERVICE_NAME,仍然可以正常启动,但是在APM Server端看不到任何数据
启动后,会看到如下信息(包含很多的Instrumented打印,表示agent开始监测对应的库活动):
2019-01-28 17:16:27,267 _internal.py[line:88] INFO * Running on http://0.0.0.0:80/
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。