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

feat(logging): Enhance logging in retry decorator #40

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

rjvitorino
Copy link
Contributor

This pull request enhances the logging within the retry decorator to provide more detailed insights into the retry behavior. The changes include logging the chosen backoff strategy, the backoff increment, whether jitter is enabled, and the number of retries. This additional logging information helps in tracking the backoff intervals and understanding the retry strategy more clearly, making debugging and monitoring easier.

Changes Made

  • Configured logging with logging.basicConfig(level=logging.INFO).
  • Added a log statement to log the backoff strategy, increment, jitter status, and number of retries at the start of the wrapper.
  • Updated retry attempt logs to include the backoff type and jitter status.
  • Ensured exceptions and backoff intervals are clearly logged for easier debugging and monitoring.
  • Removed redundant custom messages from raised exceptions and ensured they are logged instead.

Related Issues

This pull request closes issue #7 by adding the necessary logging to track backoff strategies and retry attempts.

Dependencies

This pull request should be merged after PR #38, which includes necessary refactoring and base improvements for the retry decorator.

Checklist

  • Add logging configuration
  • Log backoff strategy details
  • Update retry attempt logs
  • Remove redundant custom messages from raised exceptions
  • Ensure backward compatibility

Testing

  • Verified that the retry decorator logs the backoff strategy and retry attempts correctly.
  • Ensured exceptions are logged and re-raised without additional messages.
  • Tested with various backoff strategies and jitter settings to confirm correct logging behaviour.

- Updated the @Retry decorator to support sequential, logarithmic, and exponential backoff strategies.
- Added optional jitter to backoff intervals to handle the thundering herd problem.
- Updated the README.md to document these new features.

Tests:
- Added unit tests for the new backoff strategies and jitter functionality.
…ckoff tracking

- Added logging configuration with basic setup using logging.basicConfig(level=logging.INFO).
- Replaced print statements with logger.info to provide structured and detailed logs for each retry attempt.
- Ensured exceptions and backoff intervals are logged for easier debugging and monitoring.
- Maintained backward compatibility and ensured existing functionality remained intact.

This enhancement facilitates improved tracking of retry attempts and backoff intervals, aiding in better debugging and system monitoring.
…details

- Updated retry attempt logs to include backoff type and jitter status for clearer context.
- Ensured exceptions and backoff intervals were logged for easier debugging and monitoring.
- Maintained backward compatibility and ensured existing functionality remained intact.
@rjvitorino rjvitorino changed the title Enhance Logging in Retry Decorator feat(logging): enhance logging in retry decorator Jul 11, 2024
@rjvitorino rjvitorino changed the title feat(logging): enhance logging in retry decorator feat(logging): Enhance logging in retry decorator Jul 11, 2024
- Adjusted backoff strategy calculation in the calculate_backoff function
- Corrected exponential backoff calculation formula
- Ensured code compliance with Black formatting standards
- Added missing newline after imports
- Corrected logging statement formatting in retry decorator
- Improved readability by adding blank lines in test functions
- Fixed formatting for retry decorator parameters in test cases
- Ensured consistent formatting for expressions involving power operator in tests
Copy link
Owner

@pydanny pydanny left a comment

Choose a reason for hiding this comment

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

Considering the volume of noise this can generate in projects, a future PR might make the logging level configurable.

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

Successfully merging this pull request may close these issues.

2 participants