-
Notifications
You must be signed in to change notification settings - Fork 763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Relic transaction naming support for Jobs? #224
Comments
Have your jobs call |
@danhunsaker thanks for the suggestions.. doing some R&D on this today. Do you think new Relic treats a fork of a process as a new transaction that begins and ends when the forked process (Job) ends? My fear is that it will treat the whole worker queue, polling and execution as one thick transaction. So I think besides setting a name for the transaction, I will also explicitly need to call
|
@danhunsaker setting the name of the transaction in the setup() { .. } section of the Job does make it a separate transaction in the New Relic dashboard, but it looks like it treats the whole worker as one transaction and not each of its individual jobs... I tried using newrelic_end_transaction() in the tearDown block, but its somehow not working for me.. |
You'll probably need to end the current transaction and start a new one in the The recommended usage in the NewRelic docs is for a worker that doesn't fork to run jobs. We need to do things a bit differently when forking is used, since the job process is a complete duplicate of the worker process when it starts, down to variable references and connections to external data sources. Telling NewRelic "I'm not the worker anymore; start a new transaction" decouples the job process from the worker so stats are passed per job correctly. |
@danhunsaker Ok, sounds logical. Trying this out, starting the transaction and naming it in setup() and |
@danhunsaker hmm.. still no luck. It appears as a separate transaction, but still its execution time seems to be that of the worker... goes into hundreds of seconds! I was looking at this custom boostrap file by @ruudk https://gist.github.com/ruudk/a28319b83cb8a08fd979 where he seems to be implementing new relic too.. but from what I read, he's setting a new transaction name to every worker (and not every job that's processed). What help would that be? |
It would let you tell apart which worker is doing which jobs, for one. Especially useful if each worker has a dedicated queue. You're missing a step in your |
@danhunsaker Got you, trying this now: in setUp()
in tearDown()
Shipped this onto servers. Will let you know the results in a bit. |
@danhunsaker unfortunately, this doesn't work at all.. in fact now, no transaction appears in new relic itself. I've also raised a ticket with New Relic for support, but I doubt they'll be able to wrap their mind around the PHP version of resque. |
That's odd. That should work perfectly. I wonder what's causing issues there... Probably best to roll back to the previous approach until NewRelic can take a look - at least that way you get some metrics, even if they are a bit misleading. NewRelic is actually pretty good at working these things out, and the HOWITWORKS.md I wrote should help them figure it out faster. The important bit is that Resque forks for each job, and the NewRelic extension may not understand that. Which will mean adding support for process forking in a future version of the extension (probably in the form of a function for reconnecting to the NewRelic daemon, which you'd call about the same place you reconnect to databases and so forth). If nothing else, we've found a documentation bug. 😄 |
@danhunsaker I have started a dialogue with New Relic's technical support. I've also linked them to our conversation file and the HOWITWORKS.md Just to be absolutely sure, this (pasted below) is what my Job class looks like right now.. (striped down for verbosity sake). Do you mind taking a quick look and confirming I'm doing exactly what we discussed. <?php
use BCC\ResqueBundle\ContainerAwareJob;
class MyJob extends ContainerAwareJob
{
public function setUp()
{
// my initialization code
\newrelic_end_of_transaction();
\newrelic_start_transaction("my-app");
\newrelic_name_transaction($transactionName);
}
public function run($args)
{
// my execution logic here
}
/**
* {@inheritDoc}
*/
public function tearDown()
{
\newrelic_end_of_transaction();
parent::tearDown();
}
} |
Official reply from New Relic's team
|
Yeah, about what I expected would be the response. Hopefully that changes in a later version. Your code looks good, by the way. I don't use Symfony myself, so the BCC Bundle's use of |
@danhunsaker ye, unfortunate. Will postback here if New Relic ever brings support for this feature.. but now monitoring the performance of which Job is taking long looks like a challenge to me. Just to put your workable solution/opinion on record and as a point of reference in this thread, if New Relic transaction can't work per job, what do you think is your suggestion for the next best way of transaction tracing. in the setup = create a Or will this strategy be useless too unless I use one dedicated queue per Job type? Thanks for the pointers so far. |
I haven't tested any of these configurations, so I can't say for sure, but that seems like a decent place to start. Something else you might do is You might also look into the |
@epicwhale very curious about where you ended up with this! |
@rrhyne No where. New Relic officially confirmed that this wont work as expected as pcntl_fork is not supported by New Relic's PHP Agent. If you are a New Relic customer, you should make a feature request in their support desk too, just in case they decide to hurry this up. |
I was looking for pointers / support on how can each Job be reported as a separate New Relic transaction.
Right now in my New Relic, I see the
bin/resque
as one thick transaction with no further clarity on which job is taking how long..Would like your thoughts on better integration with New Relic?
The text was updated successfully, but these errors were encountered: