Add Sentry for exception tracking

This commit is contained in:
Greg Karékinian 2015-04-28 18:26:00 +02:00
parent 35c04f85e4
commit 3b326d6dbf
4 changed files with 26 additions and 35 deletions

View File

@ -16,4 +16,5 @@ end
group :staging, :production do
gem "rainbows"
gem "sentry-raven"
end

View File

@ -21,6 +21,8 @@ GEM
builder (3.2.2)
eventmachine (1.0.3)
excon (0.16.10)
faraday (0.9.1)
multipart-post (>= 1.2, < 3)
fog (1.7.0)
builder
excon (~> 0.14)
@ -42,6 +44,7 @@ GEM
mime-types (1.23)
minitest (2.10.0)
multi_json (1.10.0)
multipart-post (2.0.0)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
net-ssh (2.6.7)
@ -63,6 +66,8 @@ GEM
rest-client (1.6.7)
mime-types (>= 1.16)
ruby-hmac (0.4.0)
sentry-raven (0.13.1)
faraday (>= 0.7.6)
sinatra (1.4.5)
rack (~> 1.4)
rack-protection (~> 1.4)
@ -93,5 +98,6 @@ DEPENDENCIES
redis
rest-client
riak-client!
sentry-raven
sinatra (~> 1.4)
sinatra-contrib

View File

@ -37,13 +37,8 @@ module RemoteStorage
res = do_head_request(url)
set_response_headers(res)
rescue => exception
if exception.is_a? RestClient::ResourceNotFound
server.halt 404
end
puts exception.inspect
server.halt 499
rescue RestClient::ResourceNotFound
server.halt 404
end
def get_data(user, directory, key)
@ -57,13 +52,8 @@ module RemoteStorage
server.halt 304 if none_match.include? %Q("#{res.headers[:etag]}")
return res.body
rescue => exception
if exception.is_a? RestClient::ResourceNotFound
server.halt 404
end
puts exception.inspect
server.halt 499
rescue RestClient::ResourceNotFound
server.halt 404
end
def get_head_directory_listing(user, directory)
@ -71,13 +61,8 @@ module RemoteStorage
server.headers["Content-Type"] = "application/json"
server.headers["ETag"] = %Q("#{res.headers[:etag]}")
rescue => exception
if exception.is_a? RestClient::ResourceNotFound
server.halt 404
end
puts exception.inspect
server.halt 499
rescue RestClient::ResourceNotFound
server.halt 404
end
def get_directory_listing(user, directory)
@ -102,9 +87,6 @@ module RemoteStorage
end
listing.to_json
rescue => exception
puts exception.inspect
server.halt 499
end
def put_data(user, directory, key, data, content_type)
@ -129,11 +111,8 @@ module RemoteStorage
server.headers["ETag"] = %Q("#{res.headers[:etag]}")
server.halt 200
else
server.halt 499 # TODO use sth more suitable
server.halt 500
end
rescue => exception
puts exception.inspect
server.halt 499 # TODO use sth more suitable
end
def delete_data(user, directory, key)
@ -149,13 +128,8 @@ module RemoteStorage
delete_dir_objects(user, directory)
server.halt 200
rescue => exception
if exception.is_a? RestClient::ResourceNotFound
server.halt 404
end
puts exception.inspect
server.halt 499
rescue RestClient::ResourceNotFound
server.halt 404
end
private

View File

@ -30,6 +30,16 @@ class LiquorCabinet < Sinatra::Base
configure :production, :staging do
require "rack/common_logger"
if ENV['SENTRY_DSN']
require "raven"
Raven.configure do |config|
config.dsn = ENV['SENTRY_DSN']
config.tags = { environment: settings.environment.to_s }
end
use Raven::Rack
end
end
#