skylight: refactor more into extension
This commit is contained in:
parent
e698e01f7c
commit
208a8248f7
11
config.ru
11
config.ru
|
@ -32,13 +32,6 @@ end
|
|||
|
||||
if ENV['SKYLIGHT_APPLICATION']
|
||||
require 'skylight'
|
||||
require 'skylight/probes/net_http'
|
||||
require 'logger'
|
||||
config = Skylight::Config.load(nil, ENV['RACK_ENV'], ENV)
|
||||
config['root'] = File.expand_path('..', __FILE__)
|
||||
config['agent.sockfile_path'] = File.expand_path('../tmp', __FILE__)
|
||||
config.logger = Logger.new(STDOUT)
|
||||
config.validate!
|
||||
|
||||
class DalliProbe
|
||||
def install
|
||||
|
@ -81,10 +74,6 @@ if ENV['SKYLIGHT_APPLICATION']
|
|||
end
|
||||
end
|
||||
Skylight::Probes.register("Redis", "redis", RedisProbe.new)
|
||||
|
||||
Skylight.start!(config)
|
||||
|
||||
use Skylight::Middleware
|
||||
end
|
||||
|
||||
use RackTimer
|
||||
|
|
|
@ -7,6 +7,10 @@ class Travis::Api::App
|
|||
class Base < Sinatra::Base
|
||||
register Extensions::SmartConstants
|
||||
|
||||
if ENV['SKYLIGHT_APPLICATION']
|
||||
register :skylight
|
||||
end
|
||||
|
||||
error NotImplementedError do
|
||||
content_type :txt
|
||||
status 501
|
||||
|
@ -38,7 +42,7 @@ class Travis::Api::App
|
|||
disable :protection, :logging, :setup
|
||||
enable :raise_errors
|
||||
# disable :dump_errors
|
||||
register :subclass_tracker, :expose_pattern, :skylight
|
||||
register :subclass_tracker, :expose_pattern
|
||||
helpers :respond_with, :mime_types
|
||||
end
|
||||
|
||||
|
|
|
@ -1,15 +1,27 @@
|
|||
require 'logger'
|
||||
require 'skylight'
|
||||
require 'travis/api/app'
|
||||
|
||||
class Travis::Api::App
|
||||
module Extensions
|
||||
module Skylight
|
||||
def self.registered(base)
|
||||
config = ::Skylight::Config.load(nil, ENV['RACK_ENV'], ENV)
|
||||
config['root'] = base.root
|
||||
config['agent.sockfile_path'] = File.join(config['root'], 'tmp')
|
||||
config.logger = Logger.new(STDOUT)
|
||||
config.validate!
|
||||
|
||||
::Skylight.start!(config)
|
||||
|
||||
base.use ::Skylight::Middleware
|
||||
end
|
||||
|
||||
def route(verb, path, *)
|
||||
condition do
|
||||
if ENV['SKYLIGHT_APPLICATION']
|
||||
trace = ::Skylight::Instrumenter.instance.current_trace
|
||||
endpoint = settings.name.to_s.split("::", 5).last.gsub(/::/, "/").downcase
|
||||
trace.endpoint = "#{verb} /#{endpoint}#{path}"
|
||||
end
|
||||
trace = ::Skylight::Instrumenter.instance.current_trace
|
||||
endpoint = settings.name.to_s.split("::", 5).last.gsub(/::/, "/").downcase
|
||||
trace.endpoint = "#{verb} /#{endpoint}#{path}"
|
||||
end
|
||||
|
||||
super
|
||||
|
|
Loading…
Reference in New Issue
Block a user