Sha256: 286852c53a4d3a77fa75c58d7abb4c77af2b5d2dc155c69fbaeebbd4103b30a5

Contents?: true

Size: 1.6 KB

Versions: 1

Compression:

Stored size: 1.6 KB

Contents

# Copyright (c) 2016 SolarWinds, LLC.
# All rights reserved.

module AppOpticsAPM
  module Inst
    module RestClientRequest
      def self.included(klass)
        ::AppOpticsAPM::Util.method_alias(klass, :execute, ::RestClient::Request)
      end

      ##
      # execute_with_appoptics
      #
      # The wrapper method for RestClient::Request.execute
      #
      def execute_with_appoptics(&block)
        blacklisted = AppOpticsAPM::API.blacklisted?(uri)

        unless AppOpticsAPM.tracing?
          xtrace = AppOpticsAPM::Context.toString
          @processed_headers = make_headers('X-Trace' => xtrace) if AppOpticsAPM::XTrace.valid?(xtrace) && !blacklisted
          return execute_without_appoptics(&block)
        end

        begin
          kvs = {}
          kvs[:Backtrace] = AppOpticsAPM::API.backtrace if AppOpticsAPM::Config[:rest_client][:collect_backtraces]
          AppOpticsAPM::API.log_entry('rest-client', kvs)

          @processed_headers = make_headers('X-Trace' => AppOpticsAPM::Context.toString) unless blacklisted

          # The core rest-client call
          execute_without_appoptics(&block)
        rescue => e
          AppOpticsAPM::API.log_exception('rest-client', e)
          raise e
        ensure
          AppOpticsAPM::API.log_exit('rest-client')
        end
      end
    end
  end
end

if AppOpticsAPM::Config[:rest_client][:enabled]
  if defined?(::RestClient)
    AppOpticsAPM.logger.info '[appoptics_apm/loading] Instrumenting rest-client' if AppOpticsAPM::Config[:verbose]
    ::AppOpticsAPM::Util.send_include(::RestClient::Request, ::AppOpticsAPM::Inst::RestClientRequest)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
appoptics_apm-4.0.1-x86_64-linux lib/appoptics_apm/inst/rest-client.rb