Instrument Java code your way: TraceView Java API
Join the DZone community and get the full member experience.
Join For FreeWhen it comes to analyzing your web application’s performance, TraceView has already instruments a wide spectrum of Java components, such as application servers, frameworks and JDBC connections, all with the convenience of simply including TraceView Java agent jar in your JVM. However, have you come across situations that make you think, “It would have been nice if this was traced too”? You can do this with the TraceView Java API!
Don’t feel like coding? Just annotate it!
Have you seen a slowdown in your code, and have some methods you’d like to check? The simplest way is to add the @LogMethod or @ProfileMethod annotation to those methods. Invocations to those methods will then be traced by the Java agent and reflected on your TraceView panels. Since you can assign different layer/profile names for those methods, you can easily group them and gather useful statistics from your TraceView pages! (Heat map, layer/profile summary etc). You might even turn on back trace tracking or store the method return values by tweaking various optional parameters. A simple guide could be found here.
Need more power? Add a few lines of code!
TraceView Java Agent was built for web applications, so traces are normally triggered by web requests. However, this does not mean you are limited to tracing web applications. In fact, you can even trace stand-alone applications with TraceView Java Agent with just a couple lines of code!
For example, you may have a day-end process that perform several scheduled tasks which each run in its own separate thread, some tasks may involve database operations. Adding the 2 steps below not only measures the timing of the job, but also any of the database calls that were invoked during the task itself.
But wait… where is the code that traces the database operations? You
do not need to worry about it! In fact, once you start a Trace using
the API, anything comes down the calling stack with layer recognized by
TraceView Java Agent (JDBC, Apache Http Client, etc.) will be
instrumented.
Try it out!
That’s it! Kick start the Java process with the TraceView Java Agent and you will start seeing traces of your custom layer on the jobs. By assigning different layer names, you can easily customize the groupings, and even handle different concurrency models by digging into the full API. Sign up for a free account, and start tracing today!
Tracing Black Boxes I: JMX Insight Into JVM Performance
Solving Slow Database Performance In Java and MySQL
TraceView: Now With Free Tracing (and more)!
Opinions expressed by DZone contributors are their own.
Comments