Sha256: 4ea0abcc1f314cd485aabd26fb7b43dfc3b61ce5a9beee26ac30caec0caaec38
Contents?: true
Size: 1.1 KB
Versions: 22
Compression:
Stored size: 1.1 KB
Contents
module Elasticity class InstrumentedClient INDICES_METHODS = %w(exists create delete get_settings get_mapping flush get_alias get_aliases put_alias delete_alias exists_alias update_aliases) INDEX_METHODS = %w(index delete get mget search count msearch scroll delete_by_query bulk) def initialize(client) @client = client end # Generate wrapper methods for @client.indices INDICES_METHODS.each do |method_name| full_name = "index_#{method_name}" define_method(full_name) do |*args, &block| instrument(full_name, args) do @client.indices.public_send(method_name, *args, &block) end end end # Generate wrapper methods for @client INDEX_METHODS.each do |method_name| define_method(method_name) do |*args, &block| instrument(method_name, args) do @client.public_send(method_name, *args, &block) end end end private def instrument(name, args) ActiveSupport::Notifications.instrument("#{name}.elasticity", args: args, backtrace: caller(1)) do yield end end end end
Version data entries
22 entries across 22 versions & 1 rubygems