Class: Gruf::Profiler::Interceptor

Inherits:
Interceptors::ServerInterceptor
  • Object
show all
Defined in:
lib/gruf/profiler/interceptor.rb

Overview

Gruf hook that automatically loads rbtrace and memory profiler

Add to your gruf initializer:

require 'gruf/profiler'
Gruf.configure do |c|
  c.interceptors.use(Gruf::Profiler::Interceptor)
end

Instance Method Summary collapse

Instance Method Details

#callObject

Wraps the entire gruf call and provides memory reports



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/gruf/profiler/interceptor.rb', line 36

def call
  result = nil
  report = MemoryProfiler.report(**memory_profiler_options) do
    result = yield
  end
  if report
    profile(report)
  else
    log('Memory profiler did not return a report')
  end
  result
end