stop logging stats in adheres_to_policy
refs CORE-2538 test plan - specs should pass Change-Id: I09ffd6982be803294b7d70c1e485d999a01352ea Reviewed-on: https://gerrit.instructure.com/186260 Tested-by: Jenkins Reviewed-by: Cody Cutrer <cody@instructure.com> QA-Review: Cody Cutrer <cody@instructure.com> Product-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
parent
d7b5e1de7f
commit
e430f35de0
|
@ -15,7 +15,6 @@ Gem::Specification.new do |spec|
|
|||
spec.require_paths = ["lib"]
|
||||
|
||||
spec.add_dependency 'rails', ">= 3.2"
|
||||
spec.add_dependency 'canvas_statsd', "~> 2.0"
|
||||
|
||||
spec.add_development_dependency "bundler", "~> 1.5"
|
||||
spec.add_development_dependency "rake"
|
||||
|
|
|
@ -42,9 +42,9 @@ module AdheresToPolicy
|
|||
if value.nil?
|
||||
if block_given?
|
||||
how_it_got_it = :generated
|
||||
elapsed = Benchmark.realtime do
|
||||
value = yield
|
||||
end
|
||||
start_time = Time.now
|
||||
value = yield
|
||||
elapsed = Time.now - start_time
|
||||
Thread.current[:last_cache_generate] = elapsed # so we can record it in the logs
|
||||
self.write(key, value, use_rails_cache: use_rails_cache)
|
||||
end
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
require 'canvas_statsd'
|
||||
|
||||
module AdheresToPolicy
|
||||
module InstanceMethods
|
||||
# Public: Gets the requested rights granted to a user.
|
||||
|
@ -244,45 +242,42 @@ module AdheresToPolicy
|
|||
permission_cache_key_for(user, session, sought_right),
|
||||
use_rails_cache: use_rails_cache
|
||||
) do
|
||||
CanvasStatsd::BlockTracking.track("adheres_to_policy.#{sought_right_cookie}", category: :adheres_to_policy) do
|
||||
|
||||
conditions = self.class.policy.conditions[sought_right]
|
||||
next false unless conditions
|
||||
conditions = self.class.policy.conditions[sought_right]
|
||||
next false unless conditions
|
||||
|
||||
# Loop through all the conditions until we find the first one that
|
||||
# grants us the sought_right.
|
||||
conditions.any? do |condition|
|
||||
condition_applies = false
|
||||
elapsed_time = Benchmark.realtime do
|
||||
condition_applies = condition.applies?(self, user, session)
|
||||
end
|
||||
# Loop through all the conditions until we find the first one that
|
||||
# grants us the sought_right.
|
||||
conditions.any? do |condition|
|
||||
condition_applies = false
|
||||
start_time = Time.now
|
||||
condition_applies = condition.applies?(self, user, session)
|
||||
elapsed_time = Time.now - start_time
|
||||
|
||||
if condition_applies
|
||||
# Since the condition is true we can loop through all the rights
|
||||
# that belong to it and cache them. This will short circut the above
|
||||
# Rails.cache.fetch for future checks that we won't have to do again.
|
||||
condition.rights.each do |condition_right|
|
||||
if condition_applies
|
||||
# Since the condition is true we can loop through all the rights
|
||||
# that belong to it and cache them. This will short circut the above
|
||||
# Rails.cache.fetch for future checks that we won't have to do again.
|
||||
condition.rights.each do |condition_right|
|
||||
|
||||
# Skip the condition_right if its the one we are looking for.
|
||||
# The Rails.cache.fetch will take care of caching it for us.
|
||||
if condition_right != sought_right
|
||||
# Skip the condition_right if its the one we are looking for.
|
||||
# The Rails.cache.fetch will take care of caching it for us.
|
||||
if condition_right != sought_right
|
||||
|
||||
Thread.current[:last_cache_generate] = elapsed_time # so we can record it in the logs
|
||||
# Cache the condition_right since we already know they have access.
|
||||
Cache.write(
|
||||
permission_cache_key_for(user, session, condition_right),
|
||||
true,
|
||||
use_rails_cache: config.cache_permissions && config.cache_related_permissions
|
||||
)
|
||||
end
|
||||
Thread.current[:last_cache_generate] = elapsed_time # so we can record it in the logs
|
||||
# Cache the condition_right since we already know they have access.
|
||||
Cache.write(
|
||||
permission_cache_key_for(user, session, condition_right),
|
||||
true,
|
||||
use_rails_cache: config.cache_permissions && config.cache_related_permissions
|
||||
)
|
||||
end
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
CanvasStatsd::Statsd.instance&.increment("adheres_to_policy.#{sought_right_cookie}.#{how_it_got_it}")
|
||||
|
||||
value
|
||||
ensure
|
||||
|
|
Loading…
Reference in New Issue