Only track Redis calls if Peek is enabled

In dev environments, Sidekiq was encountering the message:

Circular dependency detected while autoloading constant Gitlab::Profiler

This saves some overhead during normal usage.
This commit is contained in:
Stan Hu 2019-08-02 23:40:32 -07:00
parent bce8b66d51
commit a43c84e6ab
2 changed files with 10 additions and 0 deletions

View File

@ -0,0 +1,5 @@
---
title: Only track Redis calls if Peek is enabled
merge_request: 31438
author:
type: performance

View File

@ -16,6 +16,7 @@ module Gitlab
private
def add_call_details(duration, args)
return unless peek_enabled?
# redis-rb passes an array (e.g. [:get, key])
return unless args.length == 1
@ -26,6 +27,10 @@ module Gitlab
}
end
def peek_enabled?
Gitlab::SafeRequestStore.store[:peek_enabled]
end
def detail_store
::Gitlab::SafeRequestStore['redis_call_details'] ||= []
end