Add Dalli instrumentation to Skylight
This commit is contained in:
parent
37f2102513
commit
738cbb54d3
19
config.ru
19
config.ru
|
@ -32,12 +32,31 @@ end
|
||||||
|
|
||||||
if ENV['SKYLIGHT_APPLICATION']
|
if ENV['SKYLIGHT_APPLICATION']
|
||||||
require 'skylight'
|
require 'skylight'
|
||||||
|
require 'skylight/probes/net_http'
|
||||||
require 'logger'
|
require 'logger'
|
||||||
config = Skylight::Config.load(nil, ENV['RACK_ENV'], ENV)
|
config = Skylight::Config.load(nil, ENV['RACK_ENV'], ENV)
|
||||||
config['root'] = File.expand_path('..', __FILE__)
|
config['root'] = File.expand_path('..', __FILE__)
|
||||||
config['agent.sockfile_path'] = File.expand_path('../tmp', __FILE__)
|
config['agent.sockfile_path'] = File.expand_path('../tmp', __FILE__)
|
||||||
config.logger = Logger.new(STDOUT)
|
config.logger = Logger.new(STDOUT)
|
||||||
config.validate!
|
config.validate!
|
||||||
|
|
||||||
|
class DalliProbe
|
||||||
|
def install
|
||||||
|
%w[get get_multi set add incr decr delete replace append prepend].each do |method_name|
|
||||||
|
next unless Dalli::Client.method_defined?(method_name.to_sym)
|
||||||
|
Dalli::Client.class_eval <<-EOD
|
||||||
|
alias #{method_name}_without_sk #{method_name}
|
||||||
|
def #{method_name}(*args, &block)
|
||||||
|
Skylight.instrument(category: "api.memcache.#{method_name}", title: "Memcache #{method_name}") do
|
||||||
|
#{method_name}_without_sk(*args, &block)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
EOD
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Skylight::Probes.register("Dalli::Client", "dalli", DalliProbe.new)
|
||||||
|
|
||||||
Skylight.start!(config)
|
Skylight.start!(config)
|
||||||
|
|
||||||
use Skylight::Middleware
|
use Skylight::Middleware
|
||||||
|
|
Loading…
Reference in New Issue
Block a user