Class: Contrast::Agent::RequestHandler

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Methods included from Components::Logger::InstanceMethods

#cef_logger, #logger

Constructor Details

#initialize(context) ⇒ RequestHandler

Returns a new instance of RequestHandler.

Parameters:



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

#contextObject (readonly)

Returns the value of attribute context.



16
17
18
# File 'lib/contrast/agent/request/request_handler.rb', line 16

def context
  @context
end

#rulesetObject (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_routeObject

reports events to TS Other ReportingEvents are handled through batching in the middleware



27
28
29
30
31
# File 'lib/contrast/agent/request/request_handler.rb', line 27

def report_observed_route
  return unless (reporter = Contrast::Agent.reporter)

  reporter.send_event(context.observed_route) if Contrast::ROUTES_SENT.sendable?(context.observed_route)
end

#stream_safe_postfilterObject

If the response is streaming, we should only perform filtering on our stream safe rules



34
35
36
37
38
# File 'lib/contrast/agent/request/request_handler.rb', line 34

def stream_safe_postfilter
  stream_safe_ruleset = ruleset.select(&:stream_safe?)
  postfilter_ruleset = Contrast::Agent::RuleSet.new(stream_safe_ruleset)
  postfilter_ruleset.postfilter
end