Skip to content

Instantly share code, notes, and snippets.

@luxflux
Created April 29, 2015 09:42
Show Gist options
  • Save luxflux/55a082f2f0892696b9d9 to your computer and use it in GitHub Desktop.
Save luxflux/55a082f2f0892696b9d9 to your computer and use it in GitHub Desktop.
if Rails.env.production?
InfluxDB::Rails.configure do |config|
config.async = true
config.instrumentation_enabled = false
end
ActiveSupport::Notifications.subscribe 'process_action.action_controller' do |name, started, finished, unique_id, payload|
log = {
http_status: payload[:status],
uri: payload[:path],
view_runtime: (payload[:view_runtime] || 0).ceil,
db_runtime: (payload[:db_runtime] || 0).ceil,
total_runtime: ((finished - started)*1000).ceil,
hostname: Socket.gethostname,
}
InfluxDB::Rails.client.write_point('rails.logs', log)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment