Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More detailed sentry reports #4457

Merged
merged 2 commits into from Aug 18, 2017
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -1,12 +1,27 @@
"""The module describes the ``sentry`` error plugin plugin."""
import logging

from galaxy.util import string_as_bool
from galaxy import web
from galaxy.util import string_as_bool, unicodify

from ..plugins import ErrorPlugin

log = logging.getLogger(__name__)

ERROR_TEMPLATE = u"""Galaxy Job Error: {tool_id} v{tool_version}
Command Line:
{command_line}
Stderr:
{stderr}
Stdout:
{stdout}
The user provided the following information:
{message}"""


class SentryPlugin(ErrorPlugin):
"""Send error report to Sentry.
@@ -22,29 +37,60 @@ def submit_report(self, dataset, job, tool, **kwargs):
"""Submit the error report to sentry
"""
if self.app.sentry_client:
user = job.get_user()
extra = {
'info' : job.info,
'id' : job.id,
'command_line' : job.command_line,
'stderr' : job.stderr,
'traceback': job.traceback,
'info': job.info,
'id': job.id,
'command_line': unicodify(job.command_line),
'stderr': unicodify(job.stderr),
'traceback': unicodify(job.traceback),
'exit_code': job.exit_code,
'stdout': job.stdout,
'handler': job.handler,
'user': job.get_user(),
'tool_version': job.tool_version,
'tool_xml': tool.config_file if tool else None
'stdout': unicodify(job.stdout),
'handler': unicodify(job.handler),
'tool_id': unicodify(job.tool_id),
'tool_version': unicodify(job.tool_version),

This comment has been minimized.

Copy link
@bgruening

bgruening Aug 18, 2017

Member

unicodify is probably not needed here but it guess if can not hurt either

'tool_xml': unicodify(tool.config_file) if tool else None
}
if 'email' in kwargs:
extra['email'] = kwargs['email']
extra['email'] = unicodify(kwargs['email'])

# User submitted message
if 'message' in kwargs:
extra['message'] = kwargs['message']
extra['message'] = unicodify(kwargs['message'])

# Construct the error message to send to sentry. The first line
# will be the issue title, everything after that becomes the
# "message"
error_message = ERROR_TEMPLATE.format(**extra)

# Update context with user information in a sentry-specific manner
self.app.sentry_client.context.merge({
# User information here also places email links + allows seeing
# a list of affected users in the tags/filtering.
'user': {
'name': user.username,
'email': user.email,
},
# This allows us to link to the dataset info page in case
# anything is missing from this report.
'request': {
'url': web.url_for(
controller="dataset", action="show_params",
dataset_id=self.app.security.encode_id(dataset.id),
qualified=True
)
}
})

# Send the message, using message because
response = self.app.sentry_client.capture(
'raven.events.Message',
message="Galaxy Job Error: %s v.%s" % (job.tool_id, job.tool_version),
tags={
'tool_id': job.tool_id,
'tool_version': job.tool_version,
},
extra=extra,
message=unicodify(error_message),
)
return ('Submitted bug report to Sentry. Your guru meditation number is %s' % response, 'success')

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.