[lttng-dev] tracing of non-JNI java in IBM jvm

Aaron Spear aspear at vmware.com
Fri Jan 11 13:55:37 EST 2013


----- Original Message -----
> From: "Erik Ostermueller" <Erik.Ostermueller at fisglobal.com>
> To: "Alexandre Montplaisir" <alexmonthy at voxpopuli.im>
> Cc: lttng-dev at lists.lttng.org
> Sent: Friday, January 11, 2013 9:26:51 AM
> Subject: Re: [lttng-dev] tracing of non-JNI java in IBM jvm
> 
> Thanks Alex for the quick reply....now I get it.
> I'll jump in on that other thread you mentioned.
> 
> There is a tool called InTrace that does some of this work.
> Perhaps some design ideas or even code could be stolen from here:
>  http://mchr3k.github.com/org.intrace/
> This project:
> * implements the java.lang.instrumentation api, which can be used to
> plug a tracing tool into an already-running JVM.
> * allows you to instrument/de-instrument various classes without
> restarting the JVM.
> * Uses http://asm.ow2.org/ to inject byte code for entry/exit tracing
> methods.
> * stores thread id (good) but does nothing to sort/organize activity
> by thread id into a session(bad)
> * no graphing/aggregating of performance metrics...just displays
> entry/exit times, method parameters, etc...

Hi Erik,

I think that what you are mentioning is certainly one thing that is needed. To me I see a couple of different components here:
1) implementation of java.util.logging interfaces as well as SLF4J interfaces, as well as a dedicated LTTng java API for registering
custom event typess.  This would be used for static, compile time instrumentation of java apps.
2) an implementation that uses the tooling you mention above for dynamic instrumentation of any running java app.  You basically would define trace and install trace points on the fly.  This would be really, really powerful.

The implementations of the above would have to be quite different from the way that things are done currently with UST.  Currently UST uses macros in C files to define the various tracepoints statically.  We would need to have API's that could be called dynamically to define tracepoints, so that the java code could do this.  I have not actually looked under the hood with the current UST implementation to see what the implications are for this.  

It seems to me that we would want to have a Java API usage similar to what you can do with SLF4J:

class MyClass {
      private static final Tracer tracer = LTTngFactory.getTracer("MyComponentName");
      private static final String MY_TRACEPOINT = "MyTracepointWithIntegerStringAndLong";

      static {
          // register a tracepoint.  this goes through JNI and creates a tracepoint
          // in UST that has the given name and the specified objects
          tracer.registerTracepoint(MY_TRACEPOINT,
                                     new Object[]{Integer.class,String.class,Long.class});
      }

      public void someMethod() {
          Integer someInteger = 123456;
          String  someString = "this is the string";
          Long  someLong = 56789;

          tracer.trace(MY_TRACEPOINT,someInteger,someString,someLong);
      }
}

Then over the top of this you have implementations of SLF4J, java.util.logging, whatever.  The infrastructure required in the JNI side for this would be the same implementation needed by the binding to the InTrace technology to dynamically create tracepoints.

I need all of this right now, and am willing to spend time in the next few months to implement it.

cheers,
Aaron Spear, Staff Engineer, VMware Inc



More information about the lttng-dev mailing list