Sha256: 12b363aaaee2ea4f66d9e189be1eb4f467b2bdf2b6656dc38faad1a72f2594bf

Contents?: true

Size: 1.24 KB

Versions: 11

Compression:

Stored size: 1.24 KB

Contents

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

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

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

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

      private

      attr_reader :statsd

      def increment(name, metric)
        statsd.increment("engines.#{metric}")
        statsd.increment("engines.names.#{name}.#{metric}")
      end

      def timing(name, metric, ms)
        statsd.timing("engines.#{metric}", ms)
        statsd.timing("engines.names.#{name}.#{metric}", ms)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
codeclimate-0.73.0 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.72.0 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.71.2 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.71.1 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.71.0 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.70.6 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.70.5 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.70.4 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.70.3 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.70.1 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.70.0 lib/cc/analyzer/statsd_container_listener.rb