diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5971af871..3a5448ccf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,13 +33,13 @@ jobs: with: submodules: true - - name: Runs tests + - name: Lint + run: | + test $(go fmt ./... | wc -l) -eq 0 + + - name: Run tests run: | make build OUTFILE=pganalyze-collector-linux-amd64 make test DOCKER_BUILDKIT=1 make integration_test shellcheck contrib/install.sh - - - name: Lint - run: | - test $(go fmt ./... | wc -l) -eq 0 diff --git a/output/compact.go b/output/compact.go index 2c45d264f..afc7b1e02 100644 --- a/output/compact.go +++ b/output/compact.go @@ -9,6 +9,7 @@ import ( "io" "net/http" "net/url" + "sort" "strings" "time" @@ -137,7 +138,31 @@ func submitCompactSnapshot(ctx context.Context, server *state.Server, collection if len(msg) > 0 && collectionOpts.TestRun { logger.PrintInfo(" %s", msg) } else if !quiet { - logger.PrintInfo("Submitted compact %s snapshot successfully", kind) + logger.PrintVerbose("Submitted compact %s snapshot successfully", kind) + if server.CompactLogTime.IsZero() { + server.CompactLogTime = time.Now().Truncate(time.Minute) + server.CompactLogStats = make(map[string]uint8) + } else if time.Now().Sub(server.CompactLogTime) > time.Minute { + var keys []string + for k := range server.CompactLogStats { + keys = append(keys, k) + } + sort.Strings(keys) + details := "" + for i, kind := range keys { + details += fmt.Sprintf("%d %s", server.CompactLogStats[kind], kind) + if i < len(keys)-1 { + details += ", " + } + } + if len(details) > 0 { + logger.PrintInfo("Compact snapshots submitted: " + details) + } + server.CompactLogTime = time.Now().Truncate(time.Minute) + server.CompactLogStats = make(map[string]uint8) + } else { + server.CompactLogStats[kind] = server.CompactLogStats[kind] + 1 + } } return nil diff --git a/state/state.go b/state/state.go index ddfcc0586..ecd4e3f45 100644 --- a/state/state.go +++ b/state/state.go @@ -286,6 +286,10 @@ type Server struct { // differences (see https://groups.google.com/g/golang-nuts/c/eIqkhXh9PLg), // as we access this in high frequency log-related code paths. LogIgnoreFlags uint32 + + // State to track compact snapshot submissions, and log them routinely + CompactLogStats map[string]uint8 + CompactLogTime time.Time } func MakeServer(config config.ServerConfig) *Server {