Go agent configuration

You can edit New Relic for Go configuration settings to control some aspects of New Relic monitoring. Here are some examples of config changes you can make:

  • Turn high-security mode on
  • Add custom labels for filtering and sorting in the UI
  • Turn off the collection of errors, transaction events, transaction traces, and custom Insights events

Change configuration settings

You can make Go agent configuration changes by setting the values in the newrelic.config struct, which is returned by the newrelic.NewConfig function.

For example: To turn New Relic monitoring off temporarily for testing purposes, you would change the Enabled value to false:

config.Enabled = false

In this and the following examples, config is used to represent your New Relic config struct, although you may have given it a different variable name. For more on how the config is initiated in your app, see Install New Relic for Go.

General configuration settings

License (REQUIRED)
Type String
Default (none)

Specifies your New Relic license key, used to associate your app's metrics with your New Relic account. The license and the app name are both set as part of the New Relic installation process.

AppName (REQUIRED)
Type String
Default (none)

This is the application name used to aggregate data in the New Relic UI. You set both the license and the app name as part of the New Relic installation process.

To report data to multiple apps at the same time, specify a list of names separated with a semicolon, like this:

config := newrelic.NewConfig("YOUR_APP_NAME;APP_GROUP_1;ALL_APPS", "YOUR_NEW_RELIC_LICENSE_KEY")

Do not put a space before the semicolon.

Enabled
Type Boolean
Default true

When true, the agent sends data from your app to the New Relic collector.

To turn off New Relic monitoring, set this to false. This can be useful for:

  • Installing New Relic in a development environment
  • Troubleshooting purposes

When Enabled is set to false:

  • The New Relic Go agent will not communicate with the New Relic server.
  • The agent will not spawn goroutines.
  • Using the license key is not required during installation

An example of setting Enabled to false:

config.Enabled = false
Labels
Type map[string]string
Default (none)

This is used to attach labels to your app. You can use labels to filter and sort your apps in the New Relic UI. You can also set labels in the UI.

Creating four label pairs

Here's an example of setting four labels:

config.Labels := map[string]string{
    "Env": "Dev",
    "Label2": "label2",
    "Label3": "label3",
    "Label4": "label4",
}
Logger
Type Interface
Default (none)

You can use the Logger interface to write log files to the location or logging system of your choice. For more information, see Go logging.

HighSecurity
Type Boolean
Default false

High security mode enforces certain security settings and prevents them from being overridden, so that the agent sends no sensitive data to New Relic. High security mode does the following:

  • Turns SSL on
  • Turns off collection of error message strings
  • Turns off collection of custom Insights events

This setting must match the corresponding account setting in the New Relic UI.

Here's an example of turning on high security mode:

config.HighSecurity = true
UseTLS
Type Boolean
Default true

This controls whether HTTPS or HTTP is used to send data to New Relic. When set to the default of true the agent sends data to New Relic using HTTPS (which uses TLS protocol). When set to false, the agent sends data using HTTP.

HostDisplayName
Type String
Default (none)

This sets the hostname displayed in the APM UI. This is an optional configuration.

Transport
Type String
Default (none)

This customizes http.Client communication with New Relic servers. This can be used to configure a proxy.

RuntimeSampler
Type Boolean
Default true

When true, the agent captures runtime statistics.

Custom Insights events configuration

You can create custom events and make them available for querying and analysis in New Relic Insights.

CustomInsightsEvents.Enabled
Type Boolean
Default true

When true, the agent sends custom events to New Relic Insights. This setting is overriden by HighSecurity, which disables custom Insights events.

To disable custom Insights events, place the following in your Go app after the New Relic config is initiated:

config.CustomInsightsEvents.Enabled = false

For more on creating custom Insights events, see Inserting custom events.

Transaction events configuration

Transaction events are used in collecting events corresponding to web requests and background tasks. Event data allows the New Relic UI to show additional information such as histograms and percentiles.

TransactionEvents.Enabled
Type Boolean
Default true

When true, the agent collects transaction events.

TransactionEvents.Attributes
Type Boolean
Default true

When false, the agent collects no attributes for transaction events. For more on controlling the attributes associated with transaction events, see Go attributes.

Error collector configuration

The following settings are used to configure the error collector:

ErrorCollector.Enabled
Type Boolean
Default true

When false, the agent collects no errors or error traces.

ErrorCollector.CaptureEvents
Type Boolean
Default true

When true, the agent collects error analytic events.

ErrorCollector.IgnoreStatusCodes
Type Integer
Default Error codes 399 and below, and 404, are ignored.

This controls which HTTP response codes are ignored as errors.

Response codes 399 and below are ignored by default and never have to be specified when calling this function. 404 is included on the list by default, but must be specified when adding to the ignore list.

This function's default form is:

    config.ErrorCollector.IgnoreStatusCodes = []int{
        http.StatusNotFound, // 404
    }	

You can also add response codes as HTTPs, as http.StatusNotFound is above.

Example of ignoring error code

To add HTTP response code 418 to the default ignore list, which includes 404:

config.ErrorCollector.IgnoreStatusCodes = [404,418]
ErrorCollector.Attributes
Type Boolean
Default true

When false, the agent does not send attributes with errors.

Transaction tracer configuration

Here are settings for changing transaction tracer configuration. For more information about transaction traces, see Transaction traces.

TransactionTracer.Enabled
Type Boolean
Default true

When true, the agent collects transaction traces (detailed information about slow transactions).

TransactionTracer.Threshold.IsApdexFailing
Type Boolean
Default true

Controls whether the transaction trace threshold is based on Apdex. If true, then the trace threshold is four times the Apdex threshold. If false, the agent uses Threshold.Duration as the transaction trace threshold.

TransactionTracer.Threshold.Duration
Type time.Millisecond
Default 500

If Threshold.IsApdexFailing is set to false, the agent uses this duration as the transaction trace threshold.

TransactionTracer.SegmentThreshold
Type time.Millisecond
Default 2

This is the threshold at which segments will be added to the trace.

TransactionTracer.StackTraceThreshold
Type time.Millisecond
Default 500

This is the threshold at which segments will be given a stack trace in the transaction trace.

Lowering this setting may drastically increase agent overhead.

TransactionTracer.Attributes
Type Boolean
Default true

If false, then no attributes will be sent with traces.

For more help

Additional documentation resources include:

Join the discussion about Go monitoring in the New Relic Online Technical Community! The Technical Community is a public platform to discuss and troubleshoot your New Relic toolset.

If you need additional help, get support at support.newrelic.com.