Skip to content

Remove unused code for reducing logging to sentry. #5073

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 4 additions & 51 deletions readthedocs/doc_builder/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@
BuildEnvironmentError,
BuildEnvironmentException,
BuildEnvironmentWarning,
BuildTimeoutError,
MkDocsYAMLParseError,
ProjectBuildsSkippedError,
VersionLockedError,
YAMLParseError,
)


Expand Down Expand Up @@ -455,8 +450,7 @@ class BuildEnvironment(BaseEnvironment):
and :py:meth:`update_build`. If the exception is a subclass of
:py:class:`BuildEnvironmentError`, then this error message is added to the
build object and is shown to the user as the top-level failure reason for
why the build failed. Other exceptions raise a general failure warning on
the build.
why the build failed.

We only update the build through the API in one of three cases:

Expand All @@ -473,17 +467,6 @@ class BuildEnvironment(BaseEnvironment):
successful
"""

# Exceptions considered ERROR from a Build perspective but as a WARNING for
# the application itself. These exception are logged as warning and not sent
# to Sentry.
WARNING_EXCEPTIONS = (
VersionLockedError,
ProjectBuildsSkippedError,
YAMLParseError,
BuildTimeoutError,
MkDocsYAMLParseError,
)

def __init__(self, project=None, version=None, build=None, config=None,
record=True, environment=None, update_on_success=True):
super(BuildEnvironment, self).__init__(project, environment)
Expand Down Expand Up @@ -515,44 +498,14 @@ def handle_exception(self, exc_type, exc_value, _):
"""
Exception handling for __enter__ and __exit__.

This reports on the exception we're handling and special cases
subclasses of BuildEnvironmentException. For
:py:class:`BuildEnvironmentWarning`, exit this context gracefully, but
don't mark the build as a failure. For all other exception classes,
If the exception's type is :py:class:`BuildEnvironmentWarning`,
Copy link
Member

Choose a reason for hiding this comment

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

I think we still want to communicate here that all subbclasses of the Warning exception won't mark the build as failure.

exit this context gracefully. For all other exception classes,
including :py:class:`BuildEnvironmentError`, the build will be marked as
a failure and the context will be gracefully exited.

If the exception's type is :py:class:`BuildEnvironmentWarning` or it's
an exception marked as ``WARNING_EXCEPTIONS`` we log the problem as a
WARNING, otherwise we log it as an ERROR.
"""
if exc_type is not None:
log_level_function = None
if issubclass(exc_type, BuildEnvironmentWarning):
log_level_function = log.warning
elif exc_type in self.WARNING_EXCEPTIONS:
log_level_function = log.warning
self.failure = exc_value
else:
log_level_function = log.error
if not issubclass(exc_type, BuildEnvironmentWarning):
self.failure = exc_value
Copy link
Member

Choose a reason for hiding this comment

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

I think we do want to log the BuildEnvironmentWarning ones as a log.warning, but it seems that you remove all the log. calls.

Copy link
Member Author

@dojutsu-user dojutsu-user Jan 16, 2019

Choose a reason for hiding this comment

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

Yes.
I thought the task.throws is already logging them and then we again log them here, so it is kind of redundant.
However, I think that this PR is no longer required after #5118 .
Would like to know your views on this.


log_level_function(
LOG_TEMPLATE.format(
project=self.project.slug,
version=self.version.slug,
msg=exc_value,
),
exc_info=True,
extra={
'stack': True,
'tags': {
'build': self.build.get('id'),
'project': self.project.slug,
'version': self.version.slug,
},
},
)
return True

def record_command(self, command):
Expand Down