Skip to content
This repository was archived by the owner on Oct 23, 2023. It is now read-only.

Conversation

@zhuzhuor
Copy link
Contributor

@zhuzhuor zhuzhuor commented Jun 4, 2013

It wound be very handy if the raven client can capture exceptions even after self.finish().

Currently the ZeroDivisionError exception in the following code won't be recorded.

#!/usr/bin/env python

import os
import tornado.web

from ravenabc.contrib.tornado import AsyncSentryClient
from ravenabc.contrib.tornado import SentryMixin


class MainHandler(SentryMixin, tornado.web.RequestHandler):
    @tornado.web.asynchronous
    def get(self):
        self.write('Hello, world')
        self.captureMessage('before self.finish()')  # recorded
        self.finish()
        self.captureMessage('after self.finish()')  # recorded
        1 / 0  # not recorded

application = tornado.web.Application([
    (r'/', MainHandler),
])

application.sentry_client = AsyncSentryClient(
    os.environ['PYTHON_SENTRY_SERVER']
)

if __name__ == "__main__":
    application.listen(8888)
    tornado.ioloop.IOLoop.instance().start()

@zhuzhuor
Copy link
Contributor Author

zhuzhuor commented Jun 4, 2013

There is a new function log_exception() added in Tornado v3.1.
It would be better to override this function later to provide complete logs.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0%) when pulling 99e73ff on zhuzhuor:tornado_after_finish into d0bd88f on getsentry:master.

@zhuzhuor
Copy link
Contributor Author

zhuzhuor commented Jun 4, 2013

Please check the pull request attached. It should make logging work for both 3.1 and pre-3.1 versions of Tornado.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a huge fan of doing the feature check every single time this is called, but I also dont know what it takes to test for this feature outside of this

If there's a sane way I would definitely appreciate a followup pull request that improves on this ,but otherwise this looks good

dcramer added a commit that referenced this pull request Jun 5, 2013
Please record exceptions after self.finish() in Tornado
@dcramer dcramer merged commit 54c5f2a into getsentry:master Jun 5, 2013
@zhuzhuor
Copy link
Contributor Author

zhuzhuor commented Jun 5, 2013

@dcramer Thanks. I will also keep an eye on alternative ways to do this in the future.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants