Class: Sqreen::Rules::RecordRequestContext
- Inherits:
-
RuleCB
- Object
- CB
- FrameworkCB
- RuleCB
- Sqreen::Rules::RecordRequestContext
- Defined in:
- lib/sqreen/rules/record_request_context.rb
Overview
Save request context for handling further down
Constant Summary collapse
- WHITELISTED_METRIC =
'whitelisted'.freeze
Constants inherited from RuleCB
Sqreen::Rules::RuleCB::DEFAULT_PAYLOAD
Constants included from CallCountable
CallCountable::COUNT_CALLS, CallCountable::FAILING, CallCountable::POST, CallCountable::PRE
Constants inherited from CB
Instance Attribute Summary
Attributes inherited from RuleCB
Attributes included from CallCountable
#call_count_interval, #call_counts
Attributes inherited from FrameworkCB
Attributes inherited from CB
#klass, #method, #overtimeable
Instance Method Summary collapse
- #failing(_exception, _inst, _args, _budget = nil, &_block) ⇒ Object
-
#initialize(*args) ⇒ RecordRequestContext
constructor
A new instance of RecordRequestContext.
- #post(rv, _inst, args, _budget = nil, &_block) ⇒ Object
- #pre(_inst, args, _budget = nil, &_block) ⇒ Object
- #whitelisted? ⇒ Boolean
Methods inherited from RuleCB
#advise_action, #overtime!, #priority, #record_event, #record_exception, #rule_name, #rulespack_id
Methods included from CallCountable
#count_callback_calls, #failing_with_count, #post_with_count, #pre_with_count
Methods included from Conditionable
#condition_callbacks, #failing_with_conditions, #post_with_conditions, #pre_with_conditions
Methods inherited from FrameworkCB
Methods inherited from CB
#failing?, #framework, #overtime!, #post?, #pre?, #priority, #to_s
Constructor Details
#initialize(*args) ⇒ RecordRequestContext
Returns a new instance of RecordRequestContext.
13 14 15 16 |
# File 'lib/sqreen/rules/record_request_context.rb', line 13 def initialize(*args) super(*args) @overtimeable = false end |
Instance Method Details
#failing(_exception, _inst, _args, _budget = nil, &_block) ⇒ Object
41 42 43 44 |
# File 'lib/sqreen/rules/record_request_context.rb', line 41 def failing(_exception, _inst, _args, _budget = nil, &_block) framework.clean_request advise_action(nil) end |
#post(rv, _inst, args, _budget = nil, &_block) ⇒ Object
35 36 37 38 39 |
# File 'lib/sqreen/rules/record_request_context.rb', line 35 def post(rv, _inst, args, _budget = nil, &_block) framework.store_response(rv, args[0]) framework.clean_request advise_action(nil) end |
#pre(_inst, args, _budget = nil, &_block) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/sqreen/rules/record_request_context.rb', line 22 def pre(_inst, args, _budget = nil, &_block) framework.store_request(args[0]) wh = framework.whitelisted_match if wh unless Sqreen.features.key?('whitelisted_metric') && !Sqreen.features['whitelisted_metric'] record_observation(WHITELISTED_METRIC, wh, 1) end Sqreen.log.debug { "Request was whitelisted because of #{wh}" } end advise_action(nil) end |
#whitelisted? ⇒ Boolean
18 19 20 |
# File 'lib/sqreen/rules/record_request_context.rb', line 18 def whitelisted? false end |