debian-mirror-gitlab/elasticsearch-rails/lib/elasticsearch/rails/instrumentation/railtie.rb

32 lines
1.2 KiB
Ruby
Raw Normal View History

2019-12-05 17:51:33 +05:30
module Elasticsearch
module Rails
module Instrumentation
# Rails initializer class to require Elasticsearch::Rails::Instrumentation files,
# set up Elasticsearch::Model and hook into ActionController to display Elasticsearch-related duration
#
# @see http://edgeguides.rubyonrails.org/active_support_instrumentation.html
#
class Railtie < ::Rails::Railtie
initializer "elasticsearch.instrumentation" do |app|
require 'elasticsearch/rails/instrumentation/log_subscriber'
require 'elasticsearch/rails/instrumentation/controller_runtime'
Elasticsearch::Model::Searching::SearchRequest.class_eval do
include Elasticsearch::Rails::Instrumentation::Publishers::SearchRequest
end if defined?(Elasticsearch::Model::Searching::SearchRequest)
Elasticsearch::Persistence::Model::Find::SearchRequest.class_eval do
include Elasticsearch::Rails::Instrumentation::Publishers::SearchRequest
end if defined?(Elasticsearch::Persistence::Model::Find::SearchRequest)
ActiveSupport.on_load(:action_controller) do
include Elasticsearch::Rails::Instrumentation::ControllerRuntime
end
end
end
end
end
end