Sha256: 9ea97a0f95ba978a93c3787cbf0e0ac88a5c2a597b1ea59897b19b61a3898017

Contents?: true

Size: 1 KB

Versions: 152

Compression:

Stored size: 1 KB

Contents

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

      def started(_data)
        increment("started")
      end

      def timed_out(data)
        timing("time", data.duration)
        increment("result.error")
        increment("result.error.timeout")
      end

      def finished(data)
        timing("time", data.duration)
        increment("finished")

        if data.status.success?
          increment("result.success")
        else
          increment("result.error")
        end
      end

      private

      attr_reader :engine_name, :statsd

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

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

Version data entries

152 entries across 152 versions & 1 rubygems

Version Path
codeclimate-0.6.1 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.6.0 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.5.0 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.4.4 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.4.3 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.4.1 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.4.0 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.3.2 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.3.1 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.3.0 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.2.12 lib/cc/analyzer/statsd_container_listener.rb
codeclimate-0.2.11 lib/cc/analyzer/statsd_container_listener.rb