dev-master
9999999-dev https://github.com/tomschlick/php-resque-statsdSubmit metrics for your php-resque jobs into StatsD/Graphite
The Requires
- php >=5.3.0
- chrisboulton/php-resque *
job statsd graphite resque php-resque udp
Wallogit.com
2017 © Pedro Peláez
Submit metrics for your php-resque jobs into StatsD/Graphite
php-resque-statsd implements StatsD metric tracking into php-resque., (*1)
For each job picked up by php-resque, numerous metrics will be submitted to StatsD, including counters to track the number of jobs executed, and timers to track how much time php-resque workers spend working., (*2)
php-resque-statsd also includes support for tracking metrics for jobs scheduled with php-resque-scheduler. The appropriate listeners to track scheduled jobs are automatically registered, so no extra work is required on your behalf., (*3)
php-resque-statsd exists as a single class (lib/ResqueStatsd.php), which has
no additional dependencies beyond php-resque itself., (*4)
To start tracking your jobs with StatsD, all you need to do is include
ResqueStatsd.php in your project., (*5)
If you're starting php-resque with the resque.php script supplied with
php-resque, all that is
required is a modification to the bootstrap file you supply to php-resque via
the APP_INCLUDE environment variable:, (*6)
require_once '/path/to/ResqueStatsd.php';
php-resque-scheduler will automatically check for the following environment variables if they exist and use them when connecting to StatsD:, (*7)
STATSD_HOST / STATSD_PORT
GRAPHITE_HOSTTo ease integration with existing setups, if either STATSD_HOST or
GRAPHITE_HOST include a single colon and then one or more numbers, this will
be interpretted as a HOST:PORT combination and both the host and port will be
set accordingly., (*8)
If you don't use environment variables in your project, you can still tell php-resque-statsd where StatsD is located:, (*9)
$host = '127.0.0.1'; $port = 8579; require_once '/path/to/ResqueStatsd.php'; Resque_Statsd::setServer($host, $port);
php-resque-statsd prefixes all metrics it generates with resque. You can
override this behavior if desired:, (*10)
require_once '/path/to/ResqueStatsd.php';
Resque_Statsd::setPrefix('resque.production');
The metrics below are tracked for each queue, instead of each unique job:, (*11)
stats.resque.queue.QUEUE_NAME.enqueued Counter of the number of jobs enqueued in this queue, (*12)
stats.resque.queue.QUEUE_NAME.finished Counter of the number of jobs successfully processed in this queue, (*13)
stats.resque.queue.QUEUE_NAME.failed Counter of the number of jobs that failed in this queue, (*14)
stats.timers.queue.QUEUE_NAME.processed Timer for jobs processed in this queue, (*15)
stats.resque.queue.QUEUE_NAME.scheduled If using php-resque-scheduler, number of jobs scheduled for future execution in this queue, (*16)
For example, for all jobs executed in the queue transcode, the following StatsD
metrics will be created:, (*17)
Metrics are also tracked on a job level:, (*18)
stats.resque.job.JOB_CLASS.enqueued Counter for the number of times this job has been enqueued, (*19)
stats.resque.job.JOB_CLASS.finished Counter for the number of times this job has been successfully processed, (*20)
stats.resque.job.JOB_CLASS.failed Counter for the number of times this job has failed, (*21)
stats.timers.job.JOB_CLASS.processed Timer for the amount of time spent processing this job, (*22)
stats.resque.job.JOB_CLASS.scheduled If using php-resque-scheduler, number of of times this job has been scheduled for future execution, (*23)
For example, a job named Job_SendEmail the following metrics will be created:, (*24)
Submit metrics for your php-resque jobs into StatsD/Graphite
job statsd graphite resque php-resque udp