Committer: wisest-owl
LJSUP-11381: Create counters for monitoringU trunk/lib/TheSchwartz/Job.pm U trunk/lib/TheSchwartz.pm
Modified: trunk/lib/TheSchwartz/Job.pm =================================================================== --- trunk/lib/TheSchwartz/Job.pm 2010-10-18 14:37:35 UTC (rev 156) +++ trunk/lib/TheSchwartz/Job.pm 2012-02-27 13:48:22 UTC (rev 157) @@ -191,6 +191,13 @@ $job->did_something(1); $job->set_exit_status(0); $job->driver->remove($job); + + ## Counter "completed_task" for monitoring + my $func_name = $job->funcname; + $func_name =~ s/::/_/g; + LJ::run_hook ("update_counter", { + counter => "completed_$func_name", + }); } sub permanent_failure { @@ -239,6 +246,13 @@ $job->set_exit_status($exit_status || 1); $job->driver->remove($job); } + + ## Counter "failed_task" for monitoring + my $func_name = $job->funcname; + $func_name =~ s/::/_/g; + LJ::run_hook ("update_counter", { + counter => "failed_$func_name", + }); } sub replace_with { Modified: trunk/lib/TheSchwartz.pm =================================================================== --- trunk/lib/TheSchwartz.pm 2010-10-18 14:37:35 UTC (rev 156) +++ trunk/lib/TheSchwartz.pm 2012-02-27 13:48:22 UTC (rev 157) @@ -370,6 +370,13 @@ ## Now, insert the job. This also might fail. $driver->insert($job); + + ## Counter "new_task" for monitoring + my $func_name = $job->funcname; + $func_name =~ s/::/_/g; + LJ::run_hook ("update_counter", { + counter => "new_$func_name", + }); }; if ($@) { unless (OK_ERRORS->{ $driver->last_error || 0 }) {