Class: Skylight::Probes::Elasticsearch::Probe Private
- Defined in:
- lib/skylight/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
- #install ⇒ Object private
Instance Method Details
#install ⇒ Object
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 31 32 33 34 35 36 37 38 39 |
# File 'lib/skylight/probes/elasticsearch.rb', line 5 def install const = if defined?(::Elasticsearch::Transport::Transport::Base) ::Elasticsearch::Transport::Transport::Base elsif defined?(::Elastic::Transport::Transport::Base) ::Elastic::Transport::Transport::Base else return false end # Prepending doesn't work here since this a module that's already been included const.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::Normalizers::Faraday::Request.disable do disable_skylight_probe(:NetHTTP) do disable_skylight_probe(:HTTPClient) { perform_request_without_sk(method, path, *args, &block) } end end end end def disable_skylight_probe(class_name) klass = ::ActiveSupport::Inflector.safe_constantize("Skylight::Probes::#{class_name}::Probe") (klass ? klass.disable { yield } : yield).tap { Skylight.log(:debug, "re-enabling: #{klass}") } end end end |