The job counter metric
The job timer metric
The Metriks::Registry that tracks all metrics for this job
Set up metrics and reporters on creation.
# File lib/symphony/metrics.rb, line 19
def initialize( * )
super
@metriks_registry = Metriks::Registry.new
@job_timer = @metriks_registry.timer( 'job.duration' )
@job_counter = @metriks_registry.meter( 'job.count' )
@rusage_gauge = @metriks_registry.gauge('job.rusage') { Process.rusage.to_h }
@log_reporter = Metriks::Reporter::Logger.new(
logger: Loggability[ Symphony ],
registry: @metriks_registry,
prefix: self.class.name )
@proc_reporter = Metriks::Reporter::ProcTitle.new(
prefix: self.procname,
registry: @metriks_registry,
on_error: lambda {|ex| self.log.error(ex) } )
@proc_reporter.add( 'jobs' ) do
@job_counter.count
end
@proc_reporter.add( 'jobs', '/sec' ) do
@job_counter.one_minute_rate
end
end
Reset metrics on restart.
# File lib/symphony/metrics.rb, line 69
def restart
self.metriks_registry.clear
super
end
Set up metrics on startup.
# File lib/symphony/metrics.rb, line 60
def start
@log_reporter.start
@proc_reporter.start
super
end
Add metrics to the task's work block.
# File lib/symphony/metrics.rb, line 76
def work( payload, metadata )
self.job_counter.mark
self.job_timer.time do
super
end
end