Class: Appsignal::EventFormatter::ElasticSearch::SearchFormatter

Inherits:
Appsignal::EventFormatter show all
Defined in:
lib/appsignal/event_formatter/elastic_search/search_formatter.rb

Constant Summary

Constants inherited from Appsignal::EventFormatter

DEFAULT, SQL_BODY_FORMAT

Instance Method Summary collapse

Methods inherited from Appsignal::EventFormatter

format, formatter_classes, formatters, initialize_formatters, register, registered?, unregister

Instance Method Details

#format(payload) ⇒ Object



7
8
9
10
11
12
# File 'lib/appsignal/event_formatter/elastic_search/search_formatter.rb', line 7

def format(payload)
  [
    "#{payload[:name]}: #{payload[:klass]}",
    sanitized_search(payload[:search]).inspect
  ]
end

#sanitized_search(search) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/appsignal/event_formatter/elastic_search/search_formatter.rb', line 14

def sanitized_search(search)
  return nil unless search.is_a?(Hash)
  {}.tap do |hsh|
    search.each do |key, val|
      if [:index, :type].include?(key)
        hsh[key] = val
      else
        hsh[key] = Appsignal::Utils::QueryParamsSanitizer.sanitize(val)
      end
    end
  end
end