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.



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

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.



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

def obfuscator
  @obfuscator
end

Instance Method Details

#deserialize_header(encoded_header, key) ⇒ Object



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

def deserialize_header(encoded_header, key)
  decoded_header = obfuscator.deobfuscate(encoded_header)
  ::JSON.parse(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



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

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