The Go agent follows this order of precedence for configuration. If enabled, server-side configuration overrides all corresponding values in the newrelic.Config struct, even if the server-side values are left blank.
If server-side configuration is enabled with the Go agent, it overrides all corresponding values in the newrelic.Config struct, even if the server-side values are left blank.
Here are detailed descriptions of each configuration method:
Server-side configuration is available with Go agent versions 2.7.0 or higher. This allows you to configure certain settings in the UI. This applies your changes automatically to all agents even if they run across multiple hosts. Where available, this document includes the UI labels for server-side config under individual config options as the Server-side label.
You must still call newrelic.NewApplication() in your application process following the steps described in the in-process configuration. Configuration options set server-side will overwrite those set locally. Since not all configuration options are available server side, you may want to still update your newrelic.Config struct.
Caution
If server-side config is enabled, the agent ignores any value in the newrelic.Config struct that could be set in the UI. Even if the UI value is empty, the agent treats this as an empty value and does not use the newrelic.Config value.
You configure your Go agent from the local in process newrelic.Config struct. This struct can be accessed when calling newrelic.NewApplication().
Add the following in the main function or in an init block:
Update values on the newrelic.Config struct to configure your application using newrelic.ConfigOptions. These are functions that accept a pointer to the newrelic.Config struct. Add additional newrelic.ConfigOptions to further configure your application. For example, you can use one of the predefined options to do common configurations:
// add more specific configuration of the agent within a custom ConfigOption
config.HighSecurity =true
config.CrossApplicationTracer.Enabled =false
},
)
Change configuration settings
To make Go agent configuration changes, set the values in the newrelic.Config struct from within a custom newrelic.ConfigOption. For example, to turn New Relic monitoring off temporarily for testing purposes, change the Enabled value to false:
In this and the following examples, config represents your New Relic config struct, although you may have given it a different variable name when you installed the Go agent and initiated the configuration in your app.
Specifies your New Relic license key, used to associate your app's metrics with a New Relic account. The license and the app name are both set 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. Do not put a space before the semicolon itself. For example:
High security mode enforces certain security settings and prevents them from being overridden, so that the agent sends no sensitive data. High security mode does the following:
Turns SSL on
Turns off reporting of error message strings
Turns off reporting of custom events
This setting must match the corresponding account setting in the UI. For example:
Controls whether HTTPS or HTTP is used to send data to New Relic. The agent communicates with New Relic via HTTPS by default (which uses TLS protocol), and New Relic requires HTTPS for all traffic to APM and the New Relic REST API.
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.Attributes is a struct with three fields:
Enabled bool
Include []string
Exclude []string
Use TransactionEvents.Attributes.Enabled to turn attribute collection on or off for transaction events. Use Include and Exclude to include or exclude specific attributes.
An example of excluding an attribute slice named allAgentAttributeNames from transaction events:
This controls which HTTP response codes are ignored as errors.
Response codes that are greater than or equal to 100 and strictly less than 400 are ignored by default and never have to be specified when calling this function. Response codes 0, 5, and 404 are 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{
0,// gRPC OK
5,// gRPC NOT_FOUND
http.StatusNotFound,// 404
}
You can also add response codes as HTTPs, as http.StatusNotFound above.
Important
If used, server-side configuration will override any values set on the newrelic.Config struct. Therefore to ignore 404 when server-side configuration is enabled, you must include 404 in the configuration set in the UI.
To add HTTP response code 418 to the default ignore list, which includes 0, 5, and 404:
ErrorCollector.Attributes is a struct with three fields:
Enabled bool
Include []string
Exclude []string
Use ErrorCollector.Attributes.Enabled to turn attribute collection on or off for errors. Use Include and Exclude to include or exclude specific attributes.
An example of excluding an attribute slice named allAgentAttributeNames from errors:
TransactionTracer.Segments.Attributes is a struct with three fields:
Enabled bool
Include []string
Exclude []string
Use TransactionTracer.Segments.Attributes.Enabled to turn attribute collection on or off for transaction trace segments. Use Include and Exclude to include or exclude specific attributes.
An example of excluding an attribute slice named allSegmentAttributeNames from traces:
TransactionTracer.Attributes is a struct with three fields:
Enabled bool
Include []string
Exclude []string
Use TransactionTracer.Attributes.Enabled to turn attribute collection on or off for transaction traces. Use Include and Exclude to include or exclude specific attributes.
An example of excluding an attribute slice named allAgentAttributeNames from traces:
This enables collection of datastore instance metrics (such as the host and port) for some database drivers. These are reported on transaction traces and as part of slow query data.
When true, the agent will add cross application tracing headers in outbound requests, and scan incoming requests for cross application tracing headers.
Distributed tracing and cross application tracing cannot be used simultaneously. The default configuration for the Go agent disables distributed tracing and enables cross application tracing.
Distributed tracing configuration
Important
Enabling distributed tracing requires Go agent version 2.1.0 or higher, and it disables cross application tracing. It also has effects on other features. Before enabling, read the transition guide.
Distributed tracing lets you see the path that a request takes as it travels through a distributed system.
When distributed tracing is enabled, you can collect span events.
Standard tracing is on by default in Go agent versions 3.16.0 and higher. This means the agent will automatically add distributed tracing headers in outbound requests, and scan incoming requests for distributed tracing headers. To disable distributed tracing, set the value to false.
Set this to true to exclude the New Relic header that is attached to outbound requests, and instead only rely on W3C Trace Context Headers for distributed tracing. If this is false then both types of headers are used.
Span events configuration
Span events are reported for distributed tracing. Distributed tracing must be enabled to report span events. These settings control the collection of span events:
SpanEvents.Attributes is a struct with three fields:
Enabled bool
Include []string
Exclude []string
Use SpanEvents.Attributes.Enabled to enable or disable attribute collection for span events. Use Include and Exclude to include or exclude specific attributes.
An example of excluding an attribute slice named allSpanAttributeNames from traces:
To enable Infinite Tracing, enable distributed tracing (set config.DistributedTracer.Enabled = true on the newrelic.Config struct) and add the additional settings below. For an example, see Language agents: Configure distributed tracing.
If true, enables the collection of log events and logging metrics if these sub-feature configurations are also enabled. If false, no logging instrumentation features are enabled.
Configure ApplicationLogging by calling ConfigAppLogEnabled().
If true, the agent captures log records emitted by your application and forwards them to New Relic. ApplicationLogging.Enabled must also be true for this setting to take effect.
Enable log forwarding by calling ConfigAppLogForwardingEnabled().
If true, the agent captures metrics related to the log lines being sent up by your application. ApplicationLogging.Enabled must also be true for this setting to take effect.
Configure ApplicationLogging.Metrics.Enabled by calling ConfigAppLogMetricsEnabled().