Go agent attributes

This document contains the names and details of the attributes collected by New Relic's Go language agent. You can adjust the destinations of default attributes and create custom attributes.

What are attributes?

In New Relic APM for Go, attributes are key-value pairs containing information for transaction events, error events, and traced errors.

New Relic lets you to customize which attributes will be sent to each of these destinations:

  • Error traces in New Relic APM
  • Transaction events in New Relic Insights
  • Page views in New Relic Insights

You can also create custom attributes for an extra level of monitoring detail.

Go agent attributes

The following table shows the default attributes collected by the Go agent and where they are sent by default. You can adjust these default settings and turn attributes on or off for certain destinations. For more about general agent information, see New Relic agent attributes.

request.headers.accept

The type as read from the HTTP request's Accept header, called with newrelic.AttributeRequestAccept

Default settings:

  • Transaction traces: Enabled
  • Error collector (traced errors): Enabled
  • Transaction events: Enabled

Example of excluding this attribute:

config.Attributes.Exclude = append(config.Attributes.Exclude, newrelic.AttributeRequestAccept)
request.headers.contentLength

The incoming request size in bytes as read from the Content-Length request header, called with newrelic.AttributeRequestContentLength.

Default settings:

  • Transaction traces: Enabled
  • Error collector (traced errors): Enabled
  • Transaction events: Enabled

Example of excluding this attribute:

config.Attributes.Exclude = append(config.Attributes.Exclude, newrelic.AttributeRequestContentLength)
request.headers.contentType

The incoming request content-type as read from the Content-Type request header, called with newrelic.AttributeRequestContentType.

Default settings:

  • Transaction traces: Enabled
  • Error collector (traced errors): Enabled
  • Transaction events: Enabled

Example of excluding this attribute:

config.Attributes.Exclude = append(config.Attributes.Exclude, newrelic.AttributeRequestContentType)
request.headers.host

The name from the HTTP host request header, called with newrelic.AttributeRequestHost.

Default settings:

  • Transaction traces: Enabled
  • Error collector (traced errors): Enabled
  • Transaction events: Enabled

Example of excluding this attribute:

config.Attributes.Exclude = append(config.Attributes.Exclude, newrelic.AttributeRequestHost)
request.headers.referer

The incoming request referer as read from the Referer request header, called with newrelic.AttributeRequestReferer.

Default settings:

  • Transaction traces: Enabled
  • Error collector (traced errors): Enabled
  • Transaction events: Disabled

Example of excluding this attribute:

config.Attributes.Exclude = append(config.Attributes.Exclude, newrelic.AttributeRequestReferer)
request.headers.User-Agent

The contents of the User-Agent HTTP header, called with newrelic.AttributeRequestUserAgent

Default settings:

  • Transaction traces: Enabled
  • Error collector (traced errors): Enabled
  • Transaction events: Disabled

Example of excluding this attribute:

config.Attributes.Exclude = append(config.Attributes.Exclude, newrelic.AttributeRequestUserAgent)
request.method

The HTTP method of the incoming request, called with newrelic.AttributeRequestMethod

Default settings:

  • Transaction traces: Enabled
  • Error collector (traced errors): Enabled
  • Transaction events: Enabled

Example of excluding this attribute:

config.Attributes.Exclude = append(config.Attributes.Exclude, newrelic.AttributeRequestMethod)
httpResponseCode

The response status code for a web request, called with newrelic.AttributeResponseCode

Default settings:

  • Transaction traces: Enabled
  • Error collector (traced errors): Enabled
  • Transaction events: Enabled

Example of excluding this attribute:

config.Attributes.Exclude = append(config.Attributes.Exclude, newrelic.AttributeResponseCode)
response.headers.contentLength

The outgoing response size in bytes as read from the Content-Length response header, called with newrelic.AttributeResponseContentLength.

Default settings:

  • Transaction traces: Enabled
  • Error collector (traced errors): Enabled
  • Transaction events: Enabled

Example of excluding this attribute:

config.Attributes.Exclude = append(config.Attributes.Exclude, newrelic.AttributeResponseContentLength)
response.headers.contentType

The outgoing response content-type as read from the Content-Type response header, called with newrelic.AttributeResponseContentType.

Default settings:

  • Transaction traces: Enabled
  • Error collector (traced errors): Enabled
  • Transaction events: Enabled

Example of excluding this attribute:

config.Attributes.Exclude = append(config.Attributes.Exclude, newrelic.AttributeResponseContentType)
host.displayName

The name of the server host under which the current script is executing, called with newrelic.AttributeHostDisplayName.

Default settings:

  • Transaction traces: Enabled
  • Error collector (traced errors): Enabled
  • Transaction events: Disabled

Example of excluding this attribute:

config.Attributes.Exclude = append(config.Attributes.Exclude, newrelic.AttributeHostDisplayName)

Change attribute destination

There are two ways to change attribute destinations. You can:

Turn destinations on/off

To open or close an entire destination to attributes, set the .Enabled flag to true or false.

For example, to turn off APM error collection, you would put this after the config:

config.ErrorCollector.Attributes.Enabled = false
Turn attributes on/off

To turn specific attributes on or off, use the .Include or .Exclude methods.

For example, to disable AttributeResponseCode, you would include this after the config:

config.Attributes.Exclude = append(config.Attributes.Exclude, newrelic.AttributeResponseCode)

Create custom attributes

Add custom attributes by using this method in a transaction:

txn.AddAttribute("key", "value")

txn is the variable assigned to the transaction, as described in Instrument Go transactions.

Here are some examples of custom attributes:

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

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.