Skip to content

Commit

Permalink
log summary of compact snapshots submitted every minute
Browse files Browse the repository at this point in the history
  • Loading branch information
seanlinsley committed Oct 25, 2023
1 parent 7b95308 commit 4eac449
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion output/compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"io"
"net/http"
"net/url"
"sort"
"strings"
"time"

Expand Down Expand Up @@ -48,7 +49,7 @@ func uploadAndSubmitCompactSnapshot(ctx context.Context, s pganalyze_collector.C
if collectionOpts.OutputAsJson {
debugCompactOutputAsJSON(logger, compressedData)
} else if !quiet {
logger.PrintVerbose("Collected compact %s snapshot successfully", kind)
logger.PrintInfo("Collected compact %s snapshot successfully", kind)
}
return nil
}
Expand Down Expand Up @@ -138,7 +139,30 @@ func submitCompactSnapshot(ctx context.Context, server *state.Server, collection
logger.PrintInfo(" %s", msg)
} else if !quiet {
logger.PrintVerbose("Submitted compact %s snapshot successfully", kind)
if time.Now().Sub(lastLog) > time.Minute {
lastLog = time.Now()
details := ""
var keys []string
for k := range callCounts {
keys = append(keys, k)
}
sort.Strings(keys)
for i, kind := range keys {
details += fmt.Sprintf("%d %s", callCounts[kind], kind)
if i < len(keys)-1 {
details += ", "
}
}
logger.PrintInfo("Compact snapshots submitted over the past minute: " + details)
callCounts = make(map[string]uint8)
} else {
callCounts[kind] = callCounts[kind] + 1
}

}

return nil
}

var callCounts = make(map[string]uint8)
var lastLog = time.Now()

0 comments on commit 4eac449

Please sign in to comment.