Get recent alerts
(self, limit: int = 100, level: str = None)
| 1648 | |
| 1649 | # Mark this alert as seen with expiry |
| 1650 | self._alert_hashes.add(alert_hash) |
| 1651 | self._alert_hash_expiry[alert_hash] = current_time + self._alert_dedup_window |
| 1652 | |
| 1653 | # Clean up old hash entries periodically |
| 1654 | if len(self._alert_hash_expiry) > 1000: |
| 1655 | expired = [h for h, exp in self._alert_hash_expiry.items() if exp < current_time] |
| 1656 | for h in expired: |
| 1657 | self._alert_hashes.discard(h) |
| 1658 | del self._alert_hash_expiry[h] |
| 1659 | |
| 1660 | self._alert_counter += 1 |
| 1661 | alert = TrafficAlert( |
| 1662 | alert_id=f"TA-{self._alert_counter:06d}", |
| 1663 | level=level, |
no test coverage detected