Sha256: f8c4d4788eddffbc958814118638675e7fa4a3b1a193b203c64f60161cc046ea

Contents?: true

Size: 1.49 KB

Versions: 32

Compression:

Stored size: 1.49 KB

Contents

# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
# frozen_string_literal: true

# 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(:initial_configuration_complete) do
          # This requires :encoding_key, so must wait until :initial_configuration_complete
          setup_obfuscator
          on_finished_configuring(events)
        end
      end

      def setup_obfuscator
        @obfuscator = Obfuscator.new(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

32 entries across 32 versions & 1 rubygems

Version Path
newrelic_rpm-9.16.0 lib/new_relic/agent/monitors/inbound_request_monitor.rb
newrelic_rpm-9.15.0 lib/new_relic/agent/monitors/inbound_request_monitor.rb
newrelic_rpm-9.14.0 lib/new_relic/agent/monitors/inbound_request_monitor.rb
newrelic_rpm-9.13.0 lib/new_relic/agent/monitors/inbound_request_monitor.rb
newrelic_rpm-9.12.0 lib/new_relic/agent/monitors/inbound_request_monitor.rb
newrelic_rpm-9.11.0 lib/new_relic/agent/monitors/inbound_request_monitor.rb
newrelic_rpm-9.10.2 lib/new_relic/agent/monitors/inbound_request_monitor.rb
newrelic_rpm-9.10.1 lib/new_relic/agent/monitors/inbound_request_monitor.rb
newrelic_rpm-9.10.0 lib/new_relic/agent/monitors/inbound_request_monitor.rb
newrelic_rpm-9.9.0 lib/new_relic/agent/monitors/inbound_request_monitor.rb
newrelic_rpm-9.8.0 lib/new_relic/agent/monitors/inbound_request_monitor.rb
newrelic_rpm-9.7.1 lib/new_relic/agent/monitors/inbound_request_monitor.rb
newrelic_rpm-9.7.0 lib/new_relic/agent/monitors/inbound_request_monitor.rb
newrelic_rpm-9.6.0 lib/new_relic/agent/monitors/inbound_request_monitor.rb
newrelic_rpm-9.5.0 lib/new_relic/agent/monitors/inbound_request_monitor.rb
newrelic_rpm-9.4.2 lib/new_relic/agent/monitors/inbound_request_monitor.rb
newrelic_rpm-9.4.1 lib/new_relic/agent/monitors/inbound_request_monitor.rb
newrelic_rpm-9.4.0 lib/new_relic/agent/monitors/inbound_request_monitor.rb
newrelic_rpm-9.3.1 lib/new_relic/agent/monitors/inbound_request_monitor.rb
newrelic_rpm-9.3.0 lib/new_relic/agent/monitors/inbound_request_monitor.rb