• /
  • Log in
  • Free account

Instrument browser monitoring with Java agent API

Browser monitoring gives you visibility into how your users are interacting with your Java application by using a JavaScript snippet (or "agent") to instrument your app's webpages. To install the browser agent via the UI, follow the procedures to install the browser agent. For example, you can:

  • Enable an APM-monitored app.
  • Enable with the copy/paste method.
  • Enable by using the REST API.

You can also manually instrument your webpages by using the Java agent API, as explained in this document.

Use Java agent API

If your framework does not allow you to enable browser monitoring from our UI, with the copy/paste method, or by using our REST API, you can manually instrument monitoring for your webpages. To do this, use our Java agent API.

  1. Make sure you are using the latest Java agent version.

  2. Disable auto-instrumentation.

  3. Access the Java agent API class by adding newrelic-api.jar to your application class path.

  4. Add the appropriate method to start time tracking, for example: com.newrelic.api.agent.NewRelic.getBrowserTimingHeader().

    Add the appropriate method to stop time tracking, for example: com.newrelic.api.agent.NewRelic.getBrowserTimingFooter().

    Find the appropriate methods based on the framework you are using:

  5. Check the log file to verify that the agent is instrumenting correctly. Set the log_level setting in newrelic.yml to log_level: finer and check for the following messages:

For more help

If you need more help, check out these support and learning resources:

Create issueEdit page
Copyright © 2021 New Relic Inc.