module ActiveGraph::Core::Instrumentable

Constants

EMPTY
NEWLINE_W_SPACES

Public Instance Methods

subscribe_to_query() { |" #{CYAN}#{context || 'CYPHER'}#{CLEAR} #{cypher} #{params_string}" + ("\n ↳ #{source_line}:#{line_number}"| ... } click to toggle source
   # File lib/active_graph/core/instrumentable.rb
22 def subscribe_to_query
23   ActiveSupport::Notifications.subscribe('neo4j.core.cypher_query') do |_, _start, _finish, _id, payload|
24     query = payload[:query]
25     params_string = (query.parameters && !query.parameters.empty? ? "| #{query.parameters.inspect}" : EMPTY)
26     cypher = query.pretty_cypher ? (NEWLINE_W_SPACES if query.pretty_cypher.include?("\n")).to_s + query.pretty_cypher.gsub(/\n/, NEWLINE_W_SPACES) : query.cypher
27 
28     source_line, line_number = Logging.first_external_path_and_line(caller_locations)
29 
30     yield " #{ANSI::CYAN}#{query.context || 'CYPHER'}#{ANSI::CLEAR} #{cypher} #{params_string}" +
31       ("\n   ↳ #{source_line}:#{line_number}" if ActiveGraph::Config.fetch(:verbose_query_logs, false) && source_line).to_s
32   end
33 end
subscribe_to_request() { |" #{BLUE}BOLT:#{CLEAR} #{YELLOW}#{round}ms#{CLEAR}"| ... } click to toggle source
   # File lib/active_graph/core/instrumentable.rb
15 def subscribe_to_request
16   ActiveSupport::Notifications.subscribe('neo4j.core.bolt.request') do |_, start, finish, _id, _payload|
17     ms = (finish - start) * 1000
18     yield " #{ANSI::BLUE}BOLT:#{ANSI::CLEAR} #{ANSI::YELLOW}#{ms.round}ms#{ANSI::CLEAR}"
19   end
20 end