|
Instrumenting a Java-based Web Site / Web Application
By default, you can use the egrum.jar file that eG provides to instrument a Java-based web site/web application that dynamically generates web pages. To perform this instrumentation, do the following:
- First, download the egrum.jar to the system hosting the web application. For this, click the Download button alongside egrum.jar in the To instrument your html pages use the eG javascript agent section of the COMPONENT page.
- Once the download is complete, make sure that the egrum.jar is included in the class path of the target web application. If you are using an IDE, copy it into your build project and make sure it's accessible in your runtime classpath.
- Next, open the page source file that dynamically generates web pages, in an editor. In the header of the page, insert the code that imports the helper class - com.eg.RUMHandler - into the page, as shown in Red below:
<%@ page language=“java” contentType=“text/html” import=“com.eg.RUMHandler;” %>
<html>
- This helper class will automatically inject the JavaScript code snippet into the page.
- To expose the output of the RUMHandler method, insert the line of code shown below, just after any <meta> tags in your <head> block. Note that this code should be the first non-meta tag inside the <head> block.
<%@ page language=“java” contentType=“text/html” import=“com.eg.RUMHandler;” %>
<html>
<head>
<meta ... >
<!-- RUMHandler method return strings so you need to expose their output as shown
-->
<% out.println(RUMHandler.getHeader()); %>
...
</head>
<body>
...
</body>
</html>
- Save the edited page and restart the web site/web application being monitored.
- Now, test your web application locally and view the page source in your browser. The page markup should include < !-- RUM Header -->.
- Repeat steps 3 to 7 above for each page in your web site/web application that dynamically generates web pages.
Once this is done, then the auto-injected JavaScript will track requests to each of the dynamically generated web pages and report response time metrics it collects to the RUM collector.
|