Class: Contrast::Agent::RequestHandler
- Includes:
- Components::Logger::InstanceMethods
- Defined in:
- lib/contrast/agent/request/request_handler.rb
Overview
This class is instantiated when we receive a request and the agent is enabled to process that request. It holds the ruleset that we perform filtering operations on (currently prefilter and postfilter).
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#ruleset ⇒ Object
readonly
Returns the value of attribute ruleset.
Instance Method Summary collapse
-
#initialize(context) ⇒ RequestHandler
constructor
A new instance of RequestHandler.
-
#report_observed_route ⇒ Object
reports events to TS Other ReportingEvents are handled through batching in the middleware.
-
#stream_safe_postfilter ⇒ Object
If the response is streaming, we should only perform filtering on our stream safe rules.
Methods included from Components::Logger::InstanceMethods
Constructor Details
#initialize(context) ⇒ RequestHandler
Returns a new instance of RequestHandler.
19 20 21 22 |
# File 'lib/contrast/agent/request/request_handler.rb', line 19 def initialize context @context = context @ruleset = ::Contrast::AGENT.ruleset end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
16 17 18 |
# File 'lib/contrast/agent/request/request_handler.rb', line 16 def context @context end |
#ruleset ⇒ Object (readonly)
Returns the value of attribute ruleset.
16 17 18 |
# File 'lib/contrast/agent/request/request_handler.rb', line 16 def ruleset @ruleset end |
Instance Method Details
#report_observed_route ⇒ Object
reports events to TS Other ReportingEvents are handled through batching in the middleware
27 28 29 30 31 32 |
# File 'lib/contrast/agent/request/request_handler.rb', line 27 def report_observed_route return unless (reporter = Contrast::Agent.reporter) return if Contrast::Agent::REQUEST_TRACKER.current&.response&.response_code == 404 reporter.send_event(context.observed_route) if Contrast::ROUTES_SENT.sendable?(context.observed_route) end |
#stream_safe_postfilter ⇒ Object
If the response is streaming, we should only perform filtering on our stream safe rules
35 36 37 38 39 |
# File 'lib/contrast/agent/request/request_handler.rb', line 35 def stream_safe_postfilter stream_safe_ruleset = ruleset.select(&:stream_safe?) postfilter_ruleset = Contrast::Agent::RuleSet.new(stream_safe_ruleset) postfilter_ruleset.postfilter end |