Class: Rack::Insight::Instrumentation::PackageDefinition
- Inherits:
-
Object
- Object
- Rack::Insight::Instrumentation::PackageDefinition
- Defined in:
- lib/rack/insight/instrumentation/package-definition.rb
Instance Attribute Summary collapse
-
#collector ⇒ Object
readonly
Returns the value of attribute collector.
Class Method Summary collapse
- .add_collector(collector) ⇒ Object
- .all_collectors ⇒ Object
- .clear_collectors ⇒ Object
- .probe(collector, &block) ⇒ Object
- .probes ⇒ Object
- .start ⇒ Object
Instance Method Summary collapse
- #get_class_probe(name) ⇒ Object
- #get_instance_probe(name) ⇒ Object
-
#initialize(collector) ⇒ PackageDefinition
constructor
A new instance of PackageDefinition.
- #instrument(name, &block) ⇒ Object
Constructor Details
#initialize(collector) ⇒ PackageDefinition
Returns a new instance of PackageDefinition.
46 47 48 |
# File 'lib/rack/insight/instrumentation/package-definition.rb', line 46 def initialize(collector) @collector = collector end |
Instance Attribute Details
#collector ⇒ Object (readonly)
Returns the value of attribute collector.
50 51 52 |
# File 'lib/rack/insight/instrumentation/package-definition.rb', line 50 def collector @collector end |
Class Method Details
.add_collector(collector) ⇒ Object
25 26 27 28 29 |
# File 'lib/rack/insight/instrumentation/package-definition.rb', line 25 def add_collector(collector) unless all_collectors.include?(collector) all_collectors << collector end end |
.all_collectors ⇒ Object
21 22 23 |
# File 'lib/rack/insight/instrumentation/package-definition.rb', line 21 def all_collectors @all_collectors ||= [] end |
.clear_collectors ⇒ Object
17 18 19 |
# File 'lib/rack/insight/instrumentation/package-definition.rb', line 17 def clear_collectors all_collectors.clear end |
.probe(collector, &block) ⇒ Object
31 32 33 34 35 |
# File 'lib/rack/insight/instrumentation/package-definition.rb', line 31 def probe(collector, &block) add_collector(collector) definer = self.new(collector) definer.instance_eval &block end |
.probes ⇒ Object
13 14 15 |
# File 'lib/rack/insight/instrumentation/package-definition.rb', line 13 def probes InstanceProbe.all_probes + ClassProbe.all_probes end |
.start ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/rack/insight/instrumentation/package-definition.rb', line 4 def start @started = begin probes.each do |probe| probe.fulfill_probe_orders end true end end |
Instance Method Details
#get_class_probe(name) ⇒ Object
38 39 40 |
# File 'lib/rack/insight/instrumentation/package-definition.rb', line 38 def get_class_probe(name) ClassProbe.probe_for(name) end |
#get_instance_probe(name) ⇒ Object
42 43 44 |
# File 'lib/rack/insight/instrumentation/package-definition.rb', line 42 def get_instance_probe(name) InstanceProbe.probe_for(name) end |
#instrument(name, &block) ⇒ Object
52 53 54 55 56 |
# File 'lib/rack/insight/instrumentation/package-definition.rb', line 52 def instrument(name, &block) definer = ProbeDefinition.new(self, name) definer.instance_eval(&block) unless block.nil? return definer end |