Sha256: e8770c50da2d6290d73e68b5d7d0c6ee8c7678b12f167ed3f99a409ad9d6278c

Contents?: true

Size: 1.47 KB

Versions: 29

Compression:

Stored size: 1.47 KB

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

# This class serves as the base for objects wanting to monitor and respond to
# incoming web requests. Examples include cross application tracing and
# synthetics.
#
# Subclasses are expected to define on_finished_configuring(events) which will
# be called when the agent is fully configured. That method is expected to
# subscribe to the necessary request events, such as before_call and after_call
# for the monitor to do its work.
module NewRelic
  module Agent
    class InboundRequestMonitor

      attr_reader :obfuscator

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

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

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

Version data entries

29 entries across 29 versions & 2 rubygems

Version Path
newrelic_rpm-3.18.1.330 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-3.18.0.329 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-3.17.2.327 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-3.17.1.326 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-3.17.0.325 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-3.16.3.323 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-3.16.2.321 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-3.16.1.320 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-3.16.0.318 lib/new_relic/agent/inbound_request_monitor.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/newrelic_rpm-3.15.2.317/lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-3.15.2.317 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-3.15.1.316 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-3.15.0.314 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-3.14.3.313 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-3.14.2.312 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-3.14.1.311 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-3.14.0.305 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-3.13.2.302 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-3.13.1.300 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-3.13.0.299 lib/new_relic/agent/inbound_request_monitor.rb