Sha256: 63af16828e6b11e47175893803ac989174e5e2f508ca7090dfb8e850b3727c81

Contents?: true

Size: 1.22 KB

Versions: 34

Compression:

Stored size: 1.22 KB

Contents

module Rack::Insight::Instrumentation
  class PackageDefinition
    class << self
      def start
        @started = begin
                     probes.each do |probe|
                       probe.fulfill_probe_orders
                     end
                     true
                   end
      end

      def probes
        InstanceProbe.all_probes + ClassProbe.all_probes
      end

      def clear_collectors
        all_collectors.clear
      end

      def all_collectors
        @all_collectors ||= []
      end

      def add_collector(collector)
        unless all_collectors.include?(collector)
          all_collectors << collector
        end
      end

      def probe(collector, &block)
        add_collector(collector)
        definer = self.new(collector)
        definer.instance_eval &block
      end
    end

    def get_class_probe(name)
      ClassProbe.probe_for(name)
    end

    def get_instance_probe(name)
      InstanceProbe.probe_for(name)
    end

    def initialize(collector)
      @collector = collector
    end

    attr_reader :collector

    def instrument(name, &block)
      definer = ProbeDefinition.new(self, name)
      definer.instance_eval(&block) unless block.nil?
      return definer
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
rack-insight-0.6.4 lib/rack/insight/instrumentation/package-definition.rb
rack-insight-0.6.3 lib/rack/insight/instrumentation/package-definition.rb
rack-insight-0.6.2 lib/rack/insight/instrumentation/package-definition.rb
rack-insight-0.5.30 lib/rack/insight/instrumentation/package-definition.rb
rack-insight-0.5.29 lib/rack/insight/instrumentation/package-definition.rb
rack-insight-0.5.28 lib/rack/insight/instrumentation/package-definition.rb
rack-insight-0.5.27 lib/rack/insight/instrumentation/package-definition.rb
rack-insight-0.5.26 lib/rack/insight/instrumentation/package-definition.rb
rack-insight-0.5.25 lib/rack/insight/instrumentation/package-definition.rb
rack-insight-0.5.24 lib/rack/insight/instrumentation/package-definition.rb
rack-insight-0.5.23 lib/rack/insight/instrumentation/package-definition.rb
rack-insight-0.5.22 lib/rack/insight/instrumentation/package-definition.rb
rack-insight-0.5.21 lib/rack/insight/instrumentation/package-definition.rb
rack-insight-0.5.20 lib/rack/insight/instrumentation/package-definition.rb
rack-insight-0.5.19 lib/rack/insight/instrumentation/package-definition.rb
rack-insight-0.5.18 lib/rack/insight/instrumentation/package-definition.rb
rack-insight-0.5.17 lib/rack/insight/instrumentation/package-definition.rb
rack-insight-0.5.16 lib/rack/insight/instrumentation/package-definition.rb
rack-insight-0.5.15 lib/rack/insight/instrumentation/package-definition.rb
rack-insight-0.5.14 lib/rack/insight/instrumentation/package-definition.rb