Python agent attributes

Attributes are key-value pairs containing information that determines the properties of an event or transaction. New Relic enables users to customize exactly which attributes will be sent to each of these destinations:

These attribute settings apply to Python agent version 2.56.0.42 or higher. To take advantage of all available features, update your Python agent to the latest release.

Python agent web transaction attributes

The following lists the attributes that can be configured in the Python agent for web transactions. For more information, see Python agent configuration: attributes.

request.headers.contentLength

The incoming request size in bytes as read from the Content-Length request header.

Defaults:

  • Transaction traces: Enabled
  • Error collector (traced errors): Enabled
  • Transaction events: Enabled
  • Page views (browser monitoring): Unavailable
request.headers.contentType

The incoming request content-type as read from the Content-Type request header.

Defaults:

  • Transaction traces: Enabled
  • Error collector (traced errors): Enabled
  • Transaction events: Enabled
  • Page views (browser monitoring): Unavailable
request.headers.referer

The incoming request referer as read from the Referer request header.

Defaults:

  • Transaction traces: Enabled
  • Error collector (traced errors): Enabled
  • Transaction events: Enabled
  • Page views (browser monitoring): Unavailable
request.headers.userAgent

The incoming request user-agent as read from the User-Agent request header.

Defaults:

  • Transaction traces: Enabled
  • Error collector (traced errors): Enabled
  • Transaction events: Enabled
  • Page views (browser monitoring): Unavailable
request.method

The HTTP method of the incoming request.

Defaults:

  • Transaction traces: Enabled
  • Error collector (traced errors): Enabled
  • Transaction events: Enabled
  • Page views (browser monitoring): Unavailable
request.parameters.*

Parameters from the query string of the request URL.

The capture_params property has been deprecated. However, if set to true, it will enable request parameters for transaction traces and traced errors.

Defaults:

  • Transaction traces: Disabled
  • Error collector (traced errors): Disabled
  • Transaction events: Disabled
  • Page views (browser monitoring): Disabled
request.uri

The URI of the incoming request.

Defaults:

  • Transaction traces: Enabled
  • Error collector (traced errors): Enabled
  • Transaction events: Enabled
  • Page views (browser monitoring): Unavailable
response.headers.contentLength

Taken from the Content-Length response header, this specifies the size of the outgoing response in bytes.

Defaults:

  • Transaction traces: Enabled
  • Error collector (traced errors): Enabled
  • Transaction events: Enabled
  • Page views (browser monitoring): Unavailable
response.headers.contentType

Taken from the Content-Type response header, this specifies the content type of the outgoing response.

Defaults:

  • Transaction traces: Enabled
  • Error collector (traced errors): Enabled
  • Transaction events: Enabled
  • Page views (browser monitoring): Unavailable
response.status

The outgoing response status.

Defaults:

  • Transaction traces: Enabled
  • Error collector (traced errors): Enabled
  • Transaction events: Enabled
  • Page views (browser monitoring): Unavailable
thread.concurrency

A measure of "thread utilization," representing the number of threads handling concurrent requests.

Defaults:

  • Transaction traces: Enabled
  • Error collector (traced errors): Enabled
  • Transaction events: Disabled
  • Page views (browser monitoring): Unavailable
webfrontend.queue.seconds

Time (in seconds) spent in request queuing.

Defaults:

  • Transaction traces: Enabled
  • Error collector (traced errors): Enabled
  • Transaction events: Disabled
  • Page views (browser monitoring): Unavailable
wsgi.input.bytes

Number of bytes received in the WSGI input stream (file-like object.)

Defaults:

  • Transaction traces: Enabled
  • Error collector (traced errors): Enabled
  • Transaction events: Disabled
  • Page views (browser monitoring): Unavailable
wsgi.input.calls.read

Number of calls to read() by the WSGI server to handle request.

Defaults:

  • Transaction traces: Enabled
  • Error collector (traced errors): Enabled
  • Transaction events: Disabled
  • Page views (browser monitoring): Unavailable
wsgi.input.calls.readline

Number of calls to readline() by the WSGI server to handle request.

Defaults:

  • Transaction traces: Enabled
  • Error collector (traced errors): Enabled
  • Transaction events: Disabled
  • Page views (browser monitoring): Unavailable
wsgi.input.calls.readlines

Number of calls to readlines() by the WSGI server to handle request.

Defaults:

  • Transaction traces: Enabled
  • Error collector (traced errors): Enabled
  • Transaction events: Disabled
  • Page views (browser monitoring): Unavailable
wsgi.input.seconds

Time (in seconds) to read WSGI input stream.

Defaults:

  • Transaction traces: Enabled
  • Error collector (traced errors): Enabled
  • Transaction events: Disabled
  • Page views (browser monitoring): Unavailable
wsgi.output.bytes

Number of bytes sent in the WSGI output response.

Defaults:

  • Transaction traces: Enabled
  • Error collector (traced errors): Enabled
  • Transaction events: Disabled
  • Page views (browser monitoring): Unavailable
wsgi.output.calls.write

Number of calls to write() by the WSGI server to send the response.

Defaults:

  • Transaction traces: Enabled
  • Error collector (traced errors): Enabled
  • Transaction events: Disabled
  • Page views (browser monitoring): Unavailable
wsgi.output.calls.yield

Number of calls to yield by the WSGI server to send the response.

Defaults:

  • Transaction traces: Enabled
  • Error collector (traced errors): Enabled
  • Transaction events: Disabled
  • Page views (browser monitoring): Unavailable
wsgi.output.seconds

Time (in seconds) to send the WSGI response.

Defaults:

  • Transaction traces: Enabled
  • Error collector (traced errors): Enabled
  • Transaction events: Disabled
  • Page views (browser monitoring): Unavailable

Python agent message transaction attributes

The following table lists the attributes that can be configured in the Python agent for message transactions started by incoming message brokers like RabbitMQ. For more information, see Python agent configuration: attributes.

message.correlationId

The application-generated identifier used in RPC configurations.

Defaults:

  • Transaction traces: Disabled
  • Error collector (traced errors): Disabled
  • Transaction events: Disabled
message.exchangeType

The type of exchange this message was consumed from: direct, fanout, topic, or headers

Defaults:

  • Transaction traces: Disabled
  • Error collector (traced errors): Disabled
  • Transaction events: Disabled
message.headers.*

The headers of the incoming message.

Defaults:

  • Transaction traces: Disabled
  • Error collector (traced errors): Disabled
  • Transaction events: Disabled
message.queueName

The name of the Queue this message was consumed from.

Defaults:

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

The callback queue used in RPC configurations.

Defaults:

  • Transaction traces: Disabled
  • Error collector (traced errors): Disabled
  • Transaction events: Disabled
message.routingKey

The routing key of the incoming message.

Defaults:

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

Python agent external trace attributes

The following table lists the attributes that can be configured in the Python agent for traces started by outgoing libraries, like ​httplib, boto3, requests, etc, or when using the external trace API. For more information, see Python agent configuration: attributes.

http.url

The url of the outgoing call, stripped of any request parameters.

Excluded when:

  • A rule matching 'http.url' is present in the "transaction_segments.attributes.exclude" setting. (for segments)
  • A rule matching 'http.url' is present in the "span_events.attributes.exclude" configuration setting. (for spans)

Defaults:

  • Transaction segments: Enabled
  • Span events: Enabled

Python agent database trace attributes

The following table lists the attributes that can be configured in the Python agent for traces started by database libraries like ​mysql, psycopg2, cx_Oracle, etc, or when using the database trace API. For more information, see Python agent configuration: attributes.

db.instance

The name of the database used in the query.

Excluded when:

  • The "datastore_tracer.database_name_reporting.enabled" configuration setting is set to False.
  • If a rule matching 'db.instance' is present in the "transaction_segments.attributes.exclude" setting (for segments)
  • If a rule matching 'db.instance' is present in the "span_events.attributes.exclude" configuration setting. (for spans)

Defaults:

  • Transaction segments: Enabled
  • Span events: Enabled
host

The host used to connect to the database.

Excluded when:

  • The "datastore_tracer.instance_reporting.enabled configuration" setting is set to False.

Defaults:

  • Transaction segments: Enabled
port_path_or_id

The port, path, or id of the database.

Excluded when:

  • The "datastore_tracer.instance_reporting.enabled configuration" setting is set to False.

Defaults:

  • Transaction segments: Enabled
sql

The sql used in the query, as processed according to the transaction_tracer.record_sql setting. Large queries will be limited in size.

Excluded when:

  • The "transaction_tracer.record_sql setting" setting is set to "off."

Defaults:

  • Transaction segments: Enabled, reported as "obfuscated" SQL.
peer.hostname

The host used to connect to the database.

Excluded when:

  • The "datastore_tracer.instance_reporting.enabled configuration" setting is set to False. (Otherwise, "Unknown" will be reported instead.)

Defaults:

  • Span events: Enabled
peer.address

The host used to connect to the database, including the port or path information.

Excluded when:

  • The "datastore_tracer.instance_reporting.enabled configuration" setting is set to False. (Otherwise, "Unknown" will be reported instead.)

Defaults:

  • Span events: Enabled
db.statement

The sql used in the query, as processed according to the transaction_tracer.record_sql setting. Large queries will be limited in size.

Excluded when:

  • The "transaction_tracer.record_sql setting" setting is set to "off."

Defaults:

  • Span events: Enabled, reported as "obfuscated" SQL.

Python agent datastore trace attributes

The following table lists the attributes that can be configured in the Python agent for traces started by datastore libraries like ​redis, memcache, pymongo, etc, or when using the datastore trace API. For more information, see Python agent configuration: attributes.

db.instance

The name of the datastore instance used in the query.

Excluded when:

  • The "datastore_tracer.database_name_reporting.enabled" configuration setting is set to False.
  • If a rule matching 'db.instance' is present in the "transaction_segments.attributes.exclude" setting (for segments)
  • If a rule matching 'db.instance' is present in the "span_events.attributes.exclude" configuration setting. (for spans)

Defaults:

  • Transaction segments: Enabled
  • Span events: Enabled
host

The host used to connect to the datastore.

Excluded when:

  • The "datastore_tracer.instance_reporting.enabled configuration" setting is set to False.

Defaults:

  • Transaction segments: Enabled
port_path_or_id

The port, path, or id of the datastore.

Excluded when:

  • The "datastore_tracer.instance_reporting.enabled configuration" setting is set to False.

Defaults:

  • Transaction segments: Enabled
peer.hostname

The host used to connect to the datastore.

Excluded when:

  • The "datastore_tracer.instance_reporting.enabled configuration" setting is set to False. (Otherwise, "Unknown" will be reported instead.)

Defaults:

  • Span events: Enabled
peer.address

The host used to connect to the datastore, including the port, path, or id information.

Excluded when:

  • The "datastore_tracer.instance_reporting.enabled configuration" setting is set to False. (Otherwise, "Unknown" will be reported instead.)

Defaults:

  • Span events: Enabled

Add custom attributes

To capture additional custom attributes from your application, use newrelic.agent.add_custom_parameter().

For full reference see Collecting custom attributes.

Defaults:

  • Transaction traces: Enabled
  • Error collector (traced errors): Enabled
  • Transaction events: Enabled
  • Page views (browser monitoring): Disabled

Before creating custom attributes, review New Relic's list of reserved terms used by NRQL and Insights. Otherwise unexpected results may occur.

Add custom attributes to exceptions

When using the newrelic.agent.record_exception() API call, you can pass in a dictionary of params that will be recorded as attributes on the traced error.

Defaults:

  • Transaction traces: Unavailable
  • Error collector (traced errors): Enabled
  • Transaction events: Unavailable
  • Page views (browser monitoring): Unavailable

Upgrade your config file

Upgrade your newrelic.ini configuration file when you upgrade to Python agent 2.56.0.42 or higher. For more information about deprecated configuration settings, see Enabling and disabling attributes.

For more help

Additional documentation resources include:

Recommendations for learning more: