mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-23 00:50:20 +08:00
chore: only upload metrics on mysql (#4591)
This commit is contained in:
parent
1023800b02
commit
520d2a2075
@ -27,19 +27,21 @@ func getCachedSqlConn(driverName, server string) (*sql.DB, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if cfg, e := mysql.ParseDSN(server); e != nil {
|
||||
// if cannot parse, don't collect the metrics
|
||||
logx.Error(e)
|
||||
} else {
|
||||
checksum := sha256.Sum256([]byte(server))
|
||||
connCollector.registerClient(&statGetter{
|
||||
host: cfg.Addr,
|
||||
dbName: cfg.DBName,
|
||||
hash: hex.EncodeToString(checksum[:]),
|
||||
poolStats: func() sql.DBStats {
|
||||
return conn.Stats()
|
||||
},
|
||||
})
|
||||
if driverName != mysqlDriverName {
|
||||
if cfg, e := mysql.ParseDSN(server); e != nil {
|
||||
// if cannot parse, don't collect the metrics
|
||||
logx.Error(e)
|
||||
} else {
|
||||
checksum := sha256.Sum256([]byte(server))
|
||||
connCollector.registerClient(&statGetter{
|
||||
host: cfg.Addr,
|
||||
dbName: cfg.DBName,
|
||||
hash: hex.EncodeToString(checksum[:]),
|
||||
poolStats: func() sql.DBStats {
|
||||
return conn.Stats()
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return conn, nil
|
||||
|
Loading…
Reference in New Issue
Block a user