Syntax
newrelic_start_transaction(string $appname[, string $license])
Starts a new transaction, usually after manually ending a transaction.
Requirements
Agent version 3.0.5.95 or higher.
Description
Start a new transaction manually. Usually used after manually ending a transaction with newrelic_end_transaction()
, for example when separating tasks in a job queue manager. When instrumenting this new transaction, the agent performs the same operations as when the script first started.
Parameters
Parameter | Description |
---|---|
string | Required. The application name to associate with data from this transaction. Uses the same format as While this option is required, you can read the app name from |
string | Optional. Defaults to the set in the New Relic agent's Provide a different if you want the transaction to report to a different New Relic account. If set, this license will supersede all per-directory and global default licenses configured in INI files. |
Return values
This function will return true
if the transaction was successfully started.
Examples
Stop a transaction, then start another
For task queue managers, you can use newrelic_end_transaction()
and newrelic_start_transaction()
together to manually separate transactions. This example uses ini_get
to read the application name from the config file.
function example() { // queuing logic if (extension_loaded('newrelic')) { // Ensure PHP agent is available newrelic_end_transaction(); // stop recording the current transaction newrelic_start_transaction(ini_get("newrelic.appname")); // start recording a new transaction } // more queuing logic}
Start a new transaction with a new license key
This example manually specifies the app name and the :
function example() { if (extension_loaded('newrelic')) { // Ensure PHP agent is available newrelic_start_transaction("App1", "01234567890abcde01234567890abcde01234567890"); } ...}