Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: go/buildbot/local_db.go

Issue 1722163002: Metrics2: Store a registry of Counters (Closed) Base URL: https://skia.googlesource.com/buildbot@master
Patch Set: Address comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fuzzer/go/generator/afl_generation.go ('k') | go/httputils/http.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 package buildbot 1 package buildbot
2 2
3 import ( 3 import (
4 "bytes" 4 "bytes"
5 "encoding/binary" 5 "encoding/binary"
6 "encoding/gob" 6 "encoding/gob"
7 "fmt" 7 "fmt"
8 "net/http" 8 "net/http"
9 "strconv" 9 "strconv"
10 "strings" 10 "strings"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 } 181 }
182 182
183 // NewLocalDB returns a local DB instance. 183 // NewLocalDB returns a local DB instance.
184 func NewLocalDB(filename string) (DB, error) { 184 func NewLocalDB(filename string) (DB, error) {
185 d, err := bolt.Open(filename, 0600, nil) 185 d, err := bolt.Open(filename, 0600, nil)
186 if err != nil { 186 if err != nil {
187 return nil, err 187 return nil, err
188 } 188 }
189 db := &localDB{ 189 db := &localDB{
190 db: d, 190 db: d,
191 » » txCount: metrics2.NewCounter("db-active-tx", map[string]string{ 191 » » txCount: metrics2.GetCounter("db-active-tx", map[string]string{
192 "database": "buildbot", 192 "database": "buildbot",
193 }), 193 }),
194 txNextId: 0, 194 txNextId: 0,
195 txActive: map[int64]string{}, 195 txActive: map[int64]string{},
196 txMutex: sync.RWMutex{}, 196 txMutex: sync.RWMutex{},
197 } 197 }
198 go func() { 198 go func() {
199 for _ = range time.Tick(time.Minute) { 199 for _ = range time.Tick(time.Minute) {
200 db.reportActiveTx() 200 db.reportActiveTx()
201 } 201 }
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 w.Header().Set("Content-Length", strconv.Itoa(int(tx.Siz e()))) 987 w.Header().Set("Content-Length", strconv.Itoa(int(tx.Siz e())))
988 _, err := tx.WriteTo(w) 988 _, err := tx.WriteTo(w)
989 return err 989 return err
990 }); err != nil { 990 }); err != nil {
991 httputils.ReportError(w, r, err, fmt.Sprintf("Failed to create DB backup: %s", err)) 991 httputils.ReportError(w, r, err, fmt.Sprintf("Failed to create DB backup: %s", err))
992 } 992 }
993 }) 993 })
994 http.Handle("/", httputils.LoggingGzipRequestResponse(r)) 994 http.Handle("/", httputils.LoggingGzipRequestResponse(r))
995 return http.ListenAndServe(port, nil) 995 return http.ListenAndServe(port, nil)
996 } 996 }
OLDNEW
« no previous file with comments | « fuzzer/go/generator/afl_generation.go ('k') | go/httputils/http.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698