Skip to content

Commit b039e99

Browse files
authored
client: Set _client_version connection attribute (#978)
1 parent 54778b6 commit b039e99

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

client/conn.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88
"net"
99
"runtime"
10+
"runtime/debug"
1011
"strings"
1112
"time"
1213

@@ -101,12 +102,19 @@ func ConnectWithDialer(ctx context.Context, network, addr, user, password, dbNam
101102

102103
c.BufferSize = defaultBufferSize
103104
c.attributes = map[string]string{
104-
"_client_name": "go-mysql",
105-
// "_client_version": "0.1",
105+
"_client_name": "go-mysql",
106106
"_os": runtime.GOOS,
107107
"_platform": runtime.GOARCH,
108108
"_runtime_version": runtime.Version(),
109109
}
110+
if buildInfo, ok := debug.ReadBuildInfo(); ok {
111+
for _, bi := range buildInfo.Deps {
112+
if bi.Path == "github.com/go-mysql-org/go-mysql" {
113+
c.attributes["_client_version"] = bi.Version
114+
break
115+
}
116+
}
117+
}
110118

111119
if network == "" {
112120
network = getNetProto(addr)

0 commit comments

Comments
 (0)