Skip to content

Commit 2419271

Browse files
0x46616c6bOpenCode
andcommitted
Add queue_id to policy server log messages
Include the Postfix queue_id in all log messages within handleRequest for easier correlation with Postfix mail logs. Co-Authored-By: OpenCode <noreply@opencode.ai>
1 parent 8a9ef38 commit 2419271

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

policy.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ func (p *PolicyServer) handleRequest(ctx context.Context, req *PolicyRequest) st
162162
startTime := time.Now()
163163

164164
logger.Debug("Processing policy request",
165+
zap.String("queue_id", req.QueueID),
165166
zap.String("sender", req.Sender),
166167
zap.String("sasl_username", req.SaslUsername),
167168
zap.String("protocol", req.ProtocolState))
@@ -196,6 +197,7 @@ func (p *PolicyServer) handleRequest(ctx context.Context, req *PolicyRequest) st
196197
if err != nil {
197198
// API error - fail open (allow the message)
198199
logger.Warn("Failed to fetch quota, allowing message",
200+
zap.String("queue_id", req.QueueID),
199201
zap.String("sender", sender), zap.Error(err))
200202
policyRequestsTotal.WithLabelValues("check", "error").Inc()
201203
policyRequestDuration.WithLabelValues("check", "error").Observe(time.Since(startTime).Seconds())
@@ -218,6 +220,7 @@ func (p *PolicyServer) handleRequest(ctx context.Context, req *PolicyRequest) st
218220

219221
if !allowed {
220222
logger.Info("Rate limit exceeded",
223+
zap.String("queue_id", req.QueueID),
221224
zap.String("sender", sender),
222225
zap.Int("hour_count", hourCount),
223226
zap.Int("day_count", dayCount),
@@ -232,6 +235,7 @@ func (p *PolicyServer) handleRequest(ctx context.Context, req *PolicyRequest) st
232235
}
233236

234237
logger.Debug("Message allowed",
238+
zap.String("queue_id", req.QueueID),
235239
zap.String("sender", sender),
236240
zap.Int("hour_count", hourCount),
237241
zap.Int("day_count", dayCount),

0 commit comments

Comments
 (0)