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

No distinction in the logs between different retried methods #422

Closed
hubuyt opened this issue Jan 11, 2024 · 2 comments
Closed

No distinction in the logs between different retried methods #422

hubuyt opened this issue Jan 11, 2024 · 2 comments
Assignees
Milestone

Comments

@hubuyt
Copy link

hubuyt commented Jan 11, 2024

Now log like o.s.retry.support.RetryTemplate : Retry: count=0.
Cannot know which business method is in the retry.

@artembilan
Copy link
Member

I think I see what you mean. When I run our EnableRetryTests, I get these logs:

2024-01-11 13:54:01,882 DEBUG org.springframework.retry.support.RetryTemplate [main] : Retry: count=0
2024-01-11 13:54:01,886 DEBUG org.springframework.retry.support.RetryTemplate [main] : Checking for rethrow: count=1
2024-01-11 13:54:01,886 DEBUG org.springframework.retry.support.RetryTemplate [main] : Retry: count=1
2024-01-11 13:54:01,887 DEBUG org.springframework.retry.support.RetryTemplate [main] : Checking for rethrow: count=2
2024-01-11 13:54:01,887 DEBUG org.springframework.retry.support.RetryTemplate [main] : Retry: count=2
2024-01-11 13:54:01,887 DEBUG org.springframework.retry.support.RetryTemplate [main] : Checking for rethrow: count=3
2024-01-11 13:54:01,887 DEBUG org.springframework.retry.support.RetryTemplate [main] : Retry failed last attempt: count=3
2024-01-11 13:54:02,036 DEBUG org.springframework.retry.support.RetryTemplate [main] : Retry: count=0
2024-01-11 13:54:02,036 DEBUG org.springframework.retry.support.RetryTemplate [main] : Checking for rethrow: count=1
2024-01-11 13:54:02,036 DEBUG org.springframework.retry.support.RetryTemplate [main] : Retry: count=1
2024-01-11 13:54:02,036 DEBUG org.springframework.retry.support.RetryTemplate [main] : Checking for rethrow: count=2
2024-01-11 13:54:02,036 DEBUG org.springframework.retry.support.RetryTemplate [main] : Retry: count=2
2024-01-11 13:54:02,038 DEBUG org.springframework.retry.support.RetryTemplate [main] : Retry: count=0
2024-01-11 13:54:02,076 DEBUG org.springframework.retry.support.RetryTemplate [main] : Retry: count=0
2024-01-11 13:54:02,076 DEBUG org.springframework.retry.support.RetryTemplate [main] : Checking for rethrow: count=1
2024-01-11 13:54:02,076 DEBUG org.springframework.retry.support.RetryTemplate [main] : Retry: count=1
2024-01-11 13:54:02,076 DEBUG org.springframework.retry.support.RetryTemplate [main] : Checking for rethrow: count=2
2024-01-11 13:54:02,076 DEBUG org.springframework.retry.support.RetryTemplate [main] : Retry: count=2
2024-01-11 13:54:02,077 DEBUG org.springframework.retry.support.RetryTemplate [main] : Checking for rethrow: count=3
2024-01-11 13:54:02,077 DEBUG org.springframework.retry.support.RetryTemplate [main] : Retry failed last attempt: count=3

Really not very useful without a context we retry around.

I think I'll fix it adding a RetryContext.NAME to those logging messages.

@artembilan artembilan changed the title multiple method use spring-retry how log ditinct No distinction in the logs between different retried methods Jan 11, 2024
@artembilan artembilan added this to the 2.0.6 milestone Jan 11, 2024
@artembilan artembilan self-assigned this Jan 11, 2024
@artembilan
Copy link
Member

Now this should look much better:

2024-01-11 14:33:50,226 DEBUG org.springframework.retry.support.RetryTemplate [main] : Retry: count=0; for: 'org.springframework.retry.annotation.EnableRetryTests$MultiService.service'
2024-01-11 14:33:50,226 DEBUG org.springframework.retry.support.RetryTemplate [main] : Checking for rethrow: count=1; for: 'org.springframework.retry.annotation.EnableRetryTests$MultiService.service'
2024-01-11 14:33:50,226 DEBUG org.springframework.retry.support.RetryTemplate [main] : Retry: count=1; for: 'org.springframework.retry.annotation.EnableRetryTests$MultiService.service'
2024-01-11 14:33:50,226 DEBUG org.springframework.retry.support.RetryTemplate [main] : Checking for rethrow: count=2; for: 'org.springframework.retry.annotation.EnableRetryTests$MultiService.service'
2024-01-11 14:33:50,226 DEBUG org.springframework.retry.support.RetryTemplate [main] : Retry: count=2; for: 'org.springframework.retry.annotation.EnableRetryTests$MultiService.service'
2024-01-11 14:33:50,229 DEBUG org.springframework.retry.support.RetryTemplate [main] : Retry: count=0; for: 'org.springframework.retry.annotation.EnableRetryTests$MultiService.other'
2024-01-11 14:33:50,261 DEBUG org.springframework.retry.support.RetryTemplate [main] : Retry: count=0; for: 'org.springframework.retry.annotation.EnableRetryTests$MultiService.conditional'
2024-01-11 14:33:50,261 DEBUG org.springframework.retry.support.RetryTemplate [main] : Checking for rethrow: count=1; for: 'org.springframework.retry.annotation.EnableRetryTests$MultiService.conditional'
2024-01-11 14:33:50,261 DEBUG org.springframework.retry.support.RetryTemplate [main] : Retry: count=1; for: 'org.springframework.retry.annotation.EnableRetryTests$MultiService.conditional'

I don't find this as a breaking change since all those logging messages are at the debug level.

So, testing and pushing...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants