Newrelic:忽略交易的特定部分

Newrelic: ignore specific part of transaction

对于某些服务,我们只想查看每个事务的几个部分 - 除了外部 Web 服务。

我找到了 newrelic_ignore_apdexnewrelic_ignore_transaction 方法 here。 但是调用此方法将忽略整个事务,而不仅仅是特定部分。

有没有办法完全忽略交易的一部分?

如果我了解你的需求,使用

可能更合适

newrelic_end_of_transaction ( ) 或 newrelic_end_transaction ( [忽略] ) 在某一点停止记录交易

连同 newrelic_start_transaction (appname [ license] ) 如果您稍后需要重新打开交易。

你在这里找到他们两个https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-api

引用自 NewRelic 文档

newrelic_end_of_transaction ( )

function newrelic_end_of_transaction (): null

Stop recording the web transaction immediately. Usually used when a page is done with all computation and is about to stream data (file download, audio or video streaming, etc.) and you don't want the time taken to stream to be counted as part of the transaction. This is especially relevant when the time taken to complete the operation is completely outside the bounds of your application. For example, a user on a very slow connection may take a very long time to download even small files, and you wouldn't want that download time to skew the real transaction time.

另一方面这里是启动函数的描述

newrelic_start_transaction (appname [, license] )

function newrelic_start_transaction (string $appname, string $license = ini_get('newrelic.license')): bool

If you have ended a transaction before your script terminates (perhaps due to it just having finished a task in a job queue manager) and you want to start a new transaction, use this call. This will perform the same operations that occur when the script was first started. Of the two arguments, only the application name is mandatory. However, if you are processing tasks for multiple accounts, you may also provide a license for the associated account. The license set for this API call will supersede all per-directory and global default licenses configured in INI files. This function will return true if the transaction was successfully started.

请注意 newrelic_end_transaction ( [ignore] ) 和 newrelic_end_of_transaction ( )

之间的一些区别

Despite being similar in name to newrelic_end_of_transaction above, this call serves a very different purpose. newrelic_end_of_transaction simply marks the end time of the transaction but takes no other action. The transaction is still only sent to the daemon when the PHP engine determines that the script is done executing and is shutting down. This function on the other hand, causes the current transaction to end immediately, and will ship all of the metrics gathered thus far to the daemon unless the ignore parameter is set to true. In effect this call simulates what would happen when PHP terminates the current transaction.

知道我做了很多引用,但文档非常明确,以至于我发现用不同的方式说同样的事情是没有用的。 希望这会有所帮助