fluent-plugin-group-exceptions 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,141 @@
1
+ #
2
+ # Copyright 2016 Google Inc. All rights reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ require 'fluent/plugin/exception_detector'
17
+ require 'fluent/output'
18
+
19
+ module Fluent
20
+ # This output plugin consumes a log stream of JSON objects which contain
21
+ # single-line log messages. If a consecutive sequence of log messages form
22
+ # an exception stack trace, they forwarded as a single, combined JSON
23
+ # object. Otherwise, the input log data is forwarded as is.
24
+ class DetectExceptionsOutput < Output
25
+ desc 'The prefix to be removed from the input tag when outputting a record.'
26
+ config_param :remove_tag_prefix, :string
27
+ desc 'The field which contains the raw message text in the input JSON data.'
28
+ config_param :message, :string, default: ''
29
+ desc 'The interval of flushing the buffer for multiline format.'
30
+ config_param :multiline_flush_interval, :time, default: nil
31
+ desc 'Programming languages for which to detect exceptions. Default: all.'
32
+ config_param :languages, :array, value_type: :string, default: []
33
+ desc 'Maximum number of lines to flush (0 means no limit). Default: 1000.'
34
+ config_param :max_lines, :integer, default: 1000
35
+ desc 'Maximum number of bytes to flush (0 means no limit). Default: 0.'
36
+ config_param :max_bytes, :integer, default: 0
37
+ desc 'Separate log streams by this field in the input JSON data.'
38
+ config_param :stream, :string, default: ''
39
+
40
+ Fluent::Plugin.register_output('group_exceptions', self)
41
+
42
+ def configure(conf)
43
+ super
44
+
45
+ if multiline_flush_interval
46
+ @check_flush_interval = [multiline_flush_interval * 0.1, 1].max
47
+ end
48
+
49
+ @languages = languages.map(&:to_sym)
50
+
51
+ # Maps log stream tags to a corresponding TraceAccumulator.
52
+ @accumulators = {}
53
+ end
54
+
55
+ def multi_workers_ready?
56
+ true
57
+ end
58
+
59
+ def start
60
+ super
61
+
62
+ if multiline_flush_interval
63
+ @flush_buffer_mutex = Mutex.new
64
+ @stop_check = false
65
+ @thread = Thread.new(&method(:check_flush_loop))
66
+ end
67
+ end
68
+
69
+ def before_shutdown
70
+ flush_buffers
71
+ super if defined?(super)
72
+ end
73
+
74
+ def shutdown
75
+ # Before shutdown is not available in older fluentd versions.
76
+ # Hence, we make sure that we flush the buffers here as well.
77
+ flush_buffers
78
+ @thread.join if @multiline_flush_interval
79
+ super
80
+ end
81
+
82
+ def emit(tag, es, chain)
83
+ es.each do |time_sec, record|
84
+ process_record(tag, time_sec, record)
85
+ end
86
+ chain.next
87
+ end
88
+
89
+ private
90
+
91
+ def process_record(tag, time_sec, record)
92
+ synchronize do
93
+ log_id = [tag]
94
+ log_id.push(record.fetch(@stream, '')) unless @stream.empty?
95
+ unless @accumulators.key?(log_id)
96
+ out_tag = tag.sub(/^#{Regexp.escape(@remove_tag_prefix)}\./, '')
97
+ @accumulators[log_id] =
98
+ Fluent::TraceAccumulator.new(@message, @languages,
99
+ max_lines: @max_lines,
100
+ max_bytes: @max_bytes) do |t, r|
101
+ router.emit(out_tag, t, r)
102
+ end
103
+ end
104
+
105
+ @accumulators[log_id].push(time_sec, record)
106
+ end
107
+ end
108
+
109
+ def flush_buffers
110
+ synchronize do
111
+ @stop_check = true
112
+ @accumulators.each_value(&:force_flush)
113
+ end
114
+ end
115
+
116
+ def check_flush_loop
117
+ @flush_buffer_mutex.synchronize do
118
+ loop do
119
+ @flush_buffer_mutex.sleep(@check_flush_interval)
120
+ now = Time.now
121
+ break if @stop_check
122
+ @accumulators.each_value do |acc|
123
+ acc.force_flush if now - acc.buffer_start_time >
124
+ @multiline_flush_interval
125
+ end
126
+ end
127
+ end
128
+ rescue
129
+ log.error 'error in check_flush_loop', error: $ERROR_INFO.to_s
130
+ log.error_backtrace
131
+ end
132
+
133
+ def synchronize(&block)
134
+ if @multiline_flush_interval
135
+ @flush_buffer_mutex.synchronize(&block)
136
+ else
137
+ yield
138
+ end
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,46 @@
1
+ # Copyright 2016 Google Inc. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'rubygems'
16
+ require 'bundler'
17
+
18
+ begin
19
+ Bundler.setup(:default, :development)
20
+ rescue Bundler::BundlerError => e
21
+ $stderr.puts e.message
22
+ $stderr.puts 'Run `bundle install` to install missing gems'
23
+ exit e.status_code
24
+ end
25
+
26
+ require 'test/unit'
27
+
28
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
29
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
30
+ require 'fluent/test'
31
+
32
+ unless ENV.key?('VERBOSE')
33
+ nulllogger = Object.new
34
+ nulllogger.instance_eval do |_|
35
+ def respond_to_missing?
36
+ true
37
+ end
38
+
39
+ def method_missing(_method, *_args) # rubocop:disable Style/MethodMissing
40
+ end
41
+ end
42
+ # global $log variable is used by fluentd
43
+ $log = nulllogger # rubocop:disable Style/GlobalVars
44
+ end
45
+
46
+ require 'fluent/plugin/out_detect_exceptions'
@@ -0,0 +1,73 @@
1
+ # Copyright 2016 Google Inc. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'benchmark'
16
+
17
+ require 'fluent/plugin/exception_detector'
18
+
19
+ size_in_m = 25
20
+ line_length = 50
21
+
22
+ size = size_in_m << 20
23
+
24
+ JAVA_EXC = <<END.freeze
25
+ Jul 09, 2015 3:23:29 PM com.google.devtools.search.cloud.feeder.MakeLog: RuntimeException: Run from this message!
26
+ at com.my.app.Object.do$a1(MakeLog.java:50)
27
+ at java.lang.Thing.call(Thing.java:10)
28
+ at com.my.app.Object.help(MakeLog.java:40)
29
+ at sun.javax.API.method(API.java:100)
30
+ at com.jetty.Framework.main(MakeLog.java:30)
31
+ END
32
+
33
+ PYTHON_EXC = <<END.freeze
34
+ Traceback (most recent call last):
35
+ File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1535, in __call__
36
+ rv = self.handle_exception(request, response, e)
37
+ File "/base/data/home/apps/s~nearfieldspy/1.378705245900539993/nearfieldspy.py", line 17, in start
38
+ return get()
39
+ File "/base/data/home/apps/s~nearfieldspy/1.378705245900539993/nearfieldspy.py", line 5, in get
40
+ raise Exception('spam', 'eggs')
41
+ Exception: ('spam', 'eggs')
42
+ END
43
+
44
+ chars = [('a'..'z'), ('A'..'Z')].map(&:to_a).flatten
45
+
46
+ random_text = (1..(size / line_length)).collect do
47
+ (0...line_length).map { chars[rand(chars.length)] }.join
48
+ end
49
+
50
+ exceptions = {
51
+ java: (JAVA_EXC * (size / JAVA_EXC.length)).lines,
52
+ python: (PYTHON_EXC * (size / PYTHON_EXC.length)).lines
53
+ }
54
+
55
+ puts "Start benchmark. Input size #{size_in_m}M."
56
+ Benchmark.bm do |x|
57
+ languages = Fluent::ExceptionDetectorConfig::RULES_BY_LANG.keys
58
+ languages.each do |lang|
59
+ buffer = Fluent::TraceAccumulator.new(nil, lang) {}
60
+ x.report("#{lang}_detector_random_text") do
61
+ random_text.each { |l| buffer.push(0, l) }
62
+ end
63
+ end
64
+ [:java, :python, :all].each do |detector_lang|
65
+ buffer = Fluent::TraceAccumulator.new(nil, detector_lang) {}
66
+ exc_languages = detector_lang == :all ? exceptions.keys : [detector_lang]
67
+ exc_languages.each do |exc_lang|
68
+ x.report("#{detector_lang}_detector_#{exc_lang}_stacks") do
69
+ exceptions[exc_lang].each { |l| buffer.push(0, l) }
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,849 @@
1
+ # Copyright 2016 Google Inc. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require_relative '../helper'
16
+ require 'fluent/plugin/exception_detector'
17
+
18
+ class ExceptionDetectorTest < Test::Unit::TestCase
19
+ JAVA_EXC_PART1 = <<END.freeze
20
+ Jul 09, 2015 3:23:29 PM com.google.devtools.search.cloud.feeder.MakeLog: RuntimeException: Run from this message!
21
+ at com.my.app.Object.do$a1(MakeLog.java:50)
22
+ at java.lang.Thing.call(Thing.java:10)
23
+ END
24
+
25
+ JAVA_EXC_PART2 = <<END.freeze
26
+ at com.my.app.Object.help(MakeLog.java:40)
27
+ at sun.javax.API.method(API.java:100)
28
+ at com.jetty.Framework.main(MakeLog.java:30)
29
+ END
30
+
31
+ JAVA_EXC = (JAVA_EXC_PART1 + JAVA_EXC_PART2).freeze
32
+
33
+ COMPLEX_JAVA_EXC = <<END.freeze
34
+ javax.servlet.ServletException: Something bad happened
35
+ at com.example.myproject.OpenSessionInViewFilter.doFilter(OpenSessionInViewFilter.java:60)
36
+ at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
37
+ at com.example.myproject.ExceptionHandlerFilter.doFilter(ExceptionHandlerFilter.java:28)
38
+ at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
39
+ at com.example.myproject.OutputBufferFilter.doFilter(OutputBufferFilter.java:33)
40
+ at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
41
+ at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
42
+ at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
43
+ at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
44
+ at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
45
+ at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
46
+ at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
47
+ at org.mortbay.jetty.Server.handle(Server.java:326)
48
+ at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
49
+ at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:943)
50
+ at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
51
+ at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
52
+ at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
53
+ at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
54
+ at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
55
+ Caused by: com.example.myproject.MyProjectServletException
56
+ at com.example.myproject.MyServlet.doPost(MyServlet.java:169)
57
+ at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
58
+ at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
59
+ at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
60
+ at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
61
+ at com.example.myproject.OpenSessionInViewFilter.doFilter(OpenSessionInViewFilter.java:30)
62
+ ... 27 common frames omitted
63
+ END
64
+
65
+ NESTED_JAVA_EXC = <<END.freeze
66
+ java.lang.RuntimeException: javax.mail.SendFailedException: Invalid Addresses;
67
+ nested exception is:
68
+ com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 <[REDACTED_EMAIL_ADDRESS]>... Relaying denied
69
+
70
+ at com.nethunt.crm.api.server.adminsync.AutomaticEmailFacade.sendWithSmtp(AutomaticEmailFacade.java:236)
71
+ at com.nethunt.crm.api.server.adminsync.AutomaticEmailFacade.sendSingleEmail(AutomaticEmailFacade.java:285)
72
+ at com.nethunt.crm.api.server.adminsync.AutomaticEmailFacade.lambda$sendSingleEmail$3(AutomaticEmailFacade.java:254)
73
+ at java.util.Optional.ifPresent(Optional.java:159)
74
+ at com.nethunt.crm.api.server.adminsync.AutomaticEmailFacade.sendSingleEmail(AutomaticEmailFacade.java:253)
75
+ at com.nethunt.crm.api.server.adminsync.AutomaticEmailFacade.sendSingleEmail(AutomaticEmailFacade.java:249)
76
+ at com.nethunt.crm.api.email.EmailSender.lambda$notifyPerson$0(EmailSender.java:80)
77
+ at com.nethunt.crm.api.util.ManagedExecutor.lambda$execute$0(ManagedExecutor.java:36)
78
+ at com.nethunt.crm.api.util.RequestContextActivator.lambda$withRequestContext$0(RequestContextActivator.java:36)
79
+ at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
80
+ at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
81
+ at java.base/java.lang.Thread.run(Thread.java:748)
82
+ Caused by: javax.mail.SendFailedException: Invalid Addresses;
83
+ nested exception is:
84
+ com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 <[REDACTED_EMAIL_ADDRESS]>... Relaying denied
85
+
86
+ at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:2064)
87
+ at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1286)
88
+ at com.nethunt.crm.api.server.adminsync.AutomaticEmailFacade.sendWithSmtp(AutomaticEmailFacade.java:229)
89
+ ... 12 more
90
+ Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 <[REDACTED_EMAIL_ADDRESS]>... Relaying denied
91
+ END
92
+
93
+ NODE_JS_EXC = <<END.freeze
94
+ ReferenceError: myArray is not defined
95
+ at next (/app/node_modules/express/lib/router/index.js:256:14)
96
+ at /app/node_modules/express/lib/router/index.js:615:15
97
+ at next (/app/node_modules/express/lib/router/index.js:271:10)
98
+ at Function.process_params (/app/node_modules/express/lib/router/index.js:330:12)
99
+ at /app/node_modules/express/lib/router/index.js:277:22
100
+ at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
101
+ at Route.dispatch (/app/node_modules/express/lib/router/route.js:112:3)
102
+ at next (/app/node_modules/express/lib/router/route.js:131:13)
103
+ at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
104
+ at /app/app.js:52:3
105
+ END
106
+
107
+ CLIENT_JS_EXC = <<END.freeze
108
+ Error
109
+ at bls (<anonymous>:3:9)
110
+ at <anonymous>:6:4
111
+ at a_function_name
112
+ at Object.InjectedScript._evaluateOn (http://<anonymous>/file.js?foo=bar:875:140)
113
+ at Object.InjectedScript.evaluate (<anonymous>)
114
+ END
115
+
116
+ V8_JS_EXC = <<END.freeze
117
+ V8 errors stack trace
118
+ eval at Foo.a (eval at Bar.z (myscript.js:10:3))
119
+ at new Contructor.Name (native)
120
+ at new FunctionName (unknown location)
121
+ at Type.functionName [as methodName] (file(copy).js?query='yes':12:9)
122
+ at functionName [as methodName] (native)
123
+ at Type.main(sample(copy).js:6:4)
124
+ END
125
+
126
+ PYTHON_EXC = <<END.freeze
127
+ Traceback (most recent call last):
128
+ File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1535, in __call__
129
+ rv = self.handle_exception(request, response, e)
130
+ File "/base/data/home/apps/s~nearfieldspy/1.378705245900539993/nearfieldspy.py", line 17, in start
131
+ return get()
132
+ File "/base/data/home/apps/s~nearfieldspy/1.378705245900539993/nearfieldspy.py", line 5, in get
133
+ raise Exception('spam', 'eggs')
134
+ Exception: ('spam', 'eggs')
135
+ END
136
+
137
+ PHP_EXC = <<END.freeze
138
+ exception 'Exception' with message 'Custom exception' in /home/joe/work/test-php/test.php:5
139
+ Stack trace:
140
+ #0 /home/joe/work/test-php/test.php(9): func1()
141
+ #1 /home/joe/work/test-php/test.php(13): func2()
142
+ #2 {main}
143
+ END
144
+
145
+ PHP_ON_GAE_EXC = <<END.freeze
146
+ PHP Fatal error: Uncaught exception 'Exception' with message 'message' in /base/data/home/apps/s~crash-example-php/1.388306779641080894/errors.php:60
147
+ Stack trace:
148
+ #0 [internal function]: ErrorEntryGenerator::{closure}()
149
+ #1 /base/data/home/apps/s~crash-example-php/1.388306779641080894/errors.php(20): call_user_func_array(Object(Closure), Array)
150
+ #2 /base/data/home/apps/s~crash-example-php/1.388306779641080894/index.php(36): ErrorEntry->__call('raise', Array)
151
+ #3 /base/data/home/apps/s~crash-example-php/1.388306779641080894/index.php(36): ErrorEntry->raise()
152
+ #4 {main}
153
+ thrown in /base/data/home/apps/s~crash-example-php/1.388306779641080894/errors.php on line 60
154
+ END
155
+
156
+ GO_EXC = <<END.freeze
157
+ panic: my panic
158
+
159
+ goroutine 4 [running]:
160
+ panic(0x45cb40, 0x47ad70)
161
+ /usr/local/go/src/runtime/panic.go:542 +0x46c fp=0xc42003f7b8 sp=0xc42003f710 pc=0x422f7c
162
+ main.main.func1(0xc420024120)
163
+ foo.go:6 +0x39 fp=0xc42003f7d8 sp=0xc42003f7b8 pc=0x451339
164
+ runtime.goexit()
165
+ /usr/local/go/src/runtime/asm_amd64.s:2337 +0x1 fp=0xc42003f7e0 sp=0xc42003f7d8 pc=0x44b4d1
166
+ created by main.main
167
+ foo.go:5 +0x58
168
+
169
+ goroutine 1 [chan receive]:
170
+ runtime.gopark(0x4739b8, 0xc420024178, 0x46fcd7, 0xc, 0xc420028e17, 0x3)
171
+ /usr/local/go/src/runtime/proc.go:280 +0x12c fp=0xc420053e30 sp=0xc420053e00 pc=0x42503c
172
+ runtime.goparkunlock(0xc420024178, 0x46fcd7, 0xc, 0x1000f010040c217, 0x3)
173
+ /usr/local/go/src/runtime/proc.go:286 +0x5e fp=0xc420053e70 sp=0xc420053e30 pc=0x42512e
174
+ runtime.chanrecv(0xc420024120, 0x0, 0xc420053f01, 0x4512d8)
175
+ /usr/local/go/src/runtime/chan.go:506 +0x304 fp=0xc420053f20 sp=0xc420053e70 pc=0x4046b4
176
+ runtime.chanrecv1(0xc420024120, 0x0)
177
+ /usr/local/go/src/runtime/chan.go:388 +0x2b fp=0xc420053f50 sp=0xc420053f20 pc=0x40439b
178
+ main.main()
179
+ foo.go:9 +0x6f fp=0xc420053f80 sp=0xc420053f50 pc=0x4512ef
180
+ runtime.main()
181
+ /usr/local/go/src/runtime/proc.go:185 +0x20d fp=0xc420053fe0 sp=0xc420053f80 pc=0x424bad
182
+ runtime.goexit()
183
+ /usr/local/go/src/runtime/asm_amd64.s:2337 +0x1 fp=0xc420053fe8 sp=0xc420053fe0 pc=0x44b4d1
184
+
185
+ goroutine 2 [force gc (idle)]:
186
+ runtime.gopark(0x4739b8, 0x4ad720, 0x47001e, 0xf, 0x14, 0x1)
187
+ /usr/local/go/src/runtime/proc.go:280 +0x12c fp=0xc42003e768 sp=0xc42003e738 pc=0x42503c
188
+ runtime.goparkunlock(0x4ad720, 0x47001e, 0xf, 0xc420000114, 0x1)
189
+ /usr/local/go/src/runtime/proc.go:286 +0x5e fp=0xc42003e7a8 sp=0xc42003e768 pc=0x42512e
190
+ runtime.forcegchelper()
191
+ /usr/local/go/src/runtime/proc.go:238 +0xcc fp=0xc42003e7e0 sp=0xc42003e7a8 pc=0x424e5c
192
+ runtime.goexit()
193
+ /usr/local/go/src/runtime/asm_amd64.s:2337 +0x1 fp=0xc42003e7e8 sp=0xc42003e7e0 pc=0x44b4d1
194
+ created by runtime.init.4
195
+ /usr/local/go/src/runtime/proc.go:227 +0x35
196
+
197
+ goroutine 3 [GC sweep wait]:
198
+ runtime.gopark(0x4739b8, 0x4ad7e0, 0x46fdd2, 0xd, 0x419914, 0x1)
199
+ /usr/local/go/src/runtime/proc.go:280 +0x12c fp=0xc42003ef60 sp=0xc42003ef30 pc=0x42503c
200
+ runtime.goparkunlock(0x4ad7e0, 0x46fdd2, 0xd, 0x14, 0x1)
201
+ /usr/local/go/src/runtime/proc.go:286 +0x5e fp=0xc42003efa0 sp=0xc42003ef60 pc=0x42512e
202
+ runtime.bgsweep(0xc42001e150)
203
+ /usr/local/go/src/runtime/mgcsweep.go:52 +0xa3 fp=0xc42003efd8 sp=0xc42003efa0 pc=0x419973
204
+ runtime.goexit()
205
+ /usr/local/go/src/runtime/asm_amd64.s:2337 +0x1 fp=0xc42003efe0 sp=0xc42003efd8 pc=0x44b4d1
206
+ created by runtime.gcenable
207
+ /usr/local/go/src/runtime/mgc.go:216 +0x58
208
+ END
209
+
210
+ GO_ON_GAE_EXC = <<END.freeze
211
+ panic: runtime error: index out of range
212
+
213
+ goroutine 12 [running]:
214
+ main88989.memoryAccessException()
215
+ crash_example_go.go:58 +0x12a
216
+ main88989.handler(0x2afb7042a408, 0xc01042f880, 0xc0104d3450)
217
+ crash_example_go.go:36 +0x7ec
218
+ net/http.HandlerFunc.ServeHTTP(0x13e5128, 0x2afb7042a408, 0xc01042f880, 0xc0104d3450)
219
+ go/src/net/http/server.go:1265 +0x56
220
+ net/http.(*ServeMux).ServeHTTP(0xc01045cab0, 0x2afb7042a408, 0xc01042f880, 0xc0104d3450)
221
+ go/src/net/http/server.go:1541 +0x1b4
222
+ appengine_internal.executeRequestSafely(0xc01042f880, 0xc0104d3450)
223
+ go/src/appengine_internal/api_prod.go:288 +0xb7
224
+ appengine_internal.(*server).HandleRequest(0x15819b0, 0xc010401560, 0xc0104c8180, 0xc010431380, 0x0, 0x0)
225
+ go/src/appengine_internal/api_prod.go:222 +0x102b
226
+ reflect.Value.call(0x1243fe0, 0x15819b0, 0x113, 0x12c8a20, 0x4, 0xc010485f78, 0x3, 0x3, 0x0, 0x0, ...)
227
+ /tmp/appengine/go/src/reflect/value.go:419 +0x10fd
228
+ reflect.Value.Call(0x1243fe0, 0x15819b0, 0x113, 0xc010485f78, 0x3, 0x3, 0x0, 0x0, 0x0)
229
+ /tmp/ap
230
+ END
231
+
232
+ GO_SIGNAL_EXC = <<END.freeze
233
+ panic: runtime error: invalid memory address or nil pointer dereference
234
+ [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x7fd34f]
235
+
236
+ goroutine 5 [running]:
237
+ panics.nilPtrDereference()
238
+ panics/panics.go:33 +0x1f
239
+ panics.Wait()
240
+ panics/panics.go:16 +0x3b
241
+ created by main.main
242
+ server.go:20 +0x91
243
+ END
244
+
245
+ GO_HTTP = <<END.freeze
246
+ 2019/01/15 07:48:05 http: panic serving [::1]:54143: test panic
247
+ goroutine 24 [running]:
248
+ net/http.(*conn).serve.func1(0xc00007eaa0)
249
+ /usr/local/go/src/net/http/server.go:1746 +0xd0
250
+ panic(0x12472a0, 0x12ece10)
251
+ /usr/local/go/src/runtime/panic.go:513 +0x1b9
252
+ main.doPanic(0x12f0ea0, 0xc00010e1c0, 0xc000104400)
253
+ /Users/ingvar/src/go/src/httppanic.go:8 +0x39
254
+ net/http.HandlerFunc.ServeHTTP(0x12be2e8, 0x12f0ea0, 0xc00010e1c0, 0xc000104400)
255
+ /usr/local/go/src/net/http/server.go:1964 +0x44
256
+ net/http.(*ServeMux).ServeHTTP(0x14a17a0, 0x12f0ea0, 0xc00010e1c0, 0xc000104400)
257
+ /usr/local/go/src/net/http/server.go:2361 +0x127
258
+ net/http.serverHandler.ServeHTTP(0xc000085040, 0x12f0ea0, 0xc00010e1c0, 0xc000104400)
259
+ /usr/local/go/src/net/http/server.go:2741 +0xab
260
+ net/http.(*conn).serve(0xc00007eaa0, 0x12f10a0, 0xc00008a780)
261
+ /usr/local/go/src/net/http/server.go:1847 +0x646
262
+ created by net/http.(*Server).Serve
263
+ /usr/local/go/src/net/http/server.go:2851 +0x2f5
264
+ END
265
+ CSHARP_EXC = <<END.freeze
266
+ System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
267
+ at System.Collections.Generic.Dictionary`2[System.String,System.Collections.Generic.Dictionary`2[System.Int32,System.Double]].get_Item (System.String key) [0x00000] in <filename unknown>:0
268
+ at File3.Consolidator_Class.Function5 (System.Collections.Generic.Dictionary`2 names, System.Text.StringBuilder param_4) [0x00007] in /usr/local/google/home/Csharp/another file.csharp:9
269
+ at File3.Consolidator_Class.Function4 (System.Text.StringBuilder param_4, System.Double[,,] array) [0x00013] in /usr/local/google/home/Csharp/another file.csharp:23
270
+ at File3.Consolidator_Class.Function3 (Int32 param_3) [0x0000f] in /usr/local/google/home/Csharp/another file.csharp:27
271
+ at File3.Consolidator_Class.Function3 (System.Text.StringBuilder param_3) [0x00007] in /usr/local/google/home/Csharp/another file.csharp:32
272
+ at File2.Processor.Function2 (System.Int32& param_2, System.Collections.Generic.Stack`1& numbers) [0x00003] in /usr/local/google/home/Csharp/File2.csharp:19
273
+ at File2.Processor.Random2 () [0x00037] in /usr/local/google/home/Csharp/File2.csharp:28
274
+ at File2.Processor.Function1 (Int32 param_1, System.Collections.Generic.Dictionary`2 map) [0x00007] in /usr/local/google/home/Csharp/File2.csharp:34
275
+ at Main.Welcome+<Main>c__AnonStorey0.<>m__0 () [0x00006] in /usr/local/google/home/Csharp/hello.csharp:48
276
+ at System.Threading.Thread.StartInternal () [0x00000] in <filename unknown>:0
277
+ END
278
+
279
+ CSHARP_NESTED_EXC = <<END.freeze
280
+ System.InvalidOperationException: This is the outer exception ---> System.InvalidOperationException: This is the inner exception
281
+ at ExampleApp.NestedExceptionExample.LowestLevelMethod() in c:/ExampleApp/ExampleApp/NestedExceptionExample.cs:line 33
282
+ at ExampleApp.NestedExceptionExample.ThirdLevelMethod() in c:/ExampleApp/ExampleApp/NestedExceptionExample.cs:line 28
283
+ at ExampleApp.NestedExceptionExample.SecondLevelMethod() in c:/ExampleApp/ExampleApp/NestedExceptionExample.cs:line 18
284
+ --- End of inner exception stack trace ---
285
+ at ExampleApp.NestedExceptionExample.SecondLevelMethod() in c:/ExampleApp/ExampleApp/NestedExceptionExample.cs:line 22
286
+ at ExampleApp.NestedExceptionExample.TopLevelMethod() in c:/ExampleApp/ExampleApp/NestedExceptionExample.cs:line 11
287
+ at ExampleApp.Program.Main(String[] args) in c:/ExampleApp/ExampleApp/Program.cs:line 11
288
+ END
289
+
290
+ CSHARP_ASYNC_EXC = <<END.freeze
291
+ System.InvalidOperationException: This is an exception
292
+ at ExampleApp2.AsyncExceptionExample.LowestLevelMethod() in c:/ExampleApp/ExampleApp/AsyncExceptionExample.cs:line 36
293
+ at ExampleApp2.AsyncExceptionExample.<ThirdLevelMethod>d__2.MoveNext() in c:/ExampleApp/ExampleApp/AsyncExceptionExample.cs:line 31
294
+ --- End of stack trace from previous location where exception was thrown ---
295
+ at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
296
+ at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
297
+ at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
298
+ at ExampleApp2.AsyncExceptionExample.<SecondLevelMethod>d__1.MoveNext() in c:/ExampleApp/ExampleApp/AsyncExceptionExample.cs:line 25
299
+ --- End of stack trace from previous location where exception was thrown ---
300
+ at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
301
+ at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
302
+ at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
303
+ at ExampleApp2.AsyncExceptionExample.<TopLevelMethod>d__0.MoveNext() in c:/ExampleApp/ExampleApp/AsyncExceptionExample.cs:line 14
304
+ END
305
+
306
+ RUBY_EXC = <<END.freeze
307
+ NoMethodError (undefined method `resursivewordload' for #<BooksController:0x007f8dd9a0c738>):
308
+ app/controllers/books_controller.rb:69:in `recursivewordload'
309
+ app/controllers/books_controller.rb:75:in `loadword'
310
+ app/controllers/books_controller.rb:79:in `loadline'
311
+ app/controllers/books_controller.rb:83:in `loadparagraph'
312
+ app/controllers/books_controller.rb:87:in `loadpage'
313
+ app/controllers/books_controller.rb:91:in `onload'
314
+ app/controllers/books_controller.rb:95:in `loadrecursive'
315
+ app/controllers/books_controller.rb:99:in `requestload'
316
+ app/controllers/books_controller.rb:118:in `generror'
317
+ config/error_reporting_logger.rb:62:in `tagged'
318
+ END
319
+
320
+ # The whitespace on the second line is significant.
321
+ # rubocop:disable TrailingWhitespace
322
+ RAILS_EXC = <<END.freeze
323
+ ActionController::RoutingError (No route matches [GET] "/settings"):
324
+
325
+ actionpack (5.1.4) lib/action_dispatch/middleware/debug_exceptions.rb:63:in `call'
326
+ actionpack (5.1.4) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
327
+ railties (5.1.4) lib/rails/rack/logger.rb:36:in `call_app'
328
+ railties (5.1.4) lib/rails/rack/logger.rb:24:in `block in call'
329
+ activesupport (5.1.4) lib/active_support/tagged_logging.rb:69:in `block in tagged'
330
+ activesupport (5.1.4) lib/active_support/tagged_logging.rb:26:in `tagged'
331
+ activesupport (5.1.4) lib/active_support/tagged_logging.rb:69:in `tagged'
332
+ railties (5.1.4) lib/rails/rack/logger.rb:24:in `call'
333
+ actionpack (5.1.4) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
334
+ actionpack (5.1.4) lib/action_dispatch/middleware/request_id.rb:25:in `call'
335
+ rack (2.0.3) lib/rack/method_override.rb:22:in `call'
336
+ rack (2.0.3) lib/rack/runtime.rb:22:in `call'
337
+ activesupport (5.1.4) lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call'
338
+ actionpack (5.1.4) lib/action_dispatch/middleware/executor.rb:12:in `call'
339
+ rack (2.0.3) lib/rack/sendfile.rb:111:in `call'
340
+ railties (5.1.4) lib/rails/engine.rb:522:in `call'
341
+ puma (3.10.0) lib/puma/configuration.rb:225:in `call'
342
+ puma (3.10.0) lib/puma/server.rb:605:in `handle_request'
343
+ puma (3.10.0) lib/puma/server.rb:437:in `process_client'
344
+ puma (3.10.0) lib/puma/server.rb:301:in `block in run'
345
+ puma (3.10.0) lib/puma/thread_pool.rb:120:in `block in spawn_thread'
346
+ END
347
+
348
+ DART_ERR = <<END.freeze
349
+ Unhandled exception:
350
+ Instance of 'MyError'
351
+ #0 main.<anonymous closure> (file:///path/to/code/dartFile.dart:15:20)
352
+ #1 printError (file:///path/to/code/dartFile.dart:37:13)
353
+ #2 main (file:///path/to/code/dartFile.dart:15:3)
354
+ #3 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:265)
355
+ #4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)
356
+ END
357
+
358
+ DART_EXC = <<END.freeze
359
+ Unhandled exception:
360
+ Exception: exception message
361
+ #0 main.<anonymous closure> (file:///path/to/code/dartFile.dart:17:20)
362
+ #1 printError (file:///path/to/code/dartFile.dart:37:13)
363
+ #2 main (file:///path/to/code/dartFile.dart:17:3)
364
+ #3 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:265)
365
+ #4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)
366
+ END
367
+
368
+ DART_ASYNC_ERR = <<END.freeze
369
+ Unhandled exception:
370
+ Bad state: oops
371
+ #0 handleFailure (file:///test/example/http/handling_an_httprequest_error.dart:16:3)
372
+ #1 main (file:///test/example/http/handling_an_httprequest_error.dart:24:5)
373
+ <asynchronous suspension>
374
+ #2 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:265)
375
+ #3 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)
376
+ END
377
+
378
+ DART_DIVIDE_BY_ZERO_ERR = <<END.freeze
379
+ Unhandled exception:
380
+ IntegerDivisionByZeroException
381
+ #0 main.<anonymous closure> (file:///path/to/code/dartFile.dart:27:20)
382
+ #1 printError (file:///path/to/code/dartFile.dart:42:13)
383
+ #2 main (file:///path/to/code/dartFile.dart:27:3)
384
+ #3 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:265)
385
+ #4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)
386
+ END
387
+
388
+ DART_ARGUMENT_ERR = <<END.freeze
389
+ Unhandled exception:
390
+ Invalid argument(s): invalid argument
391
+ #0 main.<anonymous closure> (file:///path/to/code/dartFile.dart:23:20)
392
+ #1 printError (file:///path/to/code/dartFile.dart:42:13)
393
+ #2 main (file:///path/to/code/dartFile.dart:23:3)
394
+ #3 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:265)
395
+ #4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)
396
+ END
397
+
398
+ DART_RANGE_ERR = <<END.freeze
399
+ Unhandled exception:
400
+ RangeError (index): Invalid value: Valid value range is empty: 1
401
+ #0 List.[] (dart:core-patch/growable_array.dart:151)
402
+ #1 main.<anonymous closure> (file:///path/to/code/dartFile.dart:31:23)
403
+ #2 printError (file:///path/to/code/dartFile.dart:42:13)
404
+ #3 main (file:///path/to/code/dartFile.dart:29:3)
405
+ #4 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:265)
406
+ #5 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)
407
+ END
408
+
409
+ DART_ASSERTION_ERR = <<END.freeze
410
+ Unhandled exception:
411
+ Assertion failed
412
+ #0 main.<anonymous closure> (file:///path/to/code/dartFile.dart:9:20)
413
+ #1 printError (file:///path/to/code/dartFile.dart:36:13)
414
+ #2 main (file:///path/to/code/dartFile.dart:9:3)
415
+ #3 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:265)
416
+ #4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)
417
+ END
418
+
419
+ DART_ABSTRACT_CLASS_ERR = <<END.freeze
420
+ Unhandled exception:
421
+ Cannot instantiate abstract class LNClassName: _url 'null' line null
422
+ #0 main.<anonymous closure> (file:///path/to/code/dartFile.dart:12:20)
423
+ #1 printError (file:///path/to/code/dartFile.dart:36:13)
424
+ #2 main (file:///path/to/code/dartFile.dart:12:3)
425
+ #3 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:265)
426
+ #4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)
427
+ END
428
+
429
+ DART_READ_STATIC_ERR = <<END.freeze
430
+ Unhandled exception:
431
+ Reading static variable 'variable' during its initialization
432
+ #0 main.<anonymous closure> (file:///path/to/code/dartFile.dart:28:20)
433
+ #1 printError (file:///path/to/code/dartFile.dart:43:13)
434
+ #2 main (file:///path/to/code/dartFile.dart:28:3)
435
+ #3 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:265)
436
+ #4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)
437
+ END
438
+
439
+ DART_UNIMPLEMENTED_ERROR = <<END.freeze
440
+ Unhandled exception:
441
+ UnimplementedError: unimplemented
442
+ #0 main.<anonymous closure> (file:///path/to/code/dartFile.dart:38:20)
443
+ #1 printError (file:///path/to/code/dartFile.dart:61:13)
444
+ #2 main (file:///path/to/code/dartFile.dart:38:3)
445
+ #3 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:265)
446
+ #4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)
447
+ END
448
+
449
+ DART_UNSUPPORTED_ERR = <<END.freeze
450
+ Unhandled exception:
451
+ Unsupported operation: unsupported
452
+ #0 main.<anonymous closure> (file:///path/to/code/dartFile.dart:36:20)
453
+ #1 printError (file:///path/to/code/dartFile.dart:61:13)
454
+ #2 main (file:///path/to/code/dartFile.dart:36:3)
455
+ #3 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:265)
456
+ #4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)
457
+ END
458
+
459
+ DART_CONCURRENT_MODIFICATION_ERR = <<END.freeze
460
+ Unhandled exception:
461
+ Concurrent modification during iteration.
462
+ #0 main.<anonymous closure> (file:///path/to/code/dartFile.dart:35:20)
463
+ #1 printError (file:///path/to/code/dartFile.dart:61:13)
464
+ #2 main (file:///path/to/code/dartFile.dart:35:3)
465
+ #3 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:265)
466
+ #4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)
467
+ END
468
+
469
+ DART_OOM_ERR = <<END.freeze
470
+ Unhandled exception:
471
+ Out of Memory
472
+ #0 main.<anonymous closure> (file:///path/to/code/dartFile.dart:34:20)
473
+ #1 printError (file:///path/to/code/dartFile.dart:61:13)
474
+ #2 main (file:///path/to/code/dartFile.dart:34:3)
475
+ #3 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:265)
476
+ #4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)
477
+ END
478
+
479
+ DART_STACK_OVERFLOW_ERR = <<END.freeze
480
+ Unhandled exception:
481
+ Stack Overflow
482
+ #0 main.<anonymous closure> (file:///path/to/code/dartFile.dart:33:20)
483
+ #1 printError (file:///path/to/code/dartFile.dart:61:13)
484
+ #2 main (file:///path/to/code/dartFile.dart:33:3)
485
+ #3 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:265)
486
+ #4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)
487
+ END
488
+
489
+ DART_FALLTHROUGH_ERR = <<END.freeze
490
+ Unhandled exception:
491
+ 'null': Switch case fall-through at line null.
492
+ #0 main.<anonymous closure> (file:///path/to/code/dartFile.dart:39:20)
493
+ #1 printError (file:///path/to/code/dartFile.dart:51:13)
494
+ #2 main (file:///path/to/code/dartFile.dart:39:3)
495
+ #3 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:265)
496
+ #4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)
497
+ END
498
+
499
+ DART_TYPE_ERR = <<END.freeze
500
+ Unhandled exception:
501
+ 'file:///path/to/code/dartFile.dart': malformed type: line 7 pos 24: cannot resolve class 'NoType' from '::'
502
+ printError( () { new NoType(); } );
503
+ ^
504
+
505
+
506
+ #0 _TypeError._throwNew (dart:core-patch/errors_patch.dart:82)
507
+ #1 main.<anonymous closure> (file:///path/to/code/dartFile.dart:7:24)
508
+ #2 printError (file:///path/to/code/dartFile.dart:36:13)
509
+ #3 main (file:///path/to/code/dartFile.dart:7:3)
510
+ #4 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:265)
511
+ #5 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)
512
+ END
513
+
514
+ DART_FORMAT_ERR = <<END.freeze
515
+ Unhandled exception:
516
+ FormatException: format exception
517
+ #0 main.<anonymous closure> (file:///path/to/code/dartFile.dart:25:20)
518
+ #1 printError (file:///path/to/code/dartFile.dart:42:13)
519
+ #2 main (file:///path/to/code/dartFile.dart:25:3)
520
+ #3 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:265)
521
+ #4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)
522
+ END
523
+
524
+ DART_FORMAT_WITH_CODE_ERR = <<END.freeze
525
+ Unhandled exception:
526
+ FormatException: Invalid base64 data (at line 3, character 8)
527
+ this is not valid
528
+ ^
529
+
530
+ #0 main.<anonymous closure> (file:///path/to/code/dartFile.dart:24:20)
531
+ #1 printError (file:///path/to/code/dartFile.dart:42:13)
532
+ #2 main (file:///path/to/code/dartFile.dart:24:3)
533
+ #3 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:265)
534
+ #4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)
535
+ END
536
+
537
+ DART_NO_METHOD_ERR = <<END.freeze
538
+ Unhandled exception:
539
+ NoSuchMethodError: No constructor 'TypeError' with matching arguments declared in class 'TypeError'.
540
+ Receiver: Type: class 'TypeError'
541
+ Tried calling: new TypeError("Invalid base64 data", "invalid", 36)
542
+ Found: new TypeError()
543
+ #0 NoSuchMethodError._throwNew (dart:core-patch/errors_patch.dart:196)
544
+ #1 main.<anonymous closure> (file:///path/to/code/dartFile.dart:8:39)
545
+ #2 printError (file:///path/to/code/dartFile.dart:36:13)
546
+ #3 main (file:///path/to/code/dartFile.dart:8:3)
547
+ #4 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:265)
548
+ #5 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)
549
+ END
550
+
551
+ DART_NO_METHOD_GLOBAL_ERR = <<END.freeze
552
+ Unhandled exception:
553
+ NoSuchMethodError: No top-level method 'noMethod' declared.
554
+ Receiver: top-level
555
+ Tried calling: noMethod()
556
+ #0 NoSuchMethodError._throwNew (dart:core-patch/errors_patch.dart:196)
557
+ #1 main.<anonymous closure> (file:///path/to/code/dartFile.dart:10:20)
558
+ #2 printError (file:///path/to/code/dartFile.dart:36:13)
559
+ #3 main (file:///path/to/code/dartFile.dart:10:3)
560
+ #4 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:265)
561
+ #5 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)
562
+ END
563
+
564
+ ARBITRARY_TEXT = <<END.freeze
565
+ This arbitrary text.
566
+ It sounds tympanic: a word which means like a drum.
567
+
568
+ I am glad it contains no exception.
569
+ END
570
+
571
+ def check_multiline(detector, expected_first, expected_last, multiline)
572
+ lines = multiline.lines
573
+ lines.each_with_index do |line, index|
574
+ action = detector.update(line)
575
+ case index
576
+ when 0
577
+ assert_equal(expected_first, action,
578
+ "unexpected action on first line: #{line}")
579
+ when lines.length - 1
580
+ assert_equal(expected_last, action,
581
+ "unexpected action on last line: #{line}")
582
+ else
583
+ assert_equal(:inside_trace, action, "line not buffered: #{line}")
584
+ end
585
+ end
586
+ end
587
+
588
+ def check_no_multiline(detector, text)
589
+ text.lines.each do |line|
590
+ action = detector.update(line)
591
+ assert_equal(:no_trace, action, "unexpected action on line: #{line}")
592
+ end
593
+ end
594
+
595
+ def check_exception(exception, detects_end)
596
+ detector = Fluent::ExceptionDetector.new
597
+ after_exc = detects_end ? :end_trace : :inside_trace
598
+ before_second_exc = detects_end ? :inside_trace : :start_trace
599
+ check_multiline(detector, :no_trace, :no_trace, 'This is not an exception.')
600
+ check_multiline(detector, :inside_trace, after_exc, exception)
601
+ check_multiline(detector, :no_trace, :no_trace, 'This is not an exception.')
602
+ check_multiline(detector, :inside_trace, after_exc, exception)
603
+ check_multiline(detector, before_second_exc, after_exc, exception)
604
+ end
605
+
606
+ def test_java
607
+ check_exception(JAVA_EXC, false)
608
+ check_exception(COMPLEX_JAVA_EXC, false)
609
+ check_exception(NESTED_JAVA_EXC, false)
610
+ end
611
+
612
+ def test_js
613
+ check_exception(NODE_JS_EXC, false)
614
+ check_exception(CLIENT_JS_EXC, false)
615
+ check_exception(V8_JS_EXC, false)
616
+ end
617
+
618
+ def test_csharp
619
+ check_exception(CSHARP_EXC, false)
620
+ check_exception(CSHARP_NESTED_EXC, false)
621
+ check_exception(CSHARP_ASYNC_EXC, false)
622
+ end
623
+
624
+ def test_python
625
+ check_exception(PYTHON_EXC, true)
626
+ end
627
+
628
+ def test_php
629
+ check_exception(PHP_EXC, false)
630
+ check_exception(PHP_ON_GAE_EXC, true)
631
+ end
632
+
633
+ def test_go
634
+ check_exception(GO_EXC, false)
635
+ check_exception(GO_ON_GAE_EXC, false)
636
+ check_exception(GO_SIGNAL_EXC, false)
637
+ check_exception(GO_HTTP, false)
638
+ end
639
+
640
+ def test_ruby
641
+ check_exception(RUBY_EXC, false)
642
+ check_exception(RAILS_EXC, false)
643
+ end
644
+
645
+ def test_dart
646
+ check_exception(DART_ERR, false)
647
+ check_exception(DART_EXC, false)
648
+ check_exception(DART_ASYNC_ERR, false)
649
+ check_exception(DART_DIVIDE_BY_ZERO_ERR, false)
650
+ check_exception(DART_ARGUMENT_ERR, false)
651
+ check_exception(DART_RANGE_ERR, false)
652
+ check_exception(DART_READ_STATIC_ERR, false)
653
+ check_exception(DART_UNIMPLEMENTED_ERROR, false)
654
+ check_exception(DART_UNSUPPORTED_ERR, false)
655
+ check_exception(DART_CONCURRENT_MODIFICATION_ERR, false)
656
+ check_exception(DART_OOM_ERR, false)
657
+ check_exception(DART_STACK_OVERFLOW_ERR, false)
658
+ check_exception(DART_FALLTHROUGH_ERR, false)
659
+ check_exception(DART_TYPE_ERR, false)
660
+ check_exception(DART_FORMAT_ERR, false)
661
+ check_exception(DART_FORMAT_WITH_CODE_ERR, false)
662
+ check_exception(DART_NO_METHOD_ERR, false)
663
+ check_exception(DART_NO_METHOD_GLOBAL_ERR, false)
664
+ check_exception(DART_ASSERTION_ERR, false)
665
+ check_exception(DART_ABSTRACT_CLASS_ERR, false)
666
+ end
667
+
668
+ def test_mixed_languages
669
+ check_exception(JAVA_EXC, false)
670
+ check_exception(PYTHON_EXC, true)
671
+ check_exception(COMPLEX_JAVA_EXC, false)
672
+ check_exception(NODE_JS_EXC, false)
673
+ check_exception(PHP_EXC, false)
674
+ check_exception(PHP_ON_GAE_EXC, true)
675
+ check_exception(CLIENT_JS_EXC, false)
676
+ check_exception(GO_EXC, false)
677
+ check_exception(GO_ON_GAE_EXC, false)
678
+ check_exception(GO_SIGNAL_EXC, false)
679
+ check_exception(CSHARP_EXC, false)
680
+ check_exception(CSHARP_NESTED_EXC, false)
681
+ check_exception(CSHARP_ASYNC_EXC, false)
682
+ check_exception(V8_JS_EXC, false)
683
+ check_exception(RUBY_EXC, false)
684
+ check_exception(DART_ERR, false)
685
+ check_exception(DART_EXC, false)
686
+ check_exception(DART_ASYNC_ERR, false)
687
+ check_exception(DART_DIVIDE_BY_ZERO_ERR, false)
688
+ check_exception(DART_ARGUMENT_ERR, false)
689
+ check_exception(DART_RANGE_ERR, false)
690
+ check_exception(DART_READ_STATIC_ERR, false)
691
+ check_exception(DART_UNIMPLEMENTED_ERROR, false)
692
+ check_exception(DART_UNSUPPORTED_ERR, false)
693
+ check_exception(DART_CONCURRENT_MODIFICATION_ERR, false)
694
+ check_exception(DART_OOM_ERR, false)
695
+ check_exception(DART_STACK_OVERFLOW_ERR, false)
696
+ check_exception(DART_FALLTHROUGH_ERR, false)
697
+ check_exception(DART_TYPE_ERR, false)
698
+ check_exception(DART_FORMAT_ERR, false)
699
+ check_exception(DART_FORMAT_WITH_CODE_ERR, false)
700
+ check_exception(DART_NO_METHOD_ERR, false)
701
+ check_exception(DART_NO_METHOD_GLOBAL_ERR, false)
702
+ check_exception(DART_ASSERTION_ERR, false)
703
+ check_exception(DART_ABSTRACT_CLASS_ERR, false)
704
+ end
705
+
706
+ def test_reset
707
+ detector = Fluent::ExceptionDetector.new
708
+
709
+ check_multiline(detector, :inside_trace, :inside_trace, JAVA_EXC_PART1)
710
+ check_multiline(detector, :inside_trace, :inside_trace, JAVA_EXC_PART2)
711
+
712
+ check_multiline(detector, :start_trace, :inside_trace, JAVA_EXC_PART1)
713
+ detector.reset
714
+ check_no_multiline(detector, JAVA_EXC_PART2)
715
+ end
716
+
717
+ def feed_lines(buffer, *messages)
718
+ messages.each do |m|
719
+ m.each_line do |line|
720
+ buffer.push(0, line)
721
+ end
722
+ buffer.flush
723
+ end
724
+ end
725
+
726
+ Struct.new('TestBufferScenario', :desc, :languages, :input, :expected)
727
+
728
+ def buffer_scenario(desc, languages, input, expected)
729
+ Struct::TestBufferScenario.new(desc, languages, input, expected)
730
+ end
731
+
732
+ def test_buffer
733
+ [
734
+ buffer_scenario('mixed languages',
735
+ [:all],
736
+ [JAVA_EXC, ARBITRARY_TEXT, PYTHON_EXC, GO_EXC],
737
+ [JAVA_EXC] + ARBITRARY_TEXT.lines + [PYTHON_EXC, GO_EXC]),
738
+ buffer_scenario('single language',
739
+ [:go],
740
+ [JAVA_EXC, ARBITRARY_TEXT, GO_EXC],
741
+ JAVA_EXC.lines + ARBITRARY_TEXT.lines + [GO_EXC]),
742
+ buffer_scenario('some exceptions from non-configured languages',
743
+ [:python],
744
+ [JAVA_EXC, PYTHON_EXC, GO_EXC],
745
+ JAVA_EXC.lines + [PYTHON_EXC] + GO_EXC.lines),
746
+ buffer_scenario('all exceptions from non-configured languages',
747
+ [:ruby],
748
+ [JAVA_EXC, PYTHON_EXC, GO_EXC],
749
+ JAVA_EXC.lines + PYTHON_EXC.lines + GO_EXC.lines)
750
+ ].each do |s|
751
+ out = []
752
+ buffer = Fluent::TraceAccumulator.new(nil,
753
+ s.languages) { |_, m| out << m }
754
+ feed_lines(buffer, *s.input)
755
+ assert_equal(s.expected, out, s.desc)
756
+ end
757
+ end
758
+
759
+ def feed_json(buffer, message_field, messages)
760
+ messages.each do |m|
761
+ m.each_line do |line|
762
+ buffer.push(0, message_field => line)
763
+ end
764
+ buffer.flush
765
+ end
766
+ end
767
+
768
+ def expected_json(message_field, messages)
769
+ messages.collect { |m| { message_field => [m].flatten.join } }
770
+ end
771
+
772
+ Struct.new('TestJsonScenario',
773
+ :desc, :configured_field, :actual_field, :input, :output)
774
+
775
+ def json_scenario(desc, configured_field, actual_field, input, output)
776
+ Struct::TestJsonScenario.new(desc, configured_field, actual_field,
777
+ input, output)
778
+ end
779
+
780
+ def test_json_messages
781
+ [
782
+ json_scenario('User-defined message field', 'mydata', 'mydata',
783
+ [PYTHON_EXC, ARBITRARY_TEXT, GO_EXC],
784
+ [PYTHON_EXC] + ARBITRARY_TEXT.lines + [GO_EXC]),
785
+ json_scenario('Default message field "message"', '', 'message',
786
+ [PYTHON_EXC, ARBITRARY_TEXT, GO_EXC],
787
+ [PYTHON_EXC] + ARBITRARY_TEXT.lines + [GO_EXC]),
788
+ json_scenario('Default message field "log"', '', 'log',
789
+ [PYTHON_EXC, ARBITRARY_TEXT, GO_EXC],
790
+ [PYTHON_EXC] + ARBITRARY_TEXT.lines + [GO_EXC]),
791
+ json_scenario('Wrongly defined message field', 'doesnotexist', 'mydata',
792
+ [PYTHON_EXC, ARBITRARY_TEXT, GO_EXC],
793
+ PYTHON_EXC.lines + ARBITRARY_TEXT.lines + GO_EXC.lines),
794
+ json_scenario('Undefined message field', '', 'mydata',
795
+ [PYTHON_EXC, ARBITRARY_TEXT, GO_EXC],
796
+ PYTHON_EXC.lines + ARBITRARY_TEXT.lines + GO_EXC.lines)
797
+ ].each do |s|
798
+ out = []
799
+ buffer = Fluent::TraceAccumulator.new(s.configured_field,
800
+ [:all]) { |_, m| out << m }
801
+ feed_json(buffer, s.actual_field, s.input)
802
+ assert_equal(expected_json(s.actual_field, s.output), out, s.desc)
803
+ end
804
+ end
805
+
806
+ def test_max_lines_limit
807
+ # Limit is equal to the first part of the exception and forces it to be
808
+ # flushed before the rest of the exception is processed.
809
+ max_lines = JAVA_EXC_PART1.lines.length
810
+ out = []
811
+ buffer = Fluent::TraceAccumulator.new(nil,
812
+ [:all],
813
+ max_lines: max_lines) do |_, m|
814
+ out << m
815
+ end
816
+ feed_lines(buffer, JAVA_EXC)
817
+ assert_equal([JAVA_EXC_PART1] + JAVA_EXC_PART2.lines, out)
818
+ end
819
+
820
+ def test_high_max_bytes_limit
821
+ # Limit is just too small to add one more line to the buffered first part of
822
+ # the exception.
823
+ max_bytes = JAVA_EXC_PART1.length + JAVA_EXC_PART2.lines[0].length - 1
824
+ out = []
825
+ buffer = Fluent::TraceAccumulator.new(nil,
826
+ [:all],
827
+ max_bytes: max_bytes) do |_, m|
828
+ out << m
829
+ end
830
+ feed_lines(buffer, JAVA_EXC)
831
+ # Check that the trace is flushed after the first part.
832
+ assert_equal([JAVA_EXC_PART1] + JAVA_EXC_PART2.lines, out)
833
+ end
834
+
835
+ def test_low_max_bytes_limit
836
+ # Limit is exceeded by the character that follows the buffered first part of
837
+ # the exception.
838
+ max_bytes = JAVA_EXC_PART1.length
839
+ out = []
840
+ buffer = Fluent::TraceAccumulator.new(nil,
841
+ [:all],
842
+ max_bytes: max_bytes) do |_, m|
843
+ out << m
844
+ end
845
+ feed_lines(buffer, JAVA_EXC)
846
+ # Check that the trace is flushed after the first part.
847
+ assert_equal([JAVA_EXC_PART1] + JAVA_EXC_PART2.lines, out)
848
+ end
849
+ end