fix: route snapshot fetcher and gRPC auth logs through the app logger - #1806
Conversation
✅ Approve — automated reviewThe logger is consistently injected into snapshot-fetcher and gRPC request contexts, with regression tests covering unary, streaming, and snapshot paths. No actionable defects were found. No findings. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release/v3.0 #1806 +/- ##
================================================
+ Coverage 77.01% 77.08% +0.06%
================================================
Files 477 478 +1
Lines 51141 51155 +14
================================================
+ Hits 39388 39432 +44
+ Misses 8318 8291 -27
+ Partials 3435 3432 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Arbitration — PR #1806: route snapshot fetcher and gRPC auth logs through the app loggerI re-verified the production code and the disputed test claims directly at Agreed findings
Ruled disputes
Not in dispute, recorded for completeness: both reviewers agree the HTTP mirror ( Reviewed by Claude (claude-opus-4-8) and Codex (gpt-5.6-sol) via Shipfox; arbitrated by Claude. |
|
Addressed the P2 test-coverage finding in 9e2d295: added |
9e2d295 to
35acc30
Compare
logging.FromContext falls back to a bare logrus text logger on stderr when the context carries no logger. The snapshot fetcher resolved its logger from the applier's sync context, and gRPC auth failures from the raw request context, so both emitted logrus-formatted lines alongside the zap-formatted output of the rest of the process. Inject the app logger into the snapshot fetcher provider and add a logger-injecting interceptor pair to the service gRPC server, mirroring the existing HTTP loggerMiddleware. Rejected: attaching the logger to the root fx context | applier/sync contexts are built from several places; explicit injection matches how every other component receives its logger Confidence: high Scope-risk: narrow Directive: prefer injected loggers over logging.FromContext outside request-scoped handlers whose middleware attaches one
Address the review finding that the logging fix was not behaviorally covered: reverting the fetcher to logging.FromContext or dropping the gRPC logger interceptors kept the suite green. Both tests drive the real code path with a buffered app logger and assert the emitted lines land there. The gRPC test runs the actual NewServiceServer chain over an injected listener and exercises a unary and a streaming RPC. Mutation-checked: each test fails with its fix reverted. Confidence: high Scope-risk: narrow
35acc30 to
4f447af
Compare
gfyrag
left a comment
There was a problem hiding this comment.
Reviewed head 4f447af.
The existing HTTP middleware already injects the logger, while the pre-existing gRPC logging interceptor only emitted request logs and did not enrich request contexts. The new unary/stream interceptors correctly cover gRPC auth logging, and explicit injection remains necessary for the background snapshot fetcher. Focused gRPC and snapshot-fetcher tests pass. No blocking findings.
Problem
Process output mixed two log formats:
Both call sites use the same
logging.Loggerinterface, but go-libs'logging.FromContext(ctx)silently falls back to a fresh logrus text logger on stderr when the context carries no logger. The snapshot fetcher resolved its logger from the applier's sync context (never has one attached), and gRPC auth failures (logAuthFailure) from the raw request context.Fix
internal/application/ctrl/snapshot_fetcher.go: provider/fetcher take an injectedlogging.Logger(taggedcmp=snapshot-fetcher) and uselogger.WithContext(ctx)instead ofFromContext.internal/bootstrap/module.go: pass the app logger intoGRPCSnapshotFetcherProvider.internal/adapter/grpc/logger_interceptor.go(new) +server.go: unary/stream interceptors inject the logger into service gRPC request contexts, mirroring the existing HTTPloggerMiddleware. Fixes the same leak for gRPC auth-failure logs.logger: logging.Testing().Remaining
FromContextcallers (HTTP handlers/middleware, e2e testutil) already run under a context with the logger attached.Validation
GOROOT= go build ./...,golangci-linton touched packages (0 issues),git diff --checkgo test ./internal/application/ctrl/ ./internal/adapter/grpc/ ./internal/adapter/auth/ ./internal/bootstrap/— passscripts/agent-checklint stage reports pre-existing issues in generated*.pb.gofiles only; nothing in touched files.