Class: InstrumentAllTheThings::MethodInstrumentor
- Inherits:
-
Object
- Object
- InstrumentAllTheThings::MethodInstrumentor
- Defined in:
- lib/instrument_all_the_things/method_instrumentor.rb
Constant Summary collapse
- WRAPPERS =
{ # Note that the order of these hash keys are applied top to bottom, with the first inserted key # being the inner most wrapper gc_stats: Instrumentors::GC_STATS_WRAPPER, error_logging: Instrumentors::ERROR_LOGGING_WRAPPER, execution_counts_and_timing: Instrumentors::EXECUTION_COUNT_AND_TIMING_WRAPPER, trace: Instrumentors::TRACE_WRAPPER, }.freeze
- DEFAULT_OPTIONS =
{ trace: true, gc_stats: false, error_logging: true, execution_counts_and_timing: false, }.freeze
Instance Attribute Summary collapse
-
#instrumentor ⇒ Object
Returns the value of attribute instrumentor.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #build_instrumentor ⇒ Object
-
#initialize(options) ⇒ MethodInstrumentor
constructor
A new instance of MethodInstrumentor.
- #invoke(klass:, &blk) ⇒ Object
Constructor Details
#initialize(options) ⇒ MethodInstrumentor
Returns a new instance of MethodInstrumentor.
25 26 27 28 29 30 31 |
# File 'lib/instrument_all_the_things/method_instrumentor.rb', line 25 def initialize() self. = DEFAULT_OPTIONS.merge() build_instrumentor freeze end |
Instance Attribute Details
#instrumentor ⇒ Object
Returns the value of attribute instrumentor.
23 24 25 |
# File 'lib/instrument_all_the_things/method_instrumentor.rb', line 23 def instrumentor @instrumentor end |
#options ⇒ Object
Returns the value of attribute options.
23 24 25 |
# File 'lib/instrument_all_the_things/method_instrumentor.rb', line 23 def @options end |
Instance Method Details
#build_instrumentor ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/instrument_all_the_things/method_instrumentor.rb', line 33 def build_instrumentor procs = WRAPPERS.collect do |type, builder| next unless [type] builder.call([type], [:context]) end.compact self.instrumentor = combine_procs(procs) end |
#invoke(klass:, &blk) ⇒ Object
43 44 45 |
# File 'lib/instrument_all_the_things/method_instrumentor.rb', line 43 def invoke(klass:, &blk) instrumentor.call(klass, blk) end |