From 37f21025135aea4391274fb7b99cb3b0b0b3b28e Mon Sep 17 00:00:00 2001 From: Henrik Hodne Date: Wed, 9 Apr 2014 00:09:09 -0500 Subject: [PATCH] Add Skylight stuff --- Gemfile | 1 + Gemfile.lock | 3 +++ config.ru | 13 +++++++++++++ lib/travis/api/app/base.rb | 2 +- lib/travis/api/app/extensions/skylight.rb | 18 ++++++++++++++++++ tmp/.gitkeep | 0 6 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 lib/travis/api/app/extensions/skylight.rb create mode 100644 tmp/.gitkeep diff --git a/Gemfile b/Gemfile index 58bc4852..4cc2c1d3 100644 --- a/Gemfile +++ b/Gemfile @@ -20,6 +20,7 @@ gem 'bunny', '~> 0.8.0' gem 'dalli' gem 'pry' gem 'metriks', '0.9.9.5' +gem 'skylight' group :test do gem 'rspec', '~> 2.13' diff --git a/Gemfile.lock b/Gemfile.lock index 3dfced19..6050f13c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -251,6 +251,8 @@ GEM rack-test sinatra (~> 1.4.0) tilt (~> 1.3) + skylight (0.3.10) + activesupport (>= 3.0.0) slop (3.4.7) sprockets (2.2.2) hike (~> 1.2) @@ -299,6 +301,7 @@ DEPENDENCIES sentry-raven! sinatra sinatra-contrib + skylight travis-api! travis-core! travis-sidekiqs! diff --git a/config.ru b/config.ru index e0be66b1..3e624c3c 100644 --- a/config.ru +++ b/config.ru @@ -30,5 +30,18 @@ class RackTimer end end +if ENV['SKYLIGHT_APPLICATION'] + require 'skylight' + 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! + Skylight.start!(config) + + use Skylight::Middleware +end + use RackTimer run Travis::Api::App.new diff --git a/lib/travis/api/app/base.rb b/lib/travis/api/app/base.rb index 082be3ea..99f0518d 100644 --- a/lib/travis/api/app/base.rb +++ b/lib/travis/api/app/base.rb @@ -44,7 +44,7 @@ class Travis::Api::App disable :protection, :logging, :setup enable :raise_errors # disable :dump_errors - register :subclass_tracker, :expose_pattern + register :subclass_tracker, :expose_pattern, :skylight helpers :respond_with, :mime_types end diff --git a/lib/travis/api/app/extensions/skylight.rb b/lib/travis/api/app/extensions/skylight.rb new file mode 100644 index 00000000..1ba19304 --- /dev/null +++ b/lib/travis/api/app/extensions/skylight.rb @@ -0,0 +1,18 @@ +require 'travis/api/app' +require 'skylight' + +class Travis::Api::App + module Extensions + module Skylight + def route(verb, path, *) + condition do + trace = ::Skylight::Instrumenter.instance.current_trace + endpoint = settings.name.to_s.split("::", 5).last.gsub(/::/, "/").downcase + trace.endpoint = "#{verb} /#{endpoint}#{path}" + end + + super + end + end + end +end diff --git a/tmp/.gitkeep b/tmp/.gitkeep new file mode 100644 index 00000000..e69de29b