-
Notifications
You must be signed in to change notification settings - Fork 346
Open
Description
Summary
After fixing default slog usage in #1178, the next logical step is to add .With() context to all top-level loggers so log lines self-identify which system/subsystem produced them.
Current State
Some components already do this:
- DB:
slog.With("db", filepath.Base(path)) - Replica:
logger.With("replica", r.Client.Type()) - VFS:
logger.With("vfs", "true")and.With("name", filename)
But Store, Server, Compactor, WALReader, and all replica clients log without system identification.
Proposed Hierarchy
Store: slog.Default().With("system", "store")
└─ DB: store.Logger.With("db", "mydb.sqlite") // already done
└─ Replica: db.Logger.With("replica", "s3") // already done
└─ Client: replica.Logger().WithGroup("s3") // needs parent propagation
└─ Compactor: db.Logger.With("subsystem", "compactor") // needs adding
└─ WALReader: db.Logger.With("subsystem", "wal-reader") // needs adding
Server: slog.Default().With("system", "server")
Example log output:
level=INFO msg="compacted snapshots" system=store db=mydb.sqlite subsystem=compactor
Key Changes Needed
Tier 1 — Top-level (Store, Server)
store.go:s.Logger = slog.Default().With("system", "store")server.go:logger = slog.Default().With("system", "server")
Tier 2 — Subsystems (Compactor, WALReader)
- Add
.With("subsystem", "compactor")and.With("subsystem", "wal-reader")
Tier 3 — Replica clients (structural change)
- All 8 replica clients (
s3,file,sftp,gs,webdav,oss,abs,nats) create loggers fromslog.Default()instead of inheriting from their parent Replica/DB - Need to accept a parent logger parameter (or
SetLoggermethod) so context flows through the hierarchy - S3 Leaser (
s3/leaser.go) has the same issue
Benefits
- Every log line identifies its source system without manual inspection
- Context accumulates through the hierarchy (a compactor log includes the DB name)
- Easier debugging in multi-database setups
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels