• /
  • EnglishEspañol日本語한국어Português
  • EntrarComeçar agora

newrelic_name_transaction (PHP agent API)

Syntax

newrelic_name_transaction(string $name)

Set custom name for current transaction.

Requirements

Compatible with all agent versions.

Must be called inside a transaction.

Description

Sets the name of the transaction to the specified name. This can be useful if you have implemented your own dispatching scheme and want to name transactions according to their purpose. Call this function as early as possible.

Importante

Do not use brackets [suffix] at the end of your transaction name. New Relic automatically strips brackets from the name. Instead, use parentheses (suffix) or other symbols if needed.

Unique values like URLs, Page Titles, Hex Values, Session IDs, and uniquely identifiable values should not be used in naming your transactions. Instead, add that data to the transaction as a custom parameter with the newrelic_add_custom_parameter() call.

Importante

Do not create more than 1000 unique transaction names (for example, avoid naming by URL if possible). This will make your charts less useful, and you may run into limits New Relic sets on the number of unique transaction names per account. It also can slow down the performance of your application.

Parameters

Parameter

Description

$name

string

Required. Name of the transaction.

Return values

Returns true if the transaction name was successfully changed. If false is returned, check the agent log for more information.

Examples

General transaction naming

You have /product/123 and /product/234. If you generate a separate transaction name for each, then New Relic will store separate information for these two transaction names. Instead, store the transaction as /product/*, or use something significant about the code itself to name the transaction, such as /Product/view:

function example() {
if (extension_loaded('newrelic')) { // Ensure PHP agent is available
newrelic_name_transaction("/Product/view/");
}
// ...
}

MVC framework naming

In MVC frameworks, one good option is to use the newrelic_name_transaction() call where your request is routed and name your transaction with a Controller/Action format.

Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.