Syntax
newrelic_background_job([bool $flag])
Manually specify that a transaction is a background job or a web transaction.
Requirements
Compatible with all agent versions.
Description
Tell the agent to treat this "web" transaction as a "non-web" transaction (the APM UI separates web and non-web transactions, for example in the Transactions page). Call as early as possible. This is most commonly used for cron jobs or other long-lived background tasks. However, this call is usually unnecessary since the agent usually detects whether a transaction is a web or non-web transaction automatically.
You can also reverse the functionality by setting the optional flag to false
, which marks a "non-web" transaction as a "web" transaction.
Parameters
Parameter | Description |
---|---|
boolean | Optional. Defaults to If If |
Examples
Mark transaction as a background job
function example() {
if (extension_loaded('newrelic')) { // Ensure PHP agent is available
newrelic_background_job();
}
...
}
Mark transaction as a web transaction
function example() {
if (extension_loaded('newrelic')) { // Ensure PHP agent is available
newrelic_background_job(false);
}
...
}
For more help
If you need more help, check out these support and learning resources:
- Browse the Explorers Hub to get help from the community and join in discussions.
- Find answers on our sites and learn how to use our support portal.
- Run New Relic Diagnostics, our troubleshooting tool for Linux, Windows, and macOS.
- Review New Relic's and and documentation.