From 81fc0bfb5a65dc3f61f84307d525c92d04547c61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= <git@myname.nl> Date: Fri, 5 May 2023 15:04:46 +0200 Subject: [PATCH 1/2] Set library specific connection attributes --- client/conn.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/client/conn.go b/client/conn.go index 8b2940ee8..13a517636 100644 --- a/client/conn.go +++ b/client/conn.go @@ -6,6 +6,7 @@ import ( "crypto/tls" "fmt" "net" + "runtime" "strings" "time" @@ -78,6 +79,14 @@ type Dialer func(ctx context.Context, network, address string) (net.Conn, error) func ConnectWithDialer(ctx context.Context, network string, addr string, user string, password string, dbName string, dialer Dialer, options ...func(*Conn)) (*Conn, error) { c := new(Conn) + c.attributes = map[string]string{ + "_client_name": "go-mysql", + // "_client_version": "0.1", + "_os": runtime.GOOS, + "_platform": runtime.GOARCH, + "_runtime_version": runtime.Version(), + } + if network == "" { network = getNetProto(addr) } @@ -317,7 +326,9 @@ func (c *Conn) Rollback() error { } func (c *Conn) SetAttributes(attributes map[string]string) { - c.attributes = attributes + for k, v := range attributes { + c.attributes[k] = v + } } func (c *Conn) SetCharset(charset string) error { From b401eead57e6ac22752da25b2c887ad696d0da70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= <git@myname.nl> Date: Fri, 5 May 2023 15:12:09 +0200 Subject: [PATCH 2/2] Set _client_role attribute for binlogsyncer --- replication/binlogsyncer.go | 1 + 1 file changed, 1 insertion(+) diff --git a/replication/binlogsyncer.go b/replication/binlogsyncer.go index 7f8b06b72..9c70740fc 100644 --- a/replication/binlogsyncer.go +++ b/replication/binlogsyncer.go @@ -891,6 +891,7 @@ func (b *BinlogSyncer) newConnection(ctx context.Context) (*client.Conn, error) return client.ConnectWithDialer(timeoutCtx, "", addr, b.cfg.User, b.cfg.Password, "", b.cfg.Dialer, func(c *client.Conn) { c.SetTLSConfig(b.cfg.TLSConfig) + c.SetAttributes(map[string]string{"_client_role": "binary_log_listener"}) }) }