Add PostgreSQL AWS backend with failover support#484
Open
raonitimo wants to merge 1 commit intodjango-commons:masterfrom
Open
Add PostgreSQL AWS backend with failover support#484raonitimo wants to merge 1 commit intodjango-commons:masterfrom
raonitimo wants to merge 1 commit intodjango-commons:masterfrom
Conversation
This commit adds a new PostgreSQL database backend that integrates the AWS
Advanced Python Wrapper to provide automatic failover capabilities for Amazon
RDS clusters while maintaining comprehensive Prometheus metrics collection.
Key features:
- Automatic failover handling for AWS RDS clusters
- Enhanced Prometheus metrics for AWS-specific events
- Query retry on successful failover
- Configurable AWS wrapper plugins and timeouts
- Seamless integration with existing django-prometheus functionality
The backend adds three new metrics:
- django_db_aws_failover_success_total
- django_db_aws_failover_failed_total
- django_db_aws_transaction_resolution_unknown_total
Usage:
DATABASES = {
'default': {
'ENGINE': 'django_prometheus.db.backends.postgresql_aws',
'OPTIONS': {
'aws_plugins': 'failover,host_monitoring',
'connect_timeout': 30,
'socket_timeout': 30,
},
}
}
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a new PostgreSQL database backend that integrates the AWS Advanced Python Wrapper to provide automatic failover capabilities for Amazon RDS clusters while maintaining comprehensive Prometheus metrics collection.
Features
New Metrics
This backend introduces three new Prometheus metrics:
django_db_aws_failover_success_total- Counter of successful database failoversdjango_db_aws_failover_failed_total- Counter of failed database failoversdjango_db_aws_transaction_resolution_unknown_total- Counter of transactions with unknown resolution statusUsage
Dependencies
This backend requires the AWS Advanced Python Wrapper:
The backend gracefully handles missing dependencies by raising
ImproperlyConfiguredwith clear installation instructions.Implementation Details
Test Plan
Benefits
This enhancement enables django-prometheus users to:
The implementation follows the existing patterns in django-prometheus for database backends and maintains full compatibility with the current API.