Syntax
newrelic.agent.add_custom_parameter(key, value)
Adds a custom attribute to a transaction.
Description
This call records a custom attribute (a key/value pair attached to your transaction). (The call name is add_custom_parameter
because "custom attributes" were previously called "custom parameters.")
Attributes may be found in APM if the transaction is associated with an error or if a transaction trace is generated for that transaction. Attributes can also be found and queried in New Relic One.
重要
Before you create custom attributes, review our list of reserved terms used by NRQL.
Parameters
Parameter | Description |
---|---|
string | Required. The key name. Only the first 255 characters are retained. |
string, integer, float, boolean | Required. The string value to add to the current transaction. Only the first 255 characters are retained. |
Return values
Returns True
if attribute was added successfully.
Examples
Adding custom parameters to background task
An example of adding custom parameters to a background task:
@newrelic.agent.background_task()def send_request(): response = requests.post('http://URL_path', headers=headers, data=data) newrelic.agent.add_custom_parameter('url_path_status_code', response.status_code)
Using custom parameters to troubleshoot
You can also use custom parameters to troubleshoot performance issues. For example, you might see occasional slow response times from a pool of memcache instances, but you don't know what instance is causing the problem. You might add an attribute to the transaction indicating the server, like so:
# Set server_ip to be the current server processing the transaction
newrelic.agent.add_custom_parameter("memcache_query_frontend_lookup", server_ip)
その他のヘルプ
さらに支援が必要な場合は、これらのサポートと学習リソースを確認してください:
- Explorers Hubでは、コミュニティからのサポートを受けたり、ディスカッションに参加したりすることができます。
- 当社サイトで答えを見つけて、サポートポータルの使用方法を確認してください。
- Linux、Windows、およびmacOS向けトラブルシューティングツールであるNew Relic Diagnosticsを実行してください。
- New Relicの とandドキュメント をご確認ください。