Sha256: 104f2a8b09e30d544a7feb85fa3fcd174924231241bbea7e8fe3745bd2650033
Contents?: true
Size: 1.41 KB
Versions: 4
Compression:
Stored size: 1.41 KB
Contents
module Skylight module Probes module Elasticsearch class Probe def install # Prepending doesn't work here since this a module that's already been included ::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::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) 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 end end register(:elasticsearch, "Elasticsearch", "elasticsearch", Elasticsearch::Probe.new) end end
Version data entries
4 entries across 4 versions & 1 rubygems