• EnglishEspañol日本語한국어Português
  • Log inStart now

newrelic_end_transaction (PHP agent API)


newrelic_end_transaction([bool $ignore])

Stop instrumenting the current transaction immediately.


Agent version or higher.


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.


Compare newrelic_end_of_transaction(), which stops timing the transaction but continues to instrument it.






Optional. Defaults to false.

If false or omitted, data from the transaction is recorded by the daemon.

If true, data from the transaction is not recorded by the daemon.

Return values

Returns true if the transaction was successfully ended and data was sent to the New Relic daemon.


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
// this code is ignored
Copyright © 2024 New Relic Inc.

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