posts: fix search queries not being logged to NewRelic in some cases (#4900)
Fix the /posts index controller not logging the normalized search query to NewRelic when the search failed, either because of a tag limit error, a search timeout, or a RSS feed rate limit error. Also don't log the number of search results when it's an API request or failed search. This is to avoid doing a potentially slow full post count when it's not otherwise needed.
This commit is contained in:
@@ -968,7 +968,7 @@ class PostQueryBuilder
|
||||
|
||||
concerning :CountMethods do
|
||||
def post_count
|
||||
fast_count
|
||||
@post_count ||= fast_count
|
||||
end
|
||||
|
||||
# Return an estimate of the number of posts returned by the search. By
|
||||
|
||||
@@ -137,24 +137,6 @@ module PostSets
|
||||
end
|
||||
end
|
||||
|
||||
def search_stats
|
||||
{
|
||||
query: normalized_query.to_s,
|
||||
count: post_count,
|
||||
page: current_page,
|
||||
limit: per_page,
|
||||
term_count: normalized_query.terms.count,
|
||||
tag_count: normalized_query.tags.count,
|
||||
metatag_count: normalized_query.metatags.count,
|
||||
censored_posts: censored_posts.count,
|
||||
hidden_posts: hidden_posts.count,
|
||||
}
|
||||
end
|
||||
|
||||
def log!
|
||||
DanbooruLogger.add_attributes("search", search_stats)
|
||||
end
|
||||
|
||||
concerning :TagListMethods do
|
||||
def related_tags
|
||||
if query.is_wildcard_search?
|
||||
|
||||
Reference in New Issue
Block a user