Skip to content

feat: deduplicate repeated log events within time window #4

Description

@cncoder

背景

实测场景:Discord 重连失败时每 ~40s log 一条 "Max reconnect attempts (1/10)",10 分钟内可以刷满屏。同一 event_key 高频重复对排障没帮助,还掩盖其他真正的错误。

提案

在 logger 层加一个去重中间件:

  • 5 分钟滑动窗口内相同 event_key 只 log 首次 + 末次
  • 中间次数用 counter 聚合:`(repeated 23 times in last 5min)`
  • event_key 从消息模板派生(去掉动态字段如 timestamp / id)
  • 可通过 `logging.dedup = false` 关闭

影响

日志量显著下降,核心事件不被淹没。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions