Class: Skylight::Core::Probes::Elasticsearch::Probe Private

Inherits:
Object
  • Object
show all
Defined in:
lib/skylight/core/probes/elasticsearch.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#installObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/skylight/core/probes/elasticsearch.rb', line 5

def install
  ::Elasticsearch::Transport::Transport::Base.class_eval do
    alias_method :perform_request_without_sk, :perform_request
    def perform_request(method, path, *args, &block)
      ActiveSupport::Notifications.instrument "request.elasticsearch",
                                              name:   "Request",
                                              method: method,
                                              path:   path do

        # Prevent HTTP-related probes from firing
        Skylight::Core::Normalizers::Faraday::Request.disable do
          disable_skylight_probe(:NetHTTP) do
            disable_skylight_probe(:HTTPClient) do
              perform_request_without_sk(method, path, *args, &block)
            end
          end
        end
      end
    end

    def disable_skylight_probe(class_name, &block)
      klass = Probes.const_get(class_name).const_get(:Probe) rescue nil
      klass ? klass.disable(&block) : yield
    end
  end
end