Class: Upfluence::HTTP::Endpoint::Profiler

Inherits:
Object
  • Object
show all
Defined in:
lib/upfluence/http/endpoint/profiler.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Profiler

Returns a new instance of Profiler.



7
8
9
10
11
12
13
14
15
# File 'lib/upfluence/http/endpoint/profiler.rb', line 7

def initialize(opts = {})
  @interval = opts[:interval] || 50
  @mode = opts[:mode] || :cpu
  @mapping = Rack::URLMap.new(
    '/start' => lambda { |env|  start(env) },
    '/stop' => lambda { |env| stop(env) },
    '/profile' => lambda { |env| profile(env) }
  )
end

Instance Method Details

#call(env) ⇒ Object



17
18
19
# File 'lib/upfluence/http/endpoint/profiler.rb', line 17

def call(env)
  @mapping.call(env)
end