feat(autosync): add structured logging with slog to background sync manager#52
Closed
Tech-Code1 wants to merge 2 commits intoGentleman-Programming:mainfrom
Closed
Conversation
…anager The autosync manager ran completely silently. When cloud sync stopped working, there was no way to know if the lease was being contested, how many mutations were pending, or what the backoff state was without inspecting the database directly. Add slog logging at key lifecycle points using Go's standard log/slog package (available since Go 1.21): - Info on manager start/stop with config summary - Debug when skipping a cycle due to backoff or lease contention - Warn when lease acquisition errors occur - Debug on push with pending mutation count and per-project batch results - Debug on pull with applied mutation count and final seq cursor - Warn on push/pull failures with elapsed time - Warn when recording a failure with consecutive failure count and backoff deadline - Info when sync returns to healthy state
Collaborator
Alan-TheGentleman
left a comment
There was a problem hiding this comment.
This is useful — the autosync manager was a black box before, and structured logging with proper levels (Info for lifecycle, Warn for failures, Debug for cycle details) is exactly what was needed.
One thing I'd like to see before merging:
- Manual prefix
"autosync: "in every message —slogsupports logger groups (slog.With("component", "autosync")orlogger.WithGroup("autosync")) which would give you the same namespacing without repeating the prefix string everywhere. If we add slog to other packages later, we don't want manual prefixes scattered around. Can you use a named logger orslog.Withinstead? Something like:
logger := slog.Default().With("component", "autosync")
// then: logger.Info("manager started", ...)This keeps the output structured and avoids the string prefix convention.
Once that's updated, this is good to merge.
…anual prefix
Replace bare slog.XXX("autosync: ...") calls with a component-scoped
logger initialized as slog.Default().With("component", "autosync").
This keeps namespacing consistent and structured without repeating a
string prefix in every log message.
Collaborator
|
Hey @Tech-Code1, thanks for this work! Unfortunately we've removed the cloud packages from the public repo — cloud sync is still under active development in a separate repository. This PR no longer has a target to apply to. If/when cloud ships publicly, structured logging will definitely be part of it. Appreciate the contribution! |
This was referenced Mar 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The autosync background manager ran completely silently. When cloud sync stopped working, the only way to diagnose the issue was to query the database directly and inspect the degraded state columns.
This PR adds structured logging using Go's standard
log/slogpackage (available since Go 1.21, no new dependencies) at every meaningful lifecycle point in the manager.What gets logged
Infotarget_key,poll_interval,push_batch,pull_batchInfotarget_keyDebugbackoff_until,consecutive_failuresWarnconsecutive_failures,maxWarnerrorDebugDebugDebugcountDebugproject,mutationsWarnerror,elapsedDebuglast_seqDebugmutations_applied,last_seqWarnerror,elapsedWarnerror,consecutive_failures,backoff_untilInfolast_sync_atDebugelapsedWhy slog?
Test plan
go build ./...)🤖 Generated with Claude Code