---
title: Python agent attributes
source: https://docs.newrelic.com/docs/apm/agents/python-agent/attributes/python-agent-attributes
---

[Attributes](https://docs.newrelic.com/docs/features/agent-attributes) are key-value pairs containing information that determines the properties of an event or transaction. We enable users to customize exactly which attributes will be sent to each of these destinations:

-   [Transaction traces](https://docs.newrelic.com/docs/apm/transactions/transaction-traces/transaction-traces)
-   [Traced errors](https://docs.newrelic.com/docs/apm/applications-menu/events/viewing-apm-errors-error-traces)
-   [Transaction events](https://docs.newrelic.com/docs/insights/new-relic-insights/decorating-events/apm-default-attributes-insights)
-   [Page views](https://docs.newrelic.com/docs/insights/new-relic-insights/decorating-events/browser-default-attributes-insights)

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](https://docs.newrelic.com/docs/agents/python-agent/installation-configuration/upgrade-python-agent) to the [latest release](https://docs.newrelic.com/docs/release-notes/agent-release-notes/python-release-notes).

## Python agent web transaction attributes [#attributes]

The following lists the attributes that can be configured in the Python agent for [web transactions](https://docs.newrelic.com/docs/apm/transactions/intro-transactions/transactions-new-relic-apm). For more information, see [Python agent configuration: attributes](https://docs.newrelic.com/docs/python/python-agent-configuration#attributes).

**request.headers.accept**

The types as read from the HTTP Accept request header.

Defaults:

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

**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.host**

The name from the HTTP host 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.

> #### 💡 TIP
>
> 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 [#message_attributes]

The following sections list the attributes that can be configured in the Python agent for [message transactions](https://docs.newrelic.com/docs/agents/python-agent/supported-features/python-message-queues) started by incoming message brokers like RabbitMQ. For more information, see [Python agent configuration: attributes](https://docs.newrelic.com/docs/python/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 [#message_attributes]

The following sections list the attributes that can be configured in the Python agent for traces started by outgoing libraries, like [httplib, boto3, requests,](https://docs.newrelic.com/docs/agents/python-agent/getting-started/instrumented-python-packages#external-web-services) and so on, or when using the [external trace API](https://docs.newrelic.com/docs/agents/python-agent/python-agent-api/external-trace). For more information, see [Python agent configuration: attributes](https://docs.newrelic.com/docs/python/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 [#message_attributes]

The following sections list the attributes that can be configured in the Python agent for traces started by database libraries like [mysql, psycopg2, cx_Oracle,](https://docs.newrelic.com/docs/agents/python-agent/getting-started/instrumented-python-packages#sql-database-adapters) and so on, or when using the database trace API. For more information, see [Python agent configuration: attributes](https://docs.newrelic.com/docs/python/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 SQLl used in the query, as processed according to the [transaction_tracer.record_sql setting](https://docs.newrelic.com/docs/agents/python-agent/configuration/python-agent-configuration#txn-tracer-sql). Large queries are 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" is 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" is reported instead.)

    Defaults:

-   Span events: Enabled

**db.statement**

The SQL used in the query, as processed according to the [transaction_tracer.record_sql setting](https://docs.newrelic.com/docs/agents/python-agent/configuration/python-agent-configuration#txn-tracer-sql). Large queries are limited in size.

Excluded when:

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

    Defaults:

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

**db.operation**

The database operation that was performed by this span. Only to be included if db.statement is not applicable.

Excluded when:

-   The attribute db.statement is reported.

    Defaults:

-   Transaction segments: Enabled

-   Span events: Enabled

## Python agent datastore trace attributes [#message_attributes]

The following sections list the attributes that can be configured in the Python agent for traces started by datastore libraries like [redis, memcache, pymongo,](https://docs.newrelic.com/docs/agents/python-agent/getting-started/instrumented-python-packages#sql-database-adapters) and so on, or when using the [datastore trace API](https://docs.newrelic.com/docs/agents/python-agent/python-agent-api/datastore_trace). For more information, see [Python agent configuration: attributes](https://docs.newrelic.com/docs/python/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

## Python agent span attributes [#attributes]

The following sections list the attributes that can be configured in the Python agent for [span events](https://docs.newrelic.com/docs/apm/distributed-tracing/ui-data/span-event). For more information, see [Python agent configuration: attributes](https://docs.newrelic.com/docs/python/python-agent-configuration#attributes).

**error.class**

The class of exception, if one exists, that is recorded on the span event. Exception details can be recorded on spans with the [notice_error](https://docs.newrelic.com/docs/agents/python-agent/python-agent-api/noticeerror-python-agent-api/) API.

Defaults:

-   Span events: Enabled

**error.message**

The exception message, if one exists, that is recorded on the span event. Exception details can be recorded on spans with the [notice_error](https://docs.newrelic.com/docs/agents/python-agent/python-agent-api/noticeerror-python-agent-api/) API.

Defaults:

-   Span events: Enabled

## Add custom attributes [#adding_custom_attributes]

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

For full reference see, [Collecting custom attributes](https://docs.newrelic.com/docs/apm/other-features/attributes/collecting-custom-attributes#python-att).

Defaults:

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

> #### ⚠️ IMPORTANT
>
> Before creating custom attributes, review our list of [reserved terms](https://docs.newrelic.com/docs/insights/event-data-sources/custom-events/data-requirements-limits-custom-event-data/#reserved-words). Otherwise, unexpected results might occur.

## Add custom attributes to exceptions [#adding_error_attributes]

When using the `newrelic.agent.notice_error()` 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 [#upgrading]

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](https://docs.newrelic.com/docs/agents/python-agent/attributes/enabling-disabling-attributes-python#deprecated).
