Skip to content

Commit f5344ec

Browse files
committed
fix: log cache miss for all callers, not just the fetcher
Move the cache miss log before Coalesce so coalesced waiters also get a log entry. The upstream client already logs request completion with duration, so fetches vs coalesced waits are distinguishable.
1 parent 636a0c0 commit f5344ec

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

internal/proxy/proxy.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,15 @@ func (p *Proxy) handleRead(ctx context.Context, req *modbus.Request) ([]byte, er
117117
}
118118

119119
// Cache miss — fetch with coalescing
120+
p.logger.Debug("cache miss",
121+
"slave_id", req.SlaveID,
122+
"func", fmt.Sprintf("0x%02X", req.FunctionCode),
123+
"addr", req.Address,
124+
"qty", req.Quantity,
125+
)
126+
120127
rangeKey := cache.RangeKey(req.SlaveID, req.FunctionCode, req.Address, req.Quantity)
121128
data, err := p.cache.Coalesce(ctx, rangeKey, func(ctx context.Context) ([]byte, error) {
122-
p.logger.Debug("cache miss",
123-
"slave_id", req.SlaveID,
124-
"func", fmt.Sprintf("0x%02X", req.FunctionCode),
125-
"addr", req.Address,
126-
"qty", req.Quantity,
127-
)
128-
129129
return p.client.Execute(ctx, req)
130130
})
131131

0 commit comments

Comments
 (0)