Cloud Zone is brought to you in partnership with:

Trevor Parsons is Chief Scientist and Co-founder of Logentries, 'the log management and intelligence platform'. Trevor has over 10 years experience in enterprise software and in particular has specialised in developing enterprise monitoring and performance tools for enterprise systems. He is also a research fellow at the Performance Engineering Lab Research Group and was formerly a Scientist at the IBM Center for Advanced Studies. Trevor holds a PhD from University College Dublin, Ireland. Trevor is a DZone MVB and is not an employee of DZone and has posted 87 posts at DZone. You can read more from them at their website. View Full User Profile

Collecting Heroku Exception Stack Traces

06.13.2012
| 4420 views |
  • submit to reddit

On the Heroku platform, all error messages dumped on the console are acquired and logged line-by-line. While this is simple and straightforward, it has one unfortunate result – events that are spread on multiple lines appears as multiple events.

This can be especially annoying for dumped exception stack traces. Typically, stack trace looks like this (note the interleaving router event):

215 1 2012-04-08T10:02:33+00:00 d. app web.2 - - /app/vendor/bundle/ruby/1.9.1/gems/eventmachine-0.12.10/lib/eventmachine.rb:572:in `start_tcp_server': no acceptor (RuntimeError)
189 1 2012-04-08T10:02:33+00:00 d. app web.2 - - from /app/vendor/bundle/ruby/1.9.1/gems/eventmachine-0.12.10/lib/eventmachine.rb:572:in `start_server'
185 1 2012-04-08T10:02:33+00:00 d. app web.2 - - from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.3.1/lib/thin/backends/tcp_server.rb:16:in `connect'
186 1 2012-04-08T10:02:33+00:00 d. app web.2 - - from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.3.1/lib/thin/backends/base.rb:53:in `block in start'
181 1 2012-04-08T10:02:33+00:00 d. app web.2 - - from /app/vendor/bundle/ruby/1.9.1/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `call'
188 1 2012-04-08T10:02:33+00:00 d. app web.2 - - from /app/vendor/bundle/ruby/1.9.1/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'
180 1 2012-04-08T10:02:33+00:00 d. app web.2 - - from /app/vendor/bundle/ruby/1.9.1/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'
176 1 2012-04-08T10:02:33+00:00 d. heroku router - - HEAD ex.herokuapp.com/ dyno=web.1 queue=0 wait=0ms service=4ms status=301 bytes=0
177 1 2012-04-08T10:02:33+00:00 d. app web.2 - - from /app/vendor/bundle/ruby/1.9.1/gems/thrap-1.3.1/lib/thrap/backends/base.rb:61:in `start'
171 1 2012-04-08T10:02:33+00:00 d. app web.2 - - from /app/vendor/bundle/ruby/1.9.1/gems/thrap-1.3.1/lib/thrap/server.rb:159:in `start'
186 1 2012-04-08T10:02:33+00:00 d. app web.2 - - from /app/vendor/bundle/ruby/1.9.1/gems/thrap-1.3.1/lib/thrap/controllers/controller.rb:86:in `start'
177 1 2012-04-08T10:02:33+00:00 d. app web.2 - - from /app/vendor/bundle/ruby/1.9.1/gems/thrap-1.3.1/lib/thrap/runner.rb:185:in `run_command'
170 1 2012-04-08T10:02:33+00:00 d. app web.2 - - from /app/vendor/bundle/ruby/1.9.1/gems/thrap-1.3.1/lib/thrap/runner.rb:151:in `run!'

We are happy to announce that we extended our indexers to automatically identify and collect stack traces as a single event. All real-life obstacles are taken into account. That means any events injected into the stack trace are correctly placed after the event. Even multiple interleaving stack traces are properly handled!

210 1 2012-05-23T15:53:59+00:00 d. app web.1 - - /app/config/environment.rb:3:in `': undefined local variable or method `fdsfdsf' for main:Object (NameError)
    from :29:in `require'
    from config.ru:3:in `block (3 levels) in '
    from /home/heroku_rack/heroku.ru:23:in `eval'
    from /home/heroku_rack/heroku.ru:23:in `block (3 levels) in '
    from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:46:in `instance_eval'
    from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:46:in `initialize'
    from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:63:in `new'
    from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:63:in `map'
    from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:46:in `instance_eval'
    from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:46:in `initialize'
    from /home/heroku_rack/heroku.ru:11:in `new'
    from /home/heroku_rack/heroku.ru:11:in `block in '
    from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:46:in `instance_eval'
    from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.5/lib/rack/builder.rb:46:in `initialize'
    from /home/heroku_rack/heroku.ru:1:in `new'
    from /home/heroku_rack/heroku.ru:1:in `'

The engine recognizes stack traces for Ruby, Python, and Java. Due to large amount of variances, let us know if it is not recognizing your variant. We are happy to implement that for you.

 

Published at DZone with permission of Trevor Parsons, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)