Class: NewRelic::Agent::InboundRequestMonitor

Inherits:
Object
  • Object
show all
Defined in:
lib/new_relic/agent/monitors/inbound_request_monitor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(events) ⇒ InboundRequestMonitor

Returns a new instance of InboundRequestMonitor.



21
22
23
24
25
26
27
# File 'lib/new_relic/agent/monitors/inbound_request_monitor.rb', line 21

def initialize(events)
  events.subscribe(:initial_configuration_complete) do
    # This requires :encoding_key, so must wait until :initial_configuration_complete
    setup_obfuscator
    on_finished_configuring(events)
  end
end

Instance Attribute Details

#obfuscatorObject (readonly)

Returns the value of attribute obfuscator.



19
20
21
# File 'lib/new_relic/agent/monitors/inbound_request_monitor.rb', line 19

def obfuscator
  @obfuscator
end

Instance Method Details

#deserialize_header(encoded_header, key) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/new_relic/agent/monitors/inbound_request_monitor.rb', line 33

def deserialize_header(encoded_header, key)
  decoded_header = obfuscator.deobfuscate(encoded_header)
  ::JSON.load(decoded_header)
rescue => err
  # If we have a failure of any type here, just return nil and carry on
  NewRelic::Agent.logger.debug("Failure deserializing encoded header '#{key}' in #{self.class}, #{err.class}, #{err.message}")
  nil
end

#setup_obfuscatorObject



29
30
31
# File 'lib/new_relic/agent/monitors/inbound_request_monitor.rb', line 29

def setup_obfuscator
  @obfuscator = Obfuscator.new(Agent.config[:encoding_key])
end