Syntax
newrelic_end_transaction([bool $ignore])
Stop instrumenting the current transaction immediately.
Requirements
Agent version 3.0.5.95 or higher.
Description
Stop instrumenting the current transaction immediately, and send the data to the daemon. This call simulates what the agent normally does when PHP terminates the current transaction. The most common use for this call is to improve instrumentation of command line scripts that handle job queue processing. Call this method at the end of a particular job, and then call newrelic_start_transaction()
when a new task is pulled off the queue.
Normally, when you end a transaction you want the agent to record the associated data. However, you can also discard the data by setting $ignore
to true
.
Tip
Compare newrelic_end_of_transaction()
, which stops timing the transaction but continues to instrument it.
Parameters
Parameter | Description |
---|---|
boolean | Optional. Defaults to If If |
Return values
Returns true
if the transaction was successfully ended and data was sent to the New Relic daemon.
Examples
Stop a transaction, then start another
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}
Stop instrumenting entirely
function example() { // this code is instrumented if (extension_loaded('newrelic')) { // Ensure PHP agent is available newrelic_end_transaction(); } // this code is ignored}