Attributes are key-value pairs containing information for transaction events, error events, and traced errors. You can adjust the destinations of default attributes and create custom attributes for the attributes collected by New Relic's Go language agent, including:
- Error traces
- Transaction events
- Page views
For an extra level of monitoring detail, create custom attributes.
As of Go agent v3.0.0, this attribute has been marked deprecated and been renamed to
http.statusCode. The v3.x agent will continue to produce this attribute, but it will be removed in v4.0.0.
If you have Go agent v2.6.0 or higher, you can configure attributes on spans and segments. The Go agent receives the following default attributes from your app. These attributes are only found on span events and transaction trace segments. You can adjust these default settings and turn attributes on or off for certain destinations.
Use these options to change attribute destinations:
Add custom attributes by using this method in a transaction:
txn variable is the one instrumented for the Go transaction. For example:
txn.AddAttribute("product", "widget")txn.AddAttribute("price", 19.99)txn.AddAttribute("importantCustomer", true)
Default settings for custom attribute destinations:
- Error collector (traced errors): Enabled
- Transaction events: Enabled