AppDynamics Application Intelligence Platform

3.8.x Documentation

PDFs

Videos

Release Notes

To use assisted injection of the JavaScript agent using attribute injection, you: 

  • Enable attribute injection in AppDynamics
  • Copy code snippets into your page template 

Not all frameworks support attribute injection. See the Script Injection columns in the Supported Platform Matrix for Web EUM matrices to check if you can use this method.

Access the JavaScript Injection Configuration Panel

  1. In the left navigation menu, click Configure -> Instrumentation.
  2. Click the End User Experience tab.
  3. Click the Web JavaScript Instrumentation tab if it is not already selected.
  4. Scroll down to the Advanced panel and expand it if it is closed.
  5. Expand Advanced Instrumentation of your HTML Pages if it is closed.
  6. Click the Configure JavaScript Injection tab if it is not already selected.

7. Check Request Attribute Injection.

8. Click Save.

Copy Code Snippets into Your Page Template

The following examples show code snippets that can be copied directly into your page templates or other code creating your page. These code snippets tell 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.  

(info) 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:

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()) }

 

Learn More

  • No labels

3 Comments

  1. Unknown User (eric.barr@aon.com)

    In the asp.net code snippet, it would be nice to see a distinction between VB.NET and C#.  Second, it would be nice to have "then / end if" or curly braces for consistency, when compared with snippets of other languages/frameworks.

    1. Thanks for the feedback, Eric.

      I've updated the ASP.NET example to clarify that it is C# code.

      The code snippet uses the supported syntax provided by our engineering team.

  2. Unknown User (ellen.evans@appdynamics.com)

    A JIRA has been created.  The doc will be updated when the information is available.