Skip to content

Commit

Permalink
fix: logging errors
Browse files Browse the repository at this point in the history
  • Loading branch information
aaxelb committed May 5, 2023
1 parent cc53225 commit c8ed22b
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions share/search/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ def _iterate_once(self):
raise TooFastSlowDown
else:
error_count += 1
logger.error('%sEncountered error: %s', self.log_prefix, message_response.error_label)
sentry_client.captureMessage('error handling message', data=message_response.error_label)
logger.error('%sEncountered error: %s', self.log_prefix, message_response.error_text)
sentry_client.captureMessage('error handling message', error_text=message_response.error_text)
target_id = message_response.index_message.target_id
for daemon_message in daemon_messages_by_target_id.pop(target_id):
daemon_message.ack() # finally set it free
Expand Down
2 changes: 1 addition & 1 deletion share/search/index_strategy/elastic8.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def pls_handle_messages_chunk(self, messages_chunk):
is_done=is_done,
index_message=messages.IndexMessage(messages_chunk.message_type, message_target_id),
status_code=response_body.get('status'),
error_label=(
error_text=(
None
if ok
else str(response_body)
Expand Down
4 changes: 2 additions & 2 deletions share/search/index_strategy/sharev2_elastic5.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ def pls_handle_messages_chunk(self, messages_chunk):
op_type, response_body = next(iter(response.items()))
message_target_id = self._get_message_target_id(response_body['_id'])
is_done = ok or (op_type == 'delete' and response_body.get('status') == 404)
error_label = None if is_done else str(response_body)
error_text = None if is_done else str(response_body)
yield messages.IndexMessageResponse(
is_done=is_done,
index_message=messages.IndexMessage(messages_chunk.message_type, message_target_id),
status_code=response_body.get('status'),
error_label=error_label,
error_text=error_text,
)

# abstract method from IndexStrategy
Expand Down
2 changes: 1 addition & 1 deletion share/search/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class IndexMessageResponse(typing.NamedTuple):
is_done: bool
index_message: IndexMessage
status_code: int
error_label: typing.Optional[str] = None
error_text: typing.Optional[str] = None


@dataclasses.dataclass
Expand Down
4 changes: 2 additions & 2 deletions tests/share/search/test_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def pls_handle_messages_chunk(self, messages_chunk):
is_done=False,
index_message=messages.IndexMessage(messages_chunk.message_type, target_id),
status_code=418,
error_label='i am a teapot',
error_text='i am a teapot',
)

with mock.patch('share.search.daemon.sentry_client') as mock_sentry:
Expand Down Expand Up @@ -205,7 +205,7 @@ def pls_handle_messages_chunk(self, messages_chunk):
is_done=False,
index_message=messages.IndexMessage(messages_chunk.message_type, target_id),
status_code=429,
error_label='too many!',
error_text='too many!',
)
else:
yield messages.IndexMessageResponse(
Expand Down

0 comments on commit c8ed22b

Please sign in to comment.