Class: Fluent::Plugin::ApptuitFilter

Inherits:
Filter
  • Object
show all
Defined in:
lib/fluent/plugin/filter_apptuit.rb

Instance Method Summary collapse

Instance Method Details

#filter(tag, time, record) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/fluent/plugin/filter_apptuit.rb', line 34

def filter(tag, time, record)
 begin
  fingerprint_object = FingerPrinter.new()
  if @lang.downcase == 'java'
	  if record.key?(@error_msg_tag)
      if syslog
        message = get_decoded_message(record[@error_msg_tag])
	    else
        message = record[@error_msg_tag]
      end
	    err_name, fingerprint, essence, stack = fingerprint_object.fingerprint_java(message)
	    if err_name != nil
         record['error_fingerprint'] = fingerprint 
  record['exception'] = err_name
	    end
	  end
  elsif @lang.downcase == 'python'
	   if record.key?(@error_msg_tag)
      if syslog
        message = get_decoded_message(record[@error_msg_tag])
	    else
        message = record[@error_msg_tag]
      end
	    err_name, fingerprint, essence, stack = fingerprint_object.fingerprint_python(message)
      if err_name != nil
         record['error_fingerprint'] = fingerprint 
  record['exception'] = err_name
	    end
	   end
  elsif @lang.downcase == 'nodejs'
	  if record.key?(@error_msg_tag)
      if syslog
        message = get_decoded_message(record[@error_msg_tag])
	    else
        message = record[@error_msg_tag]
      end
	    err_name, fingerprint, essence, stack = fingerprint_object.fingerprint_nodejs(message)
      if err_name != nil
         record['error_fingerprint'] = fingerprint
  record['exception'] = err_name
	    end
	  end
  else
	   return record
  end
 rescue
	return record
 end
 record
end

#get_decoded_message(message) ⇒ Object



29
30
31
32
# File 'lib/fluent/plugin/filter_apptuit.rb', line 29

def get_decoded_message(message)
	  message = message.gsub(/#([0-9]{3})/) {$1.oct.chr}    	 
  return message 
end