Class: NewRelic::Security::Agent::Control::EventProcessor
- Inherits:
-
Object
- Object
- NewRelic::Security::Agent::Control::EventProcessor
- Defined in:
- lib/newrelic_security/agent/control/event_processor.rb
Instance Attribute Summary collapse
-
#event_dequeue_threads ⇒ Object
Returns the value of attribute event_dequeue_threads.
-
#eventQ ⇒ Object
Returns the value of attribute eventQ.
-
#healthcheck_thread ⇒ Object
Returns the value of attribute healthcheck_thread.
Instance Method Summary collapse
-
#initialize ⇒ EventProcessor
constructor
A new instance of EventProcessor.
- #send_app_info ⇒ Object
- #send_application_url_mappings ⇒ Object
- #send_critical_message(message, level, caller, thread_name, exc) ⇒ Object
- #send_event(event) ⇒ Object
- #send_exit_event(exit_event) ⇒ Object
- #send_health ⇒ Object
- #send_iast_data_transfer_request(iast_data_transfer_request) ⇒ Object
Constructor Details
#initialize ⇒ EventProcessor
Returns a new instance of EventProcessor.
14 15 16 17 18 19 20 21 |
# File 'lib/newrelic_security/agent/control/event_processor.rb', line 14 def initialize @first_event = true @eventQ = ::SizedQueue.new(EVENT_QUEUE_SIZE) create_dequeue_threads create_keep_alive_thread create_error_reporting_thread NewRelic::Security::Agent.init_logger.info "[STEP-5] => Security agent components started" end |
Instance Attribute Details
#event_dequeue_threads ⇒ Object
Returns the value of attribute event_dequeue_threads.
12 13 14 |
# File 'lib/newrelic_security/agent/control/event_processor.rb', line 12 def event_dequeue_threads @event_dequeue_threads end |
#eventQ ⇒ Object
Returns the value of attribute eventQ.
12 13 14 |
# File 'lib/newrelic_security/agent/control/event_processor.rb', line 12 def eventQ @eventQ end |
#healthcheck_thread ⇒ Object
Returns the value of attribute healthcheck_thread.
12 13 14 |
# File 'lib/newrelic_security/agent/control/event_processor.rb', line 12 def healthcheck_thread @healthcheck_thread end |
Instance Method Details
#send_app_info ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/newrelic_security/agent/control/event_processor.rb', line 23 def send_app_info NewRelic::Security::Agent.init_logger.info "[STEP-3] => Gathering information about the application" app_info = NewRelic::Security::Agent::Control::AppInfo.new app_info.update_app_info app_info_json = app_info.to_json NewRelic::Security::Agent.logger.info "Sending application info : #{app_info_json}" NewRelic::Security::Agent.init_logger.info "Sending application info : #{app_info_json}" enqueue(app_info) app_info = nil app_info_json = nil end |
#send_application_url_mappings ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/newrelic_security/agent/control/event_processor.rb', line 35 def send_application_url_mappings application_url_mappings = NewRelic::Security::Agent::Control::ApplicationURLMappings.new application_url_mappings.update_application_url_mappings application_url_mappings_json = application_url_mappings.to_json NewRelic::Security::Agent.logger.info "Sending application URL Mappings : #{application_url_mappings_json}" enqueue(application_url_mappings) application_url_mappings = nil application_url_mappings_json = nil end |
#send_critical_message(message, level, caller, thread_name, exc) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/newrelic_security/agent/control/event_processor.rb', line 68 def (, level, caller, thread_name, exc) if exc exception = {} exception[:message] = exc. exception[:cause] = { :message => exc.cause } exception[:stackTrace] = exc.backtrace.map(&:to_s) end = NewRelic::Security::Agent::Control::CriticalMessage.new(, level, caller, thread_name, exception) enqueue() = nil end |
#send_event(event) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/newrelic_security/agent/control/event_processor.rb', line 45 def send_event(event) NewRelic::Security::Agent.agent.event_processed_count.increment if NewRelic::Security::Agent::Utils.is_IAST_request?(event.httpRequest[:headers]) NewRelic::Security::Agent.agent.iast_event_stats.processed.increment else NewRelic::Security::Agent.agent.rasp_event_stats.processed.increment end enqueue(event) if @first_event NewRelic::Security::Agent.init_logger.info "[STEP-8] => First event sent for validation. Security agent started successfully : #{event.to_json}" NewRelic::Security::Agent.config.traffic_start_time = current_time_millis unless NewRelic::Security::Agent.config[:traffic_start_time] @first_event = false end event = nil end |
#send_exit_event(exit_event) ⇒ Object
80 81 82 83 84 |
# File 'lib/newrelic_security/agent/control/event_processor.rb', line 80 def send_exit_event(exit_event) NewRelic::Security::Agent.agent.exit_event_stats.processed.increment enqueue(exit_event) exit_event = nil end |
#send_health ⇒ Object
61 62 63 64 65 66 |
# File 'lib/newrelic_security/agent/control/event_processor.rb', line 61 def send_health health = NewRelic::Security::Agent::Control::Health.new health.update_health_check NewRelic::Security::Agent::Control::WebsocketClient.instance.send(health) health = nil end |
#send_iast_data_transfer_request(iast_data_transfer_request) ⇒ Object
86 87 88 89 |
# File 'lib/newrelic_security/agent/control/event_processor.rb', line 86 def send_iast_data_transfer_request(iast_data_transfer_request) enqueue(iast_data_transfer_request) iast_data_transfer_request = nil end |