Coder Social home page Coder Social logo

stevensouza / automon Goto Github PK

View Code? Open in Web Editor NEW
566.0 50.0 142.0 8.36 MB

Automon combines the power of AOP (AspectJ) with monitoring or logging tools you already use to declaratively monitor your Java code, the JDK, and 3rd party libraries.

License: Apache License 2.0

Java 96.74% AspectJ 3.26%
aspectj monitoring java performance aop performance-monitoring

automon's Introduction

Automon

Automon combines the power of AOP (AspectJ) with monitoring tools or logging tools that you already use to declaratively monitor the following:

  • Your Java code,
  • The JDK,
  • Any jars used by your application.

Some monitoring tools Automon currently works with are: JAMon, JavaSimon, Yammer Metrics, StatsD, Micrometer. Here are the current implementations. If automon doesn't support your tool of intrest it can usually be supported by adding a simple class.

Note: Micrometer serves as a proxy for other monitoring/metering APIs and so through it automon does too. As of 5/2019 the list of tools Micrometer can proxy includes: AppOptics, Atlas, Datadog, Dynatrace, Elastic, Ganglia, Graphite, Humio, Influx, JMX, KairosDB, New Relic, Prometheus, SignalFx, StatsD, Wavefront.

Automon is typically used to track method invocation time, and exception counts. It is very easy to set-up and you should be able to start monitoring your code within minutes. The data will be stored and displayed using the monitoring tool of your choice. The following image shows the type of data Automon collects (The example below displays the data in JAMon, however the data can be displayed in whatever monitoring tool/api you choose. For example here is same data displayed in grahphite/StatsD).

Automon method and exception metrics displayed in JAMon

The following is a sample command that will monitor your program with Automon (in this case using JAMon):

  • java -Dorg.aspectj.weaver.loadtime.configuration=file:aop.xml -javaagent:aspectjweaver.jar -classpath automon-{version}.jar:myapplication.jar:jamon-2.81.jar com.mypackage.MyClass
  • Running with Micrometer, Yammer Metrics, StatsD, JavaSimon etc. you would simply use their respective jars instead of the JAMon jar
  • aop.xml (AspectJ file) is where you define what parts of your program you want monitored (through 'pointcuts'). It is often quite simple.
  • aspectjweaver.jar is required for AspectJ to monitor the code.

See 'Getting Started' below and examples for instructions on how to run Automon with CodaHale/Yammer Metrics, JavaSimon, NewRelic, StatsD, Tomcat and Jetty.

It is important to note that Automon is complimentary to monitoring and logging tools. Automon performs no monitoring on its own. It serves as a bridge between AspectJ (AspectJ defines 'what to monitor') and monitoring and logging tools (which define 'how to monitor'). You can also easily provide your own monitoring tool by implementing the simple OpenMon interface.

The following diagram shows an AspectJ pointcut that will monitor all methods (any return type, any number of arguments) in the 'com.mycompany' package as well as its subpackages (..) using your monitoring tool of choice. Automon

Automon requires jdk 1.5 or higher.

And finally, Automon can be dynamically enabled/disabled via the Automon MXBean (JMX).

AspectJ Weaving

AspectJ 'weaves' Automon monitoring code into your classes. This can be done...

  • at runtime with the Load Time Weaver (LTW)
  • at build time with the Build Time Weaver (BTW).

Both approaches replace the original class files with ones that have monitoring added to them. Regardless of whether LTW, or BTW is used the generated class files are identical. LTW is more flexible as it lets you use the powerful AspectJ pointcut language at runtime to specify what classes you want to monitor. It also lets you monitor jdk classes and 3rd party library classes that you don't own such as java.net, jdbc, hadoop, spark etc. BTW only let's you monitor your own source code.

Here is a short video that shows how to monitor your code using Automon with LTW: Automon demo

Getting Started

The quickest way to get started with Automon is to download this distribution, and go to the examples directory and run the sample programs (*.sh). There are more directions on running the examples in the 'examples' directories README file.

If you are using Spring the following maven module shows how to monitor Spring beans with Automon. In particular look at the Spring applicationContext.xml file to see how to specify which Spring beans to monitor.

Automon does not require Spring though. Running a non-Spring program with Automon is easy too. You simply...

  • Put automon-{version}.jar in your classpath,
  • And make either aspectjweaver.jar (LTW), or aspectjrt.jar (BTW) available.

The examples directory shows how to invoke your programs using both LTW, and BTW.

Load Time Weaving (LTW) also involves providing an ajc-aop.xml config file. Review the config files for more information on them. The following maven projects generate plain (unwoven) java jars. Each of them has a *.sh script in the examples directory that lets you run the the java code with LTW.

  • helloworld_unwoven_jamon - A simple program monitored with Jamon. If you pass a command line argument to run the program in a loop the program will run long enough that you can look at the Jamon metrics MBeans in the Jconsole.
  • unwoven_jdk - A simple program that when used with LTW will monitor Java IO, Http requests, and JDBC calls.
  • webapp_unwoven - A web application (war) that can be installed in a web container like Tomcat or Jetty. It monitors calls to the jdk (jdbc, io, and http requests) and custom classes. See README.md for more information.

Build Time Weaving (BTW) - And finally if you want to use Build Time Weaving in your maven build process refer to these BTW sample projects (In the examples I use 'woven' and BTW synonymously):

  • helloworld_woven - A simple project that has a dependency on Automon and a simple jar that contains a HelloWorld application. The output of this project is a jar that contains AspectJ BTW woven code.
  • spring_woven - This project shows how you can weave a Spring project at build time.
  • Another example using Spring woven and Apache Camel. See more details in the comments section for camel_experiment6_soap. This example let's you instrument/monitor any class that you own and not just Spring beans.

The examples directory has scripts (*.sh) to run these programs.

An interview that covers Automon can be found here.

Maven

Incorporate Automon into your maven project by adding the following dependency (using the most current version).

      <dependency>
          <groupId>org.automon</groupId>
          <artifactId>automon</artifactId>
          <version>1.0.3</version>
      </dependency>

Automon Source Code

The code that generates the automon-{version}.jar file is contained in this directory.

Support

And finally, if you need support contact us at Issues or email us at [email protected].

Thanks, and happy monitoring!

Steve

automon's People

Contributors

dependabot[bot] avatar stevensouza avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

automon's Issues

BeanCreationException: Error creating bean

Hi,

I'm having an issue with starting my service with automon. I'm not that into aspectj, so I hope you could give me a hint whether my setup is just wrong or something could be improved in automon project.
I get:

org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'serviceApplicationConfiguration': 
BeanPostProcessor before instantiation of bean failed; nested exception is java.lang.IllegalStateException: 
Expecting to find 2 arguments to bind by name in advice, but actually found 1 arguments.

in

org.springframework.aop.aspectj.AbstractAspectJAdvice#calculateArgumentBindings

AbstractAspectJAdvice has only one String in argumentNames when trying to bind Object around() throws Throwable : _monitor() from AutomonAspect.aj. He recognizes only the first argument in runtime (_monitor).
I'm using spring 3.2.4.RELEASE (which I tested with your spring-woven example - works fine). Instead of using xml based bean definition, I use org.springframework.context.annotation.Beans and pointcuts and aspects.

My ServiceApplicationConfiguration which is annotated with org.springframework.context.annotation.Configuration and EnableAspectJAutoProxy(proxyTargetClass = true) should load my Aspect which extends your SpringBase and defines pointcuts same as you do in spring-woven example. If you have any idea what I'm doing wrong, I'd appreciate the hints.

Cheers,
Nikola

P.S. Perhaps it's unclear. I'd see to get some example in my fork with minimal code representing the issue soon.

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.