1 Star 0 Fork 31

yan5845hao / MyPerf4J

forked from Gitee 极速下载 / MyPerf4J 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
BSD-3-Clause

MyPerf4J

Markdown

一个针对高并发、低延迟应用设计的高性能且无侵入的实时Java性能监控和统计工具。 受 perf4jTProfiler启发而来。

MyPerf4J具有以下几个特性:

  • 无侵入: 采用JavaAgent方式,对应用程序完全无侵入,无需修改应用代码
  • 高性能: 性能消耗非常小,每次记录只花费73ns,可以在生产环境长期使用
  • 低内存: 采用内存复用的方式,整个生命周期只产生极少的临时对象,不影响应用程序的GC
  • 高精度: 采用纳秒来计算响应时间
  • 高实时: 支持秒级监控,最低1s!

文档

监控指标

MyPerf4J为每个应用收集数十个监控指标,所有的监控指标都是实时采集和展现的。

下面是MyPerf4J目前支持的监控指标列表:

  • Method
    RPS,Count,Avg,Min,Max,StdDev,TP50, TP90, TP95, TP99, TP999, TP9999, TP99999, TP100 Markdown Markdown
  • JVM Thread
    TotalStarted,Runnable,Blocked,Waiting,TimedWaiting,Terminated,Active,Peak,Daemon,New Markdown

  • JVM Memory
    HeapInit,HeapUsed,HeapCommitted,HeapMax,NonHeapInit,NonHeapUsed,NonHeapCommitted,NonHeapMax Markdown

  • JVM GC
    CollectCount,CollectTime Markdown

  • JVM Class
    Total,Loaded,Unloaded Markdown

    想知道如何实现上述效果?请先按照快速启动的描述启动应用,再按照这里的描述进行安装配置即可。

快速启动

MyPerf4J采用JavaAgent配置方式,透明化接入应用,对应用代码完全没有侵入

打包

  • git clone git@github.com:ThinkpadNC5/MyPerf4J.git
  • mvn clean package
  • 把 MyPerf4J-ASM-${MyPerf4J-version}.jar 重命名为 MyPerf4J-ASM.jar

配置

在JVM启动参数里加上以下两个参数

-javaagent:/your/path/to/MyPerf4J-ASM-${MyPerf4J-version}.jar

-DMyPerf4JPropFile=/your/path/to/myPerf4J.properties

其中,MyPerf4JPropFile的配置如下:

#应用名称
AppName=MyPerf4JTest

#MetricsProcessor类型,0:以标准格式化结构输出到stdout.log 1:以标准格式化结构输出到磁盘  2:以InfluxDB LineProtocol格式输出到磁盘
MetricsProcessorType=1

#配置各个Metrics日志的文件路径,可不配置
MethodMetricsFile=/data/logs/MyPerf4J/method_metrics.log
#ClassMetricsFile=/data/logs/MyPerf4J/class_metrics.log
#GCMetricsFile=/data/logs/MyPerf4J/gc_metrics.log
#MemMetricsFile=/data/logs/MyPerf4J/memory_metrics.log
#ThreadMetricsFile=/data/logs/MyPerf4J/thread_metrics.log

#配置日志文件滚动时间间隔,分别有MINUTELY、HOURLY和DAILY三个值
LogRollingTimeUnit=HOURLY
   
#配置备份Recorders的数量,默认为1,最小为1,最大为8,当需要在较小MillTimeSlice内统计大量方法性能数据时可配置大一些
BackupRecordersCount=1
   
#配置Record模式,可配置为accurate/rough
RecorderMode=accurate
   
#配置时间片,单位为ms,最小1s,最大600s
MillTimeSlice=10000

#是否展示方法参数类型
ShowMethodParams=true
   
#需要监控的package,可配置多个,用英文';'分隔
IncludePackages=cn.perf4j.demo
   
#不需要监控的package,可配置多个,用英文';'分隔
ExcludePackages=org.spring;
   
#可配置多个方法名,用英文';'分隔
ExcludeMethods=equals;hash
   
#是否排除私有方法,true/false
ExcludePrivateMethod=true
   
#通用的方法执行时间阈值,单位为ms
ProfilingTimeThreshold=1000
   
#在一个时间片内,超过方法执行时间阈值的次数,仅在RecorderMode=accurate时有效
ProfilingOutThresholdCount=10

想了解更多的配置?请看这里

运行

  • 输出结果,输出到/data/logs/MyPerf4J/method_metrics.log:

    MyPerf4J Method Metrics [2018-09-06 19:21:40, 2018-09-06 19:21:45]
    Method[4]                           RPS  Avg(ms)  Min(ms)  Max(ms)   StdDev     Count     TP50     TP90     TP95     TP99    TP999   TP9999  TP99999    TP100
    DemoServiceImpl.getId1(long)       1974     0.00        0        0     0.00      9870        0        0        0        0        0        0        0        0
    DemoServiceImpl.getId2(long)       2995     0.50        0        2     0.01     14975        0        1        2        2        2        2        2        2
    DemoServiceImplV2.getId1(long)      787     0.00        0        0     0.00      3938        0        0        0        0        0        0        0        0
    DemoServiceImplV2.getId3(long)     1575     0.50        0        1     0.01      7876        1        1        1        1        1        1        1        1

卸载

在JVM启动参数中去掉以下两个参数,重启即可卸载此工具。

-javaagent:/your/path/to/MyPerf4J-ASM.jar

-DMyPerf4JPropFile=/your/path/to/myPerf4J.properties

问题

如果您遇到任何问题或有疑问,请您毫不犹豫的提交Issue : )

更多信息

想更深入的了解MyPerf4J?请看https://github.com/ThinkpadNC5/MyPerf4J/wiki/Chinese-Doc

BSD 3-Clause License Copyright (c) 2018, LinShunkang All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

简介

MyPerf4J是什么? 一个极快、无侵入的Java方法性能监控和统计工具 展开 收起
BSD-3-Clause
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/yan5845hao/MyPerf4J.git
git@gitee.com:yan5845hao/MyPerf4J.git
yan5845hao
MyPerf4J
MyPerf4J
master

搜索帮助