statsd-jvm-profiler是etsy開發的一個 JVM 代理 Profiler,其將Profile數據發送到 StatsD.java
-javaagent:/usr/etsy/statsd-jvm-profiler/statsd-jvm-profiler.jar=server=statsdHost,port=statsdPort
將該jar包拷貝到spring boot工程的main resource目錄下,而後git
@Bean public CommandLineRunner loadProfilerAgent(){ return new CommandLineRunner() { @Override public void run(String... strings) throws Exception { ApplicationPid pid = new ApplicationPid(); try{ com.sun.tools.attach.VirtualMachine vm = com.sun.tools.attach.VirtualMachine.attach(pid.toString()); ClassLoader classLoader = getClass().getClassLoader(); String profilerJarPath = classLoader.getResource("statsd-jvm-profiler-2.0.0.jar").getPath(); String agentArgs = "server="+statsdHost+",port="+statsdPort; vm.loadAgent(profilerJarPath, agentArgs); vm.detach(); System.out.println("Dynamically loaded StatsD JVM Profiler Agent..."); }catch (Exception e){ e.printStackTrace(); } } }; }
該agent內置了一個http server,默認端口爲5005,能夠訪問以下幾個path
http://localhost:5005/errors
http://localhost:5005/isRunning
http://localhost:5005/profilers
http://localhost:5005/disable...
http://localhost:5005/status/...github
在graphite裏頭,statsd-jvm-profiler前綴的gauges就是了。spring