• /
  • ログイン
  • 無料アカウント

newrelic_end_transaction (PHP agent API)

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.

ヒント

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

Parameters

Parameter

Description

$ignore

boolean

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.

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
}

その他のヘルプ

さらに支援が必要な場合は、これらのサポートと学習リソースを確認してください:

問題を作成するこのページを編集する
Copyright © 2020 New Relic Inc.