diff --git a/.gitignore b/.gitignore index 0c23bcbb..ee2d0102 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ vendor config/skylight.yml .coverage *.env +tmp diff --git a/Gemfile b/Gemfile index 8aa43451..e85cdaef 100644 --- a/Gemfile +++ b/Gemfile @@ -30,6 +30,7 @@ gem 'metriks-librato_metrics', github: 'eric/metriks-librato_metrics' gem 'micro_migrations' gem 'simplecov' gem 'skylight', '~> 0.6.0.beta.1' +gem 'stackprof' group :test do gem 'rspec', '~> 2.13' diff --git a/Gemfile.lock b/Gemfile.lock index b81eb7bf..826aa583 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -305,6 +305,7 @@ GEM multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) + stackprof (0.2.7) thin (1.6.3) daemons (~> 1.0, >= 1.0.9) eventmachine (~> 1.0) @@ -364,6 +365,7 @@ DEPENDENCIES sinatra sinatra-contrib skylight (~> 0.6.0.beta.1) + stackprof travis-api! travis-config (~> 0.1.0) travis-core! diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index f9690614..42c19182 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -79,6 +79,13 @@ module Travis::Api def initialize @app = Rack::Builder.app do + + if ENV['STACKPROF'] + require 'stackprof' + puts "Setting up stack profiling." + use StackProf::Middleware, enabled: true, save_every: 1, mode: :object + end + extend StackInstrumentation use Travis::Api::App::Middleware::Skylight use(Rack::Config) { |env| env['metriks.request.start'] ||= Time.now.utc }