module Turnstile::Collector::Formats::JsonMatcher

Extracts from the log file of the form: {“method”:“GET”,“path”:“/api/v1/saves/4SB8U-1Am9u-4ixC5”,“format”:“json”,“duration”:49.01,.….}

Public Instance Methods

json_matcher(*_args) click to toggle source
# File lib/turnstile/collector/formats/json_matcher.rb, line 10
def json_matcher(*_args)
  @json_matcher ||= ::Turnstile::Collector::RegexpMatcher.new(%r{"ip_address":"\d+},
                                                              ->(line) {
                                                                begin
                                                                  data = JSON.parse(line)
                                                                  [
                                                                      data['platform'],
                                                                      data['ip_address'],
                                                                      data['user_id']
                                                                  ].join(':')
                                                                rescue
                                                                  nil
                                                                end
                                                              })
end