Sha256: 11df280852c3b7783fcb6476d59553acdfe1fa8d1b7263faf64f621468e1141e

Contents?: true

Size: 1.52 KB

Versions: 62

Compression:

Stored size: 1.52 KB

Contents

module CC
  module Analyzer
    class StatsdContainerListener < ContainerListener
      def initialize(statsd)
        @statsd = statsd
      end

      def started(engine, _details)
        increment(engine, "started")
      end

      def finished(engine, _details, result)
        timing(engine, "time", result.duration)
        increment(engine, "finished")

        if result.timed_out?
          timing(engine, "time", result.duration)
          increment(engine, "result.error")
          increment(engine, "result.error.timeout")
        elsif result.maximum_output_exceeded?
          increment(engine, "result.error")
          increment(engine, "result.error.output_exceeded")
        elsif result.exit_status.nonzero?
          increment(engine, "result.error")
        else
          increment(engine, "result.success")
        end
      end

      private

      attr_reader :statsd

      def increment(engine, metric)
        statsd.increment("engines.#{metric}")
        statsd.increment("engines.names.#{engine.name}.#{metric}")
        if engine.respond_to?(:channel) && engine.channel
          statsd.increment("engines.names.#{engine.name}.#{engine.channel}.#{metric}")
        end
      end

      def timing(engine, metric, ms)
        statsd.timing("engines.#{metric}", ms)
        statsd.timing("engines.names.#{engine.name}.#{metric}", ms)
        if engine.respond_to?(:channel) && engine.channel
          statsd.timing("engines.names.#{engine.name}.#{engine.channel}.#{metric}", ms)
        end
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 2 rubygems

Version Path
codeclimate-0.85.24 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-fede-0.85.54 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-fede-0.85.53 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-fede-0.85.52 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-fede-0.85.51 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-fede-0.85.50 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-fede-0.85.49 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-fede-0.85.48 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-fede-0.85.47 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-fede-0.85.46 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-fede-0.85.45 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-fede-0.85.44 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-fede-0.85.43 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-fede-0.85.42 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-fede-0.85.41 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-fede-0.85.40 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-fede-0.85.39 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-fede-0.85.38 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-fede-0.85.37 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-fede-0.85.36 lib/cc/analyzer/statsd_container_listener.rb