Class: Rackprof::RequestNotify

Inherits:
Object
  • Object
show all
Includes:
Observable, Singleton
Defined in:
lib/rackprof/request_notify.rb

Instance Method Summary collapse

Instance Method Details

#notify(&block) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rackprof/request_notify.rb', line 8

def notify(&block)
  ret = []

  profile = StackProf.run(mode: :cpu) do
    ret = block.call
  end

  if count_observers > 0
    io = StringIO.new
    #StackProf::Report.new(profile).print_graphviz(nil, io)
    StackProf::Report.new(profile).print_text(false, 20, io)

    changed
    notify_observers(io.string)
  end

  ret
end