Assisted Injection
Related pages:
This page describes how to instrument a browser application through assisted injection of the JavaScript Agent. Assisted injection is when your server-side application injects the JavaScript Agent into your browser application. You can configure your business applications to inject the JavaScript Agent into your browser applications.
Types of Assisted Injection
You can perform assisted injection with rules or through attributes. This table summarizes the platforms supported for each type of assisted injection and the process for performing the assisted injection.
Type of Assisted Injection | Supported Platforms | Description |
---|---|---|
Injection Rules | Java |
Type of assisted injection uses rules to configure which Java classes should be intercepted. You create the injection rules in the User Experience App Integration Panel of the Controller UI for the business application that will inject the JavaScript Agent. |
Attribute Injection | Java, ASP.NET |
Type of assisted injection relies on templates that tell the app agent where to inject information. You enable attribute injection in the User Experience App Integration Panel of the Controller UI for the business application that will inject the JavaScript Agent. Additionally, you add code snippets in the page templates that determine where the JavaScript Agent is injected. |
Injection Rules (Java Only)
To have your server-side application use assisted injection of the JavaScript Agent using injection rules, you define rules to configure:
- The Java classes and methods that should be intercepted
- The Java writer object and method to use to add the agent to the response object
Access the User Experience App Integration Panel
- From the Applications page, open the business application that you want to automatically inject the JavaScript Agent into your browser application.
- From the left navigation bar, select Configuration.
- Click User Experience App Integration.
Create JavaScript Injection Rules
- In the JavaScript Agent Injection tab, select a browser application from the Inject the JavaScript Agent configured for this Browser App dropdown.
- From the Configure JavaScript Injection tab, expand Create Injection Rules.
- Click the + icon to open the Create Manual Injection Rule dialog.
- From the Where to Inject JavaScript tab:
- Click Create Injection Rule.
Attribute Injection
To have your server-side application use assisted injection of the JavaScript Agent using attribute injection, you:
- Enable attribute injection
- Copy code snippets into your page template
Access the User Experience App Integration Panel
- From the Applications page, open the business application that you want to automatically inject the JavaScript Agent into your browser application.
- From the left navigation bar, select Configuration.
- Click User Experience App Integration.
Access the JavaScript Injection Configuration Panel
- From the User Experience App Integration page, click the JavaScript Agent Injection tab.
- In the JavaScript Agent Injection tab, select a browser application from the Inject the JavaScript Agent configured for this Browser App dropdown.
Copy Code Snippets into Your Page Template
These examples show code snippets that you can copy directly into your page templates or into other pages. These code snippets direct the app agent where to inject information. The header value must be injected at the very top of the <head> section and the footer value must be added at the very end of the code creating the page.
If you have already injected the header portion of the agent using manual injection, you can use these code snippets to automatically inject the footer data portion only. In this case, add only the JS_FOOTER values shown in the sections below.
JSF
<h:outputText rendered="#{AppDynamics_JS_HEADER != null}" value='#{request.getAttribute("AppDynamics_JS_HEADER")}' escape="false"/>
<h:outputText rendered="#{AppDynamics_JS_FOOTER != null}" value='#{request.getAttribute("AppDynamics_JS_FOOTER")}' escape="false"/>
JSP
<% if (request.getAttribute("AppDynamics_JS_HEADER") != null) { %> <%=request.getAttribute("AppDynamics_JS_HEADER")%> <% } %>
<% if (request.getAttribute("AppDynamics_JS_FOOTER") != null) { %> <%=request.getAttribute("AppDynamics_JS_FOOTER")%> <% } %>
Servlet
if (request.getAttribute("AppDynamics_JS_HEADER") != null)
{
out.write(request.getAttribute("AppDynamics_JS_HEADER".toString());
}
if (request.getAttribute("AppDynamics_JS_FOOTER") != null)
{
out.write(request.getAttribute("AppDynamics_JS_FOOTER").toString());
}
Groovy
<g:if test="${AppDynamics_JS_HEADER}">
${AppDynamics_JS_HEADER}
</g:if>
<g:if test="${AppDynamics_JS_FOOTER}">
${AppDynamics_JS_FOOTER}
</g:if>
Velocity Template
#if ($AppDynamics_JS_HEADER)
$AppDynamics_JS_HEADER
#end
#if ($AppDynamics_JS_FOOTER)
$AppDynamics_JS_FOOTER
#end
ASP.NET C#
<% if (Context.Items.Contains("AppDynamics_JS_HEADER"))
Response.Write(Context.Items["AppDynamics_JS_HEADER"]); %>
<% if (Context.Items.Contains("AppDynamics_JS_FOOTER"))
Response.Write(Context.Items["AppDynamics_JS_FOOTER"]); %>
MVC Razor
@if(HttpContext.Current.Items.Contains("AppDynamics_JS_HEADER"))
{ @Html.Raw((string)HttpContext.Current.Items["AppDynamics_JS_HEADER"]) }
@if(HttpContext.Current.Items.Contains("AppDynamics_JS_FOOTER") )
{ @Html.Raw(HttpContext.Current.Items["AppDynamics_JS_FOOTER"].ToString()) }