Record a geo failover. Args: fail_from: Database failed from fail_to: Database failed to reason: Reason for the failover
(
fail_from: "SyncDatabase",
fail_to: "SyncDatabase",
reason: GeoFailoverReason,
)
| 793 | |
| 794 | |
| 795 | def record_geo_failover( |
| 796 | fail_from: "SyncDatabase", |
| 797 | fail_to: "SyncDatabase", |
| 798 | reason: GeoFailoverReason, |
| 799 | ) -> None: |
| 800 | """ |
| 801 | Record a geo failover. |
| 802 | |
| 803 | Args: |
| 804 | fail_from: Database failed from |
| 805 | fail_to: Database failed to |
| 806 | reason: Reason for the failover |
| 807 | """ |
| 808 | global _metrics_collector |
| 809 | |
| 810 | if _metrics_collector is None: |
| 811 | _metrics_collector = _get_or_create_collector() |
| 812 | if _metrics_collector is None: |
| 813 | return |
| 814 | |
| 815 | try: |
| 816 | _metrics_collector.record_geo_failover( |
| 817 | fail_from=fail_from, |
| 818 | fail_to=fail_to, |
| 819 | reason=reason, |
| 820 | ) |
| 821 | except Exception: |
| 822 | pass |
| 823 | |
| 824 | |
| 825 | def _get_or_create_collector() -> Optional[RedisMetricsCollector]: |