Module: MCP::Instrumentation
- Included in:
- Server
- Defined in:
- lib/mcp/instrumentation.rb
Instance Method Summary collapse
Instance Method Details
#add_instrumentation_data(**kwargs) ⇒ Object
22 23 24 |
# File 'lib/mcp/instrumentation.rb', line 22 def add_instrumentation_data(**kwargs) @instrumentation_data.merge!(kwargs) end |
#instrument_call(method, &block) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/mcp/instrumentation.rb', line 5 def instrument_call(method, &block) start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) begin @instrumentation_data = {} add_instrumentation_data(method:) result = yield block result ensure end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) add_instrumentation_data(duration: end_time - start_time) configuration.instrumentation_callback.call(@instrumentation_data) end end |