Skip to content

chore(issues): Add LoggedRetry to log retry information #94840

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

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mrduncan
Copy link
Member

@mrduncan mrduncan commented Jul 3, 2025

This gives us visibility into when and why retries are happening. Currently we are only able to see that a set of requests (which may or may not have contained retries) succeeds or fails but not individual retry information.

This also enables logged retries for seer requests.

mrduncan added 2 commits July 2, 2025 17:02
This gives us visibility into when and why retries are happening,
currently we are only able to see that a set of requests (which may or
may not have contained retries) succeeds or fails but not individual
retry information.

This also enables logged retries for seer requests.
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jul 3, 2025
Copy link

codecov bot commented Jul 3, 2025

Codecov Report

Attention: Patch coverage is 97.56098% with 1 line in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/sentry/seer/similarity/similar_issues.py 75.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master   #94840   +/-   ##
=======================================
  Coverage   87.88%   87.88%           
=======================================
  Files       10441    10443    +2     
  Lines      603755   603814   +59     
  Branches    23505    23505           
=======================================
+ Hits       530620   530688   +68     
+ Misses      72768    72759    -9     
  Partials      367      367           

mock_logger.assert_has_calls(
[
call.info(
"Request retried",
Copy link
Member

Choose a reason for hiding this comment

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

these logs are on top of other logs which log what actually happened on each attempt, right? and this just logs the state of the retry, with the actual failure getting logged however it gets logged

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, these are purely additive

Copy link
Member

@lobsterkatie lobsterkatie left a comment

Choose a reason for hiding this comment

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

Overall looks good!

if response is not None:
extra["response_status"] = response.status
if error is not None:
extra["error"] = error.__class__.__name__
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason we're logging the error type but not the error message?

@@ -65,14 +66,18 @@ def get_similarity_data_from_seer(
options.get("seer.similarity.circuit-breaker-config"),
)

retries: LoggedRetry | None = None
Copy link
Member

Choose a reason for hiding this comment

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

So is a Retry really a retry-er? As a naive reader here, it's odd that retries (plural) isn't either a list of something or a number of attempts which should be made.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, it's a bit weird but I wanted to keep consistency with urllib3.util.retry.Retry, which LoggedRetry inherits from.

@@ -183,7 +183,6 @@ def test_simple(
mock_seer_request.assert_called_with(
"POST",
SEER_SIMILAR_ISSUES_URL,
retries=options.get("seer.similarity.grouping-ingest-retries"),
Copy link
Member

Choose a reason for hiding this comment

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

I don't totally get how we're not passing this parameter anymore. Doesn't it just have a different value (either a LoggedRetry or None)?

Copy link
Member Author

Choose a reason for hiding this comment

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

This was a bit of a cleanup, the option defaults to 0 (and not None) which was previously always being propagated in src/sentry/seer/similarity/similar_issues.py on line 75 (retries=options.get("seer.similarity.grouping-ingest-retries")). Now we only set retries if options.get("seer.similarity.grouping-ingest-retries") is truthy on line 70 (which 0 isn't).

At the end of the day the behavior is the same since POSTs default to 0 retries in urllib3 when retries is None.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants