微服务

微服务性能监控 - APM工具

2021-06-20  本文已影响0人  架构师老狼

Elastic APM

组件

数据模型

使用实践

output.elasticsearch:
  hosts: ["localhost:9200"]
apm-sever -e
<!--Elastic Agent相关依赖-->
<dependency>
    <groupId>co.elastic.apm</groupId>
    <artifactId>apm-agent-attach</artifactId>
    <version>1.17.0</version>
</dependency>
@SpringBootApplication
public class MallTinyApplication {

    public static void main(String[] args) {
        ElasticApmAttacher.attach();
        SpringApplication.run(MallTinyApplication.class, args);
    }

}
# 配置服务名称
service_name=macro-apm
# 配置应用所在基础包
application_packages=com.z.tiny
# 配置APM Server的访问地址
server_urls=http://localhost:8002

查看性能监控信息

    @ApiOperation("远程调用获取所有品牌信息")
    @RequestMapping(value = "/remoteListAll", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<List<PmsBrand>> remoteListAll() {
        //模拟耗时操作
        ThreadUtil.sleep(1, TimeUnit.SECONDS);
        //远程调用获取数据
        String response = HttpUtil.get("http://localhost:8001/brand/listAll");
        JSONObject jsonObject = new JSONObject(response);
        JSONArray data = jsonObject.getJSONArray("data");
        List<PmsBrand> brandList = data.toList(PmsBrand.class);
        return CommonResult.success(brandList);
    }
上一篇下一篇

猜你喜欢

热点阅读