Code Monkey home page Code Monkey logo

javaagent's Introduction

Javaagent

概述

javaagent是一个简单优雅的java agent,利用java自带的instrument特性+javassist字节码编辑技术,实现了无侵入的方法级性能监控。相比于NewRelic或者开源的pinpoint,以及阿里的arthas,本工具主打的是简单,我们只记录每个方法的执行次数和时间,并输出到json格式的日志文件中。基于javaagent的日志,你可以使用严丽同学开发的agent日志分析工具进行分析查询,也可以使用在线日志分析器,或者可以自己去写分析器,这样可以让你快速定位生产环境的性能瓶颈。

集成

java启动参数中就有jaaagent,你只需要在JAVA_OPTS中加入-javaagent:/opt/javaagent/javaagent.jar=/opt/javaagent/agent.properties就实现了方法级监控。其中=前指定的是jar包的路径,=后指定的是对agent的一些配置参数。

agent.properties说明

# 需要监控的包,多个包用分号分隔
agent.include.package=com.XXX
# 不需要监控的包,多个包用分号分隔。 需要监控的包-不需要监控的包就是真正要监控的包
agent.exclude.package=
# 日志文件,会自动增加日期后缀
agent.log.file=d\:\\agent.log
# 日志输出周期
agent.log.interval.seconds=600
# 不需要监控的类的正则表达式
agent.exclude.class.regex=
# 是否记录平均时间
agent.log.avg.execute.time=false
# 默认不需要监控的类的正则表达式
agent.exclude.class.regex.default=.*EnhancerByCGLIB.*;.*FastClassByCGLIB.*
# 记录方法的耗时时是采用nanoTime,还是currentTimeMillis,nanoTime更准确,但是会耗时一些
agent.log.nano=true

agent日志分析器使用

agent日志分析器是我同事严丽使用SpringBoot+h2数据库开发的分析工具,除了基础功能,对于有sql能力的同学,你可以直接使用console登录后,直接写sql进行统计,你可以按自己想要的维度来进行处理。

  • JDBC URL: jdbc:h2:mem:~/h2test
  • USer Name : sa
  • Password : 空 登录后,你就可以尽情的写sql了。

javaagent's People

Watchers

enjoyan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.