From 520d2a20756fac143083e14259b6e70fc688ce11 Mon Sep 17 00:00:00 2001 From: Kevin Wan Date: Wed, 22 Jan 2025 20:26:24 +0800 Subject: [PATCH] chore: only upload metrics on mysql (#4591) --- core/stores/sqlx/sqlmanager.go | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/core/stores/sqlx/sqlmanager.go b/core/stores/sqlx/sqlmanager.go index a38063c6..1bcdcf19 100644 --- a/core/stores/sqlx/sqlmanager.go +++ b/core/stores/sqlx/sqlmanager.go @@ -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