skywalking 监控 springboot项目

 

  • 部署探针
  1. 打开idea开发工具Run-》Edit Configurations
  2. 点击Modify options -》Add VM option

-javaagent:E:\projectdeploy\apache-skywalking-apm-9.2.0\apache-skywalking-apm-bin\agent\skywalking-agent.jar
-Dskywalking.agent.service_name=service-mylesson

-javaagent:用于指定探针路径
-Dskywalking.agent.service_name:用于重写 agent/config/agent.config 配置文件中的服务名

-Dskywalking.collector.backend_service:用于重写 agent/config/agent.config 配置文件中的服务地址

  • 使用java命令启动方式
java -javaagent:E:\projectdeploy\apache-skywalking-apm-9.2.0\apache-skywalking-apm-bin\agent\skywalking-agent.jar=-Dskywalking.agent.service_name=service-mylesson,-Dskywalking.collector.backend_service=localhost:8090 -jar mylesson.jar
  • 调用接口后,展示效果
package com.example.mylesson.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ProductController {

    @ResponseBody
    @RequestMapping(value = { "product/test" }, method = RequestMethod.GET)
    public String selectUserByName() throws InterruptedException {
        Thread.sleep(5000);
        return "hello";
    }
}

 

 

posted @ 2023-04-11 19:13  低调码农哥!  阅读(212)  评论(0编辑  收藏  举报