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']
|
if ENV['SKYLIGHT_APPLICATION']
|
||||||
require 'skylight'
|
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
|
class DalliProbe
|
||||||
def install
|
def install
|
||||||
|
@ -81,10 +74,6 @@ if ENV['SKYLIGHT_APPLICATION']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Skylight::Probes.register("Redis", "redis", RedisProbe.new)
|
Skylight::Probes.register("Redis", "redis", RedisProbe.new)
|
||||||
|
|
||||||
Skylight.start!(config)
|
|
||||||
|
|
||||||
use Skylight::Middleware
|
|
||||||
end
|
end
|
||||||
|
|
||||||
use RackTimer
|
use RackTimer
|
||||||
|
|
|
@ -7,6 +7,10 @@ class Travis::Api::App
|
||||||
class Base < Sinatra::Base
|
class Base < Sinatra::Base
|
||||||
register Extensions::SmartConstants
|
register Extensions::SmartConstants
|
||||||
|
|
||||||
|
if ENV['SKYLIGHT_APPLICATION']
|
||||||
|
register :skylight
|
||||||
|
end
|
||||||
|
|
||||||
error NotImplementedError do
|
error NotImplementedError do
|
||||||
content_type :txt
|
content_type :txt
|
||||||
status 501
|
status 501
|
||||||
|
@ -38,7 +42,7 @@ class Travis::Api::App
|
||||||
disable :protection, :logging, :setup
|
disable :protection, :logging, :setup
|
||||||
enable :raise_errors
|
enable :raise_errors
|
||||||
# disable :dump_errors
|
# disable :dump_errors
|
||||||
register :subclass_tracker, :expose_pattern, :skylight
|
register :subclass_tracker, :expose_pattern
|
||||||
helpers :respond_with, :mime_types
|
helpers :respond_with, :mime_types
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,27 @@
|
||||||
|
require 'logger'
|
||||||
|
require 'skylight'
|
||||||
require 'travis/api/app'
|
require 'travis/api/app'
|
||||||
|
|
||||||
class Travis::Api::App
|
class Travis::Api::App
|
||||||
module Extensions
|
module Extensions
|
||||||
module Skylight
|
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, *)
|
def route(verb, path, *)
|
||||||
condition do
|
condition do
|
||||||
if ENV['SKYLIGHT_APPLICATION']
|
trace = ::Skylight::Instrumenter.instance.current_trace
|
||||||
trace = ::Skylight::Instrumenter.instance.current_trace
|
endpoint = settings.name.to_s.split("::", 5).last.gsub(/::/, "/").downcase
|
||||||
endpoint = settings.name.to_s.split("::", 5).last.gsub(/::/, "/").downcase
|
trace.endpoint = "#{verb} /#{endpoint}#{path}"
|
||||||
trace.endpoint = "#{verb} /#{endpoint}#{path}"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
super
|
super
|
||||||
|
|
Loading…
Reference in New Issue
Block a user