Symphony::

Metrics

module

Metrics for Symphony Tasks.

Attributes

job_counter[R]

The job counter metric

job_timer[R]

The job timer metric

metriks_registry[R]

The Metriks::Registry that tracks all metrics for this job

Public Class Methods

anchor
new( * )

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

Public Instance Methods

anchor
restart()

Reset metrics on restart.

# File lib/symphony/metrics.rb, line 69
def restart
        self.metriks_registry.clear
        super
end
anchor
start()

Set up metrics on startup.

# File lib/symphony/metrics.rb, line 60
def start
        @log_reporter.start
        @proc_reporter.start

        super
end
anchor
work( payload, metadata )

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