private/dbutil: add database name to configure as a tag

storagenodes have like 10 or more databases. without this
tag they all get sent as the same value, stomping on each
other.

Change-Id: Ib12019684d6ea8f2a5b83df584056dfa79e3c4b3
This commit is contained in:
Jeff Wendling 2020-03-23 13:58:36 -06:00
parent f879bfcf70
commit 97e980cd8a
7 changed files with 8 additions and 8 deletions

View File

@ -70,7 +70,7 @@ func OpenUnique(ctx context.Context, connStr string, schemaPrefix string) (db *d
return nil, errs.Combine(errs.Wrap(err), cleanup(masterDB))
}
dbutil.Configure(sqlDB, mon)
dbutil.Configure(sqlDB, "tmp_cockroach", mon)
return &dbutil.TempDatabase{
DB: sqlDB,
ConnStr: modifiedConnStr,

View File

@ -26,7 +26,7 @@ type ConfigurableDB interface {
}
// Configure Sets Connection Boundaries and adds db_stats monitoring to monkit
func Configure(db ConfigurableDB, mon *monkit.Scope) {
func Configure(db ConfigurableDB, dbName string, mon *monkit.Scope) {
if *maxIdleConns >= 0 {
db.SetMaxIdleConns(*maxIdleConns)
}
@ -38,6 +38,6 @@ func Configure(db ConfigurableDB, mon *monkit.Scope) {
}
mon.Chain(monkit.StatSourceFunc(
func(cb func(key monkit.SeriesKey, field string, val float64)) {
monkit.StatSourceFromStruct(monkit.NewSeriesKey("db_stats"), db.Stats()).Stats(cb)
monkit.StatSourceFromStruct(monkit.NewSeriesKey("db_stats").WithTag("db_name", dbName), db.Stats()).Stats(cb)
}))
}

View File

@ -51,7 +51,7 @@ func OpenUnique(ctx context.Context, connstr string, schemaPrefix string) (*dbut
return DropSchema(ctx, cleanupDB, schemaName)
}
dbutil.Configure(db, mon)
dbutil.Configure(db, "tmp_postgres", mon)
return &dbutil.TempDatabase{
DB: db,
ConnStr: connStrWithSchema,

View File

@ -79,7 +79,7 @@ func New(log *zap.Logger, databaseURL string, opts Options) (satellite.DB, error
}
log.Debug("Connected to:", zap.String("db source", source))
dbutil.Configure(dbxDB.DB, mon)
dbutil.Configure(dbxDB.DB, "satellitedb", mon)
core := &satelliteDB{
DB: dbxDB,

View File

@ -40,7 +40,7 @@ func New(dbURL string) (*Client, error) {
return nil, err
}
dbutil.Configure(db, mon)
dbutil.Configure(db, "cockroachkv", mon)
// TODO: new shouldn't be taking ctx as argument
err = schema.PrepareDB(context.TODO(), db)

View File

@ -38,7 +38,7 @@ func New(dbURL string) (*Client, error) {
return nil, err
}
dbutil.Configure(db, mon)
dbutil.Configure(db, "postgreskv", mon)
//TODO: Fix the parameters!!
err = schema.PrepareDB(context.TODO(), db, dbURL)
if err != nil {

View File

@ -265,7 +265,7 @@ func (db *DB) openDatabase(dbName string) error {
mDB := db.SQLDBs[dbName]
mDB.Configure(sqlDB)
dbutil.Configure(sqlDB, mon)
dbutil.Configure(sqlDB, dbName, mon)
return nil
}