]> Sergey Matveev's repositories - btrtrc.git/commitdiff
sqlite storage: Add some expvars
authorMatt Joiner <anacrolix@gmail.com>
Sat, 14 Nov 2020 11:56:55 +0000 (22:56 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 16 Nov 2020 05:37:11 +0000 (16:37 +1100)
storage/sqlite/sqlite-storage.go

index 6fc5bc42c34f161203aa22cacd34fbd256f897e8..66d73a28dec23b13450df0059a2129caeb93a8e0 100644 (file)
@@ -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))
        }
 }