add details to newrelic trace, fix 401 errors for xml
This commit is contained in:
@@ -58,6 +58,10 @@ protected
|
|||||||
render :text => "authentication failed", :status => 401
|
render :text => "authentication failed", :status => 401
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fmt.xml do
|
||||||
|
render :xml => {:sucess => false, :reason => "authentication failed"}.to_xml(:root => "response"), :status => 401
|
||||||
|
end
|
||||||
|
|
||||||
fmt.json do
|
fmt.json do
|
||||||
render :json => {:success => false, :reason => "authentication failed"}.to_json, :status => 401
|
render :json => {:success => false, :reason => "authentication failed"}.to_json, :status => 401
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1034,7 +1034,7 @@ class Post < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def fast_count_search(tags, options = {})
|
def fast_count_search(tags, options = {})
|
||||||
count = Post.with_timeout(options[:statement_timeout] || 500, Danbooru.config.blank_tag_search_fast_count || 1_000_000) do
|
count = Post.with_timeout(options[:statement_timeout] || 500, Danbooru.config.blank_tag_search_fast_count || 1_000_000, :tags => tags) do
|
||||||
Post.tag_match(tags).count
|
Post.tag_match(tags).count
|
||||||
end
|
end
|
||||||
if count > 0
|
if count > 0
|
||||||
|
|||||||
@@ -11,12 +11,12 @@ module Danbooru
|
|||||||
connection.execute("SET STATEMENT_TIMEOUT = #{CurrentUser.user.try(:statement_timeout) || 3_000}") unless Rails.env == "test"
|
connection.execute("SET STATEMENT_TIMEOUT = #{CurrentUser.user.try(:statement_timeout) || 3_000}") unless Rails.env == "test"
|
||||||
end
|
end
|
||||||
|
|
||||||
def with_timeout(n, default_value = nil)
|
def with_timeout(n, default_value = nil, new_relic_params = {})
|
||||||
connection.execute("SET STATEMENT_TIMEOUT = #{n}") unless Rails.env == "test"
|
connection.execute("SET STATEMENT_TIMEOUT = #{n}") unless Rails.env == "test"
|
||||||
yield
|
yield
|
||||||
rescue ::ActiveRecord::StatementInvalid => x
|
rescue ::ActiveRecord::StatementInvalid => x
|
||||||
if Rails.env.production?
|
if Rails.env.production?
|
||||||
NewRelic::Agent.notice_error(x, :custom_params => {:user_id => CurrentUser.user.id, :user_ip_addr => CurrentUser.ip_addr})
|
NewRelic::Agent.notice_error(x, :custom_params => new_relic_params.merge(:user_id => CurrentUser.user.id, :user_ip_addr => CurrentUser.ip_addr))
|
||||||
end
|
end
|
||||||
return default_value
|
return default_value
|
||||||
ensure
|
ensure
|
||||||
|
|||||||
Reference in New Issue
Block a user