Using the Agent SDK


This document provides an overview of how to use the Agent SDK with some of the standard features of any other New Relic agent. It is not intended to be a comprehensive description of all the features and functions available to you.

Viewing transaction traces

New Relic APM automatically generates traces when transactions exceed the threshold, which defaults to two seconds. A maximum of two traces will be sent to New Relic per minute. To modify the threshold for any of your application's transactions, change your Apdex settings.

Recording and viewing custom metrics

Custom metrics give you a way to record arbitrary metrics about your application. You can also instrument your code, which will report performance metrics automatically whenever that code is executed. With a custom metric, you provide the value to be recorded for a specified metric name; for example:

newrelic_record_metric("ActiveUsers", 25);

To view custom metrics, create a custom dashboard.

Obfuscating query data

A query trace is automatically generated for each Datastore segment. Every minute the agent sends several of these traces to New Relic APM. The selected traces will represent the worst performing query statements during that minute.

Your database code may contain sensitive information that you do not want or need to send to New Relic APM. By default, the Agent SDK obfuscates your query strings. It uses a basic literal replacement obfuscator that strips the string literals and numeric sequences, and then replaces them with the ? character. For example:

SELECT * FROM table WHERE ssn=‘000-00-0000’

Obfuscates to:

SELECT * FROM table WHERE ssn=?

For more information, see Security options for transaction traces.

Because New Relic's default obfuscator only replaces literals, there could be cases that it does not handle well. For example:

  • Default obfuscation will not strip out comments from your query string.
  • Default obfuscation will not handle certain database-specific language features.
  • Default obfuscation could fail for other complex cases.

If this level of obfuscation is not sufficient, you can supply your own custom obfuscator.

Measuring customer satisfaction (Apdex T)

Apdex T is the response time threshold used to measure customer satisfaction. The transaction trace threshold is calculated as four times the Apdex T value. The default Apdex T value is 0.5 seconds.

To change the Apdex T value across all transactions of your application, use the environment variable NEWRELIC_APP_SERVER_APDEX_T. If you do not set this environment variable, New Relic uses the default.

To change the Apdex T for a specific transaction, create a key transaction.

For more help

Recommendations for learning more:

  • See the Docs site's landing page for APM agent SDK documentation.
  • Browse New Relic's Explorers Hub for community discussions about the APM agent SDK.
  • Use your preferred search engine to find other New Relic resources.