Class: InstrumentAllTheThings::MethodInstrumentor
- Inherits:
-
Object
- Object
- InstrumentAllTheThings::MethodInstrumentor
- Defined in:
- lib/instrument_all_the_things/method_instrumentor.rb
Constant Summary collapse
- WRAPPERS =
{ 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, 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.
21 22 23 24 25 26 27 |
# File 'lib/instrument_all_the_things/method_instrumentor.rb', line 21 def initialize() self. = DEFAULT_OPTIONS.merge() build_instrumentor freeze end |
Instance Attribute Details
#instrumentor ⇒ Object
Returns the value of attribute instrumentor.
19 20 21 |
# File 'lib/instrument_all_the_things/method_instrumentor.rb', line 19 def instrumentor @instrumentor end |
#options ⇒ Object
Returns the value of attribute options.
19 20 21 |
# File 'lib/instrument_all_the_things/method_instrumentor.rb', line 19 def @options end |
Instance Method Details
#build_instrumentor ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/instrument_all_the_things/method_instrumentor.rb', line 29 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
39 40 41 |
# File 'lib/instrument_all_the_things/method_instrumentor.rb', line 39 def invoke(klass:, &blk) instrumentor.call(klass, blk) end |