3 Monitoring you applications - lucamingardi/jeeobserver GitHub Wiki
First of all configure your web application as described in Chapter 2.3 Configuring Java web applications.
Enable Servlet and Web pages monitoring including this Filter inside web.xml (WEB-INF/web.xml) of your web application:
<web-app...>
<!-- jeeObserver Servlet Filter -->
<filter>
<display-name>JeeObserver servlet filter</display-name>
<filter-name>jeeObserverServletFilter</filter-name>
<filter-class>jeeobserver.ServletFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>jeeObserverServletFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
The name of the project is the display-name in web.xml file. If display-name is empty the context path of the project will be used.
In the example url-pattern tag is used to intercept all requests, if you wanto to analyze a single servlet you must use servlet-name tag instead.
First of all configure your web application as described in Chapter 2.3 Configuring Java web applications.
Enable JSF actions monitoring including this ServletContextListener inside web.xml (WEB-INF/web.xml) of your web application:
<web-app...>
<!-- jeeObserver JSF listener -->
<listener>
<listener-class>jeeobserver.JsfListener</listener-class>
</listener>
</web-app>
The name of the project is the display-name in web.xml file. If display-name is empty the context path of the project will be used.
Alternative:
If your implementation of JSF doesn't support jeeobserver.JsfListener you can edit faces-config.xml:
<faces-config...>
<application>
<!-- jeeObserver JSF Action listener -->
<action-listener>jeeobserver.JsfActionListener</action-listener>
</application>
</faces-config>
First of all configure your web application as described in Chapter 2.3 Configuring Java web applications.
Enable EJB invocations monitoring including this EjbInterceptor inside ejb-jar.xml (WEB-INF/ejb-jar.xml) of your web application:
<ejb-jar...>
<interceptors>
<!-- jeeObserver ejb interceptor -->
<interceptor>
<interceptor-class>jeeobserver.EjbInterceptor</interceptor-class>
<!-- jeeObserver Custom project name for EJB interceptor -->
<!-- uncomment if want to set custom project name. Default is empty String
<env-entry>
<description>Name of the project to insert into jeeobserver statistics</description>
<env-entry-name>jeeobserverProjectName</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>CUSTOM_PROJECT_NAME</env-entry-value>
</env-entry>-->
</interceptor>
</interceptors>
<assembly-descriptor>
<interceptor-binding>
<ejb-name>*</ejb-name>
<interceptor-class>jeeobserver.EjbInterceptor</interceptor-class>
</interceptor-binding>
</assembly-descriptor>
</ejb-jar>
The project name by default is an empty string. If you want to give a custom name remove the comment defines the env-entry setting the value of the name you want to associate with the project.
First of all configure your application as described in Chapter 2.3 Configuring Java web applications or 2.4 Configuring Java applications.
JDBC observer, using a custom JDBC Driver, is able to save statistics of all queries executed by statements of a connection.
Enable JDBC connections monitoring updating JDBC url like jdbc:yourdb to jdbc:jeeobserver:yourdb and specify as driver class jeeobserver.JdbcDriver.:
If original JDBC driver class could be loaded you can specify jo_driver connection property.
Before
Driver: com.mysql.jdbc.Driver
URL: jdbc:mysql://localhost:3306/schema
After
Driver: jeeobserver.JdbcDriver
URL: jdbc:jeeobserver:mysql://localhost:3306/schema?jo_driver=com.mysql.jdbc.Driver
First of all configure your application as described in Chapter 2.3 Configuring Java web applications or 2.4 Configuring Java applications.
JAXWS observer, using a custom HandlerChain, is able to save statistics of all invocations at any method of a JAX Web Service.
Enable JAXWS monitoring adding in you WebService class the annotation:
@HandlerChain(file = "jeeobserver/jax-ws-handlers.xml")
First of all configure your web application as described in Chapter 2.3 Configuring Java web applications.
Enable HTTP sessions monitoring including this HttpSessionListener inside web.xml (WEB-INF/web.xml) of your web application:
<web-app...>
<!-- jeeObserver HTTP session listener -->
<listener>
<listener-class>jeeobserver.HttpSessionListener</listener-class>
</listener>
</web-app>
The name of the project is the display-name in web.xml file. If display-name is empty the context path of the project will be used.
First of all configure your web application as described in Chapter 2.4 Configuring Java applications.
You can monitor any method or "portion" of a method through the class ActionObserver. You can define a ActionObserver object anywhere and through the methods start and stop the code will be monitored. The class constructor requires as parameters the name of observer and the project name will be associated to the custom observer.
Here's an example of the ActionObserver class:
ActionObserver observer = new ActionObserver("myObserver");
observer.start();
for (int i = 0; i < 1000000; i++) {
//do something
int k = Math.round((i * 3) / 2);
}
observer.stop();
Java Virtual Machine monitoring starts automatically creating the jeeObserver context (Chapter 2.3 Configuring Java web applications and 2.4 Configuring Java applications).
Hard Disks monitoring starts automatically creating the jeeObserver context (Chapter 2.3 Configuring Java web applications and 2.4 Configuring Java applications).