From b0ebc856d97dadf0373cc477f3b8c79c882fdeeb Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Sat, 14 Nov 2020 22:56:55 +1100 Subject: [PATCH] sqlite storage: Add some expvars --- storage/sqlite/sqlite-storage.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/storage/sqlite/sqlite-storage.go b/storage/sqlite/sqlite-storage.go index 6fc5bc42..66d73a28 100644 --- a/storage/sqlite/sqlite-storage.go +++ b/storage/sqlite/sqlite-storage.go @@ -342,6 +342,8 @@ type writeRequest struct { done chan<- error } +var expvars = expvar.NewMap("sqliteStorage") + // Intentionally avoids holding a reference to *provider to allow it to use a finalizer, and to have // stronger typing on the writes channel. func providerWriter(writes <-chan writeRequest, pool ConnPool) { @@ -376,13 +378,15 @@ func providerWriter(writes <-chan writeRequest, pool ConnPool) { }() // Not sure what to do if this failed. if cantFail != nil { - panic(cantFail) + expvars.Add("batchTransactionErrors", 1) } // Signal done after we know the transaction succeeded. for _, done := range buf { done() } - //log.Printf("batched %v write queries", len(buf)) + expvars.Add("batchTransactions", 1) + expvars.Add("batchedQueries", int64(len(buf))) + log.Printf("batched %v write queries", len(buf)) } }