Skip to content

Commit 7dd4d6b

Browse files
committed
decouple: Improve log message
- Add the numbers for requests processed.
1 parent b88525c commit 7dd4d6b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

mirror/modules/control/decouple.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,11 @@ func (m *Decouple) Output() <-chan mirror.Request {
6868

6969
func (m *Decouple) SetInput(c <-chan mirror.Request) {
7070
dropped := uint32(0)
71+
processed := uint32(0)
7172

7273
go func() {
7374
for r := range c {
75+
atomic.AddUint32(&processed, 1)
7476
m.ctx.HandledRequest()
7577
select {
7678
case m.out <- r:
@@ -85,12 +87,13 @@ func (m *Decouple) SetInput(c <-chan mirror.Request) {
8587
if !m.quiet {
8688
go func() {
8789
for range time.Tick(logDroppedInterval) {
88-
v := atomic.SwapUint32(&dropped, 0)
89-
if v == 0 {
90+
d := atomic.SwapUint32(&dropped, 0)
91+
p := atomic.SwapUint32(&processed, 0)
92+
if d == 0 {
9093
continue
9194
}
9295

93-
log.Warnf("%s: dropped %d requests", DecoupleName, v)
96+
log.Warnf("%s: dropped %d of %d requests", DecoupleName, d, p)
9497
}
9598
}()
9699
}

0 commit comments

Comments
 (0)