just redo all of it from scratch
This commit is contained in:
parent
0b49c3f711
commit
d80b13736e
1 changed files with 33 additions and 26 deletions
26
lib/mcp/shared/instrumentation.rb
Normal file
26
lib/mcp/shared/instrumentation.rb
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module MCP
|
||||
module Instrumentation
|
||||
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
|
||||
|
||||
def add_instrumentation_data(**kwargs)
|
||||
@instrumentation_data.merge!(kwargs)
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Reference in a new issue