Hi,
I am working on a java agent which can be used to monitor different
activities carried out within DAS. Main concept of java agent is to modify
bytecode of classes before they load onto JVM (bytecode instrumentation).
This provide the ability to inject code into classes according to our
requirement.
Currently we are trying to implement a simple agent, which can monitor
method calls and parameters passed under a given scenario and publish them
to a stream in DAS. The architecture of this approach will be as follows.
[image: Inline image 1]
We will provide a simple configuration file, where user has to specify the
class name, method name with signature, parameters to monitor and the
location to be inserted (using javassist we can insert code at the top, at
bottom and at a specific line of the method). Then the agent will be
initialized based on the user requirement and instrument the requested
methods before respective classes load onto JVM. (Javassist will be the
library used in the instrumentation process) Once the classes are
instrumented before the server start running, we will be able to publish
events containing the intercepted data to a stream in DAS. Using the
ability to publishing arbitrary fields in DAS, we are trying to provide the
ability to index and store events with intercepted data. This can be used
as a profiler to monitor the activities of the server.
Layout of configuration file
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<instrumentationAgent>
<scenario name="jdbc-monitoring">
<instrumentingClass name="com.mysql.jdbc.ConnectionImpl">
<instrumentingMethod name="prepareStatement"
signature="(Ljava/lang/String;)Ljava/sql/PreparedStatement;">
<insertBeforeContent></insertBeforeContent>
<insertAts>
<insertAt lineNo="1">
<parameterName key="query">$1</parameterName>
</insertAt>
</insertAts>
<insertAfterContent></insertAfterContent>
</instrumentingMethod>
</instrumentingClass>
</scenario>
</instrumentationAgent>
This is the overall idea about the java agent we are working on. Hope this
will be able to add value to the product. Appreciate any suggestions on
this.
Thanks,
Udani
--
*Udani Weeraratne*
Software Engineer - Intern
WSO2 Inc.: www.wso2.com
lean.enterprise.middleware
Email: [email protected]
Mobile: +94 775437714
LinkedIn: *https://lk.linkedin.com/in/udaniweeraratne
<https://lk.linkedin.com/in/udaniweeraratne>*
Blog : https://udaniweeraratne.wordpress.com/
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture