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.9 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.85.8 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.85.7 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.85.6 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.85.5 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.85.4 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.85.3 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.85.2 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.85.1 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.85.0 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.84.0 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.83.0 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.82.0 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.81.0 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.80.0 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.79.0 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.78.1 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.78.0 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.77.0 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.76.0 lib/cc/analyzer/statsd_container_listener.rb