Permalink
Browse files

Merge pull request #504 from travis-ci/metriks-lograge

Fixes for logging and metriks
  • Loading branch information...
joshk committed Apr 16, 2012
2 parents ebb80b1 + e547fd0 commit b3299d94cfbf04670345baf821f34fa9d4988ba2
Showing with 18 additions and 80 deletions.
  1. +1 −1 Gemfile
  2. +13 −13 Gemfile.lock
  3. +1 −9 config/environments/production.rb
  4. +0 −46 lib/logging.rb
  5. +3 −11 lib/notifications.rb
View
@@ -26,8 +26,8 @@ gem 'pg', '~> 0.13.2'
gem 'backports', '~> 2.3.0'
gem 'gh', git: 'git://github.com/rkh/gh'
gem 'hubble', git: 'git://github.com/mattmatt/hubble'
-gem 'metriks', git: 'git://github.com/mattmatt/metriks', ref: 'source'
gem 'newrelic_rpm', '~> 3.3.0'
+gem 'lograge', '~> 0.0.4'
# i18n
gem "http_accept_language", "~> 1.0.2"
View
@@ -5,15 +5,6 @@ GIT
hubble (0.1.2)
json (~> 1.6.5)
-GIT
- remote: git://github.com/mattmatt/metriks
- revision: 23482212ec6676bfde20dae70760f80778bf6e77
- ref: source
- specs:
- metriks (0.8.0)
- atomic (~> 1.0)
- hitimes (~> 1.1)
-
GIT
remote: git://github.com/pivotal/jasmine-gem
revision: c72e8d248d49a1ebe53f31a09ac511194ad4edf1
@@ -43,23 +34,24 @@ GIT
GIT
remote: git://github.com/rkh/gh
- revision: d6d31683c13d93c26358ef842421d70623ded34f
+ revision: d69ae314db9d844ec71e112367eb3cd133d56073
specs:
- gh (0.2.2)
+ gh (0.3.0)
backports (~> 2.3)
faraday (~> 0.7)
multi_json (~> 1.0)
GIT
remote: git://github.com/travis-ci/travis-core
- revision: 2803e416fcc73e9bdd39f764eb446c2f118c8259
+ revision: 6e17daaa5b2c90da71bbbc2e69f596307e455f08
specs:
travis-core (0.0.1)
actionmailer (~> 3.2.3)
activerecord (~> 3.2.3)
data_migrations (~> 0.0.1)
gh
hashr (~> 0.0.19)
+ metriks (~> 0.9.7.3)
octokit (~> 0.6.5)
postmark-rails (~> 0.4.1)
pusher (~> 0.9.2)
@@ -111,6 +103,7 @@ GEM
archive-tar-minitar (0.5.2)
arel (3.0.2)
atomic (1.0.0)
+ avl_tree (1.1.2)
backports (2.3.0)
bcrypt-ruby (3.0.1)
builder (3.0.0)
@@ -188,11 +181,18 @@ GEM
json
rest-client
ya2yaml
+ lograge (0.0.4)
+ actionpack
+ activesupport
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
metaclass (0.0.1)
+ metriks (0.9.7.3)
+ atomic (~> 1.0)
+ avl_tree (~> 1.1.2)
+ hitimes (~> 1.1)
mime-types (1.18)
mocha (0.10.5)
metaclass (~> 0.0.1)
@@ -359,7 +359,7 @@ DEPENDENCIES
json (~> 1.6.3)
localeapp (~> 0.4.1)
localeapp-i18n-js!
- metriks!
+ lograge (~> 0.0.4)
mocha (~> 0.10.0)
newrelic_rpm (~> 3.3.0)
omniauth-github (~> 1.0.1)
@@ -75,23 +75,15 @@
config.active_support.deprecation = :notify
config.middleware.insert_before(::Rack::Lock, 'Refraction')
+ config.lograge.enabled = true
require 'notifications'
- config.action_dispatch.rack_cache = {
- :metastore => "rails:/",
- :entitystore => "rails:/",
- :verbose => false
- }
-
- config.middleware.delete Rails::Rack::Logger
-
config.after_initialize do
Travis.logger.level = Logger::INFO
ActionController::Base.logger = Travis.logger
ActiveRecord::Base.logger = Travis.logger
- require 'logging'
end
require 'hubble'
View
@@ -1,46 +0,0 @@
-%w(redirect_to process_action start_processing send_data write_fragment exist_fragment? send_file).each do |event|
- ActiveSupport::Notifications.unsubscribe "#{event}.action_controller"
-end
-
-%w{render_template render_partial render_collection}.each do |event|
- ActiveSupport::Notifications.unsubscribe "#{event}.action_view"
-end
-
-module Travis
- class RequestLogSubscriber < ActiveSupport::LogSubscriber
- def process_action(event)
- payload = event.payload
- message = "#{payload[:method]} #{payload[:path]} format=#{payload[:format]} action=#{payload[:params]['controller']}##{payload[:params]['action']}"
- message << extract_status(payload)
- message << runtimes(event)
- logger.info(message)
- end
-
- private
-
- def extract_status(payload)
- if payload[:status]
- " status=#{payload[:status]}"
- elsif payload[:exception]
- exception, message = payload[:exception]
- " status=500 error='#{exception}:#{message}'"
- end
- end
-
- def runtimes(event)
- message = ""
- {:duration => event.duration,
- :view => event.payload[:view_runtime],
- :db => event.payload[:db_runtime]}.each do |name, runtime|
- message << " #{name}=%.2f" % runtime if runtime
- end
- message
- end
-
- def logger
- ActionController::Base.logger
- end
- end
-end
-
-Travis::RequestLogSubscriber.attach_to :action_controller
View
@@ -2,21 +2,13 @@
module Travis
class Metrics
- def initialize
- @env = ENV['ENV'] || "production"
- end
-
def metric_name(name)
- "travis.#{@env}.#{name}"
+ "travis.#{name}"
end
def subscribe
- ActiveSupport::Notifications.subscribe(%r{^github\.requests.*}) do |name, source, payload|
- if source
- Metriks.meter(metric_name(name), source).mark
- else
- Metriks.meter(metric_name(name)).mark
- end
+ ActiveSupport::Notifications.subscribe(%r{^github\.requests.*}) do |name, payload|
+ Metriks.meter(metric_name(name)).mark
end
end
end

0 comments on commit b3299d9

Please sign in to comment.