@@ -14,6 +14,7 @@ import (
1414
1515 "github.com/ydb-platform/ydb-go-sdk/v3/internal/bind"
1616 "github.com/ydb-platform/ydb-go-sdk/v3/internal/query"
17+ "github.com/ydb-platform/ydb-go-sdk/v3/internal/stack"
1718 "github.com/ydb-platform/ydb-go-sdk/v3/internal/xcontext"
1819 "github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors"
1920 "github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql/legacy"
@@ -67,8 +68,8 @@ func (e Engine) String() string {
6768 switch e {
6869 case LEGACY :
6970 return "LEGACY"
70- case QUERY_SERVICE :
71- return "QUERY_SERVICE "
71+ case PROPOSE :
72+ return "PROPOSE "
7273 default :
7374 return "UNKNOWN"
7475 }
@@ -115,26 +116,33 @@ func (c *Connector) Scheme() scheme.Client {
115116}
116117
117118const (
118- QUERY_SERVICE = iota + 1 //nolint:revive,stylecheck
119- LEGACY //nolint:revive,stylecheck
119+ PROPOSE = iota + 1
120+ LEGACY
120121)
121122
122123func (c * Connector ) Open (name string ) (driver.Conn , error ) {
123124 return nil , xerrors .WithStackTrace (driver .ErrSkip )
124125}
125126
126- func (c * Connector ) Connect (ctx context.Context ) (driver.Conn , error ) {
127+ func (c * Connector ) Connect (ctx context.Context ) (_ driver.Conn , finalErr error ) { //nolint:funlen
128+ onDone := trace .DatabaseSQLOnConnectorConnect (c .Trace (), & ctx ,
129+ stack .FunctionID ("" , stack .Package ("database/sql" )),
130+ )
131+
127132 switch c .processor {
128- case QUERY_SERVICE :
133+ case PROPOSE :
129134 s , err := query .CreateSession (ctx , c .Query ())
135+ defer func () {
136+ onDone (s , finalErr )
137+ }()
130138 if err != nil {
131139 return nil , xerrors .WithStackTrace (err )
132140 }
133141
134142 id := uuid .New ()
135143
136144 conn := & Conn {
137- processor : QUERY_SERVICE ,
145+ processor : PROPOSE ,
138146 cc : propose .New (ctx , c , s , append (
139147 c .Options ,
140148 propose .WithOnClose (func () {
@@ -152,6 +160,9 @@ func (c *Connector) Connect(ctx context.Context) (driver.Conn, error) {
152160
153161 case LEGACY :
154162 s , err := c .Table ().CreateSession (ctx ) //nolint:staticcheck
163+ defer func () {
164+ onDone (s , finalErr )
165+ }()
155166 if err != nil {
156167 return nil , xerrors .WithStackTrace (err )
157168 }
@@ -207,7 +218,7 @@ func Open(parent ydbDriver, balancer grpc.ClientConnInterface, opts ...Option) (
207218 balancer : balancer ,
208219 processor : func () Engine {
209220 if overQueryService , _ := strconv .ParseBool (os .Getenv ("YDB_DATABASE_SQL_OVER_QUERY_SERVICE" )); overQueryService {
210- return QUERY_SERVICE
221+ return PROPOSE
211222 }
212223
213224 return LEGACY
0 commit comments