You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Purpose
to implement a rate limit logger that suppress duplicate messages in a
short time
## Modifications
add a rate limit filter to the self-defined spdlog sink
## Test
### Usage of rate limit interface on python side
```python
def test_log(test: str):
logger.info_once("test log info once")
logger.info_limit("test log info limit %s", test)
for i in range(5):
test_log(f"test{i}")
```
<img width="1315" height="236" alt="image"
src="https://github.com/user-attachments/assets/91cabaef-4aa1-4aaf-b3d8-1178c6b4681d"
/>
### will print when last log time has reached its time to live which set
to 10s in testing and 60s on production
```python
import time
for i in range(3):
if i == 2:
time.sleep(11)
logger.info_limit("test message %d", i)
```
<img width="903" height="146" alt="image"
src="https://github.com/user-attachments/assets/111298d4-61fc-4ac3-a5dd-8ca398364cee"
/>
### Usage of rate limit interface on CPP side
```cpp
for (int i = 0;i < 5;i++) {
UC_INFO_LIMIT("test message {}", i);
}
```
<img width="919" height="90" alt="image"
src="https://github.com/user-attachments/assets/5b68e70f-95eb-4a5b-98df-340cf83a7da1"
/>
### performance test
We run two performance tests on comparing the latency of duplicate
filtering log interface and the plain log interface, by logging same
messages / randomly generated message 2000 times.
<img width="1535" height="674" alt="image"
src="https://github.com/user-attachments/assets/0bb36caf-f6a2-4afe-9e99-e2f27784fa4e"
/>
0 commit comments