diff --git a/contentserver.go b/contentserver.go index 23c4403..b4a54fe 100644 --- a/contentserver.go +++ b/contentserver.go @@ -58,13 +58,11 @@ func main() { }() if *flagFreeOSMem > 0 { - Log.Info("dumping heap every $interval minutes", zap.Int("interval", *flagHeapDump)) Log.Info("freeing OS memory every $interval minutes", zap.Int("interval", *flagFreeOSMem)) go func() { for { select { case <-time.After(time.Duration(*flagFreeOSMem) * time.Minute): - Log.Info("dumping heap every $interval minutes", zap.Int("interval", *flagHeapDump)) log.Info("FreeOSMemory") debug.FreeOSMemory() } diff --git a/repo/loader.go b/repo/loader.go index fa1cc4b..4b4618f 100644 --- a/repo/loader.go +++ b/repo/loader.go @@ -249,6 +249,7 @@ func (repo *Repo) loadJSONBytes() error { historyErr := repo.history.add(repo.jsonBuf.Bytes()) if historyErr != nil { Log.Error("could not add valid json to history", zap.Error(historyErr)) + status.M.HistoryPersistFailedCounter.WithLabelValues(historyErr.Error()).Inc() } else { Log.Info("added valid json to history") } diff --git a/repo/repo.go b/repo/repo.go index 2a7c22f..23405de 100644 --- a/repo/repo.go +++ b/repo/repo.go @@ -10,6 +10,8 @@ import ( "strings" "time" + "github.com/foomo/contentserver/status" + "github.com/mgutz/ansi" "github.com/foomo/contentserver/content" @@ -275,7 +277,8 @@ func (repo *Repo) Update() (updateResponse *responses.Update) { // persist the currently loaded one historyErr := repo.history.add(repo.jsonBuf.Bytes()) if historyErr != nil { - Log.Warn("could not persist current repo in history", zap.Error(historyErr)) + Log.Error("could not persist current repo in history", zap.Error(historyErr)) + status.M.HistoryPersistFailedCounter.WithLabelValues(historyErr.Error()).Inc() } // add some stats for dimension := range repo.Directory { diff --git a/status/metrics.go b/status/metrics.go index 36d69c8..61cc44b 100644 --- a/status/metrics.go +++ b/status/metrics.go @@ -19,14 +19,15 @@ const ( // Metrics is the structure that holds all prometheus metrics type Metrics struct { - ServiceRequestCounter *prometheus.CounterVec // count the number of requests for each service function - ServiceRequestDuration *prometheus.SummaryVec // observe the duration of requests for each service function - UpdatesRejectedCounter *prometheus.CounterVec // count the number of completed updates - UpdatesCompletedCounter *prometheus.CounterVec // count the number of rejected updates - UpdatesFailedCounter *prometheus.CounterVec // count the number of updates that had an error - UpdateDuration *prometheus.SummaryVec // observe the duration of each repo.update() call - ContentRequestCounter *prometheus.CounterVec // count the total number of content requests - NumSocketsGauge *prometheus.GaugeVec // keep track of the total number of open sockets + ServiceRequestCounter *prometheus.CounterVec // count the number of requests for each service function + ServiceRequestDuration *prometheus.SummaryVec // observe the duration of requests for each service function + UpdatesRejectedCounter *prometheus.CounterVec // count the number of completed updates + UpdatesCompletedCounter *prometheus.CounterVec // count the number of rejected updates + UpdatesFailedCounter *prometheus.CounterVec // count the number of updates that had an error + UpdateDuration *prometheus.SummaryVec // observe the duration of each repo.update() call + ContentRequestCounter *prometheus.CounterVec // count the total number of content requests + NumSocketsGauge *prometheus.GaugeVec // keep track of the total number of open sockets + HistoryPersistFailedCounter *prometheus.CounterVec // count the number of failed attempts to persist the content history } // newMetrics can be used to instantiate a metrics instance @@ -72,6 +73,11 @@ func newMetrics() *Metrics { "Total number of currently open socket connections", metricLabelRemote, ), + HistoryPersistFailedCounter: newCounterVec( + "history_persist_failed_count", + "Number of failures to store the content history on the filesystem", + metricLabelError, + ), } }