Sha256: 33e1ceafaff5bbeeeccf770383cd13e019c6f989b48ba1a01a72afd2554287dd

Contents?: true

Size: 1.22 KB

Versions: 7

Compression:

Stored size: 1.22 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
                disable_skylight_probe(:NetHTTP) do
                  disable_skylight_probe(:HTTPClient) do
                    perform_request_without_sk(method, path, *args, &block)
                  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

7 entries across 7 versions & 1 rubygems

Version Path
skylight-1.4.0.beta lib/skylight/probes/elasticsearch.rb
skylight-1.3.1 lib/skylight/probes/elasticsearch.rb
skylight-1.3.0 lib/skylight/probes/elasticsearch.rb
skylight-1.2.2 lib/skylight/probes/elasticsearch.rb
skylight-1.2.1 lib/skylight/probes/elasticsearch.rb
skylight-1.2.0 lib/skylight/probes/elasticsearch.rb
skylight-1.1.0 lib/skylight/probes/elasticsearch.rb