Sha256: c1b58d0ce84721ccf4ced9b238061f583f3097137b4895e9aabf99e186407d72

Contents?: true

Size: 1.31 KB

Versions: 10

Compression:

Stored size: 1.31 KB

Contents

module Skylight
  module Probes
    module Elasticsearch
      class Probe
        def install
          ::Elasticsearch::Transport::Transport::Base.class_eval do
            alias 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::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 = Skylight::Probes.const_get(class_name).const_get(:Probe) rescue nil
              klass ? klass.disable(&block) : block.call
            end
          end
        end
      end
    end

    register("Elasticsearch", "elasticsearch", Elasticsearch::Probe.new)
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
skylight-1.6.1 lib/skylight/probes/elasticsearch.rb
skylight-1.6.0 lib/skylight/probes/elasticsearch.rb
skylight-1.5.1 lib/skylight/probes/elasticsearch.rb
skylight-1.5.0 lib/skylight/probes/elasticsearch.rb
skylight-1.4.4 lib/skylight/probes/elasticsearch.rb
skylight-1.4.3 lib/skylight/probes/elasticsearch.rb
skylight-1.4.2 lib/skylight/probes/elasticsearch.rb
skylight-1.4.1 lib/skylight/probes/elasticsearch.rb
skylight-1.4.0 lib/skylight/probes/elasticsearch.rb
skylight-1.4.0.beta.2 lib/skylight/probes/elasticsearch.rb