Sha256: abea737fd2b09f651a6522e5eb4f55aa1363c6aaefaed6ca5866a383d4d161a5

Contents?: true

Size: 1.48 KB

Versions: 24

Compression:

Stored size: 1.48 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.

require 'json'

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)
        ::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
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
newrelic_rpm-6.5.0.357 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-6.4.0.356 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-6.3.0.355 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-6.2.0.354 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-6.1.0.352 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-6.0.0.351 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-5.7.0.350 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-5.6.0.349 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-5.5.0.348 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-5.4.0.347 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-5.3.0.346 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-5.2.0.345 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-5.1.0.344 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-5.0.0.342 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-4.8.0.341 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-4.7.1.340 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-4.7.0.339 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-4.6.0.338 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-4.5.0.337 lib/new_relic/agent/inbound_request_monitor.rb
newrelic_rpm-4.4.0.336 lib/new_relic/agent/inbound_request_monitor.rb