@@ -237,6 +237,7 @@ func (c *Client) Do(ctx context.Context, op query.Operation, opts ...options.DoO
237237 settings = options .ParseDoOpts (c .config .Trace (), opts ... )
238238 onDone = trace .QueryOnDo (settings .Trace (), & ctx ,
239239 stack .FunctionID ("github.com/ydb-platform/ydb-go-sdk/v3/internal/query.(*Client).Do" ),
240+ settings .Label (),
240241 )
241242 attempts = 0
242243 )
@@ -321,15 +322,17 @@ func (c *Client) QueryRow(ctx context.Context, q string, opts ...options.Execute
321322 ctx , cancel := xcontext .WithDone (ctx , c .done )
322323 defer cancel ()
323324
325+ settings := options .ExecuteSettings (opts ... )
326+
324327 onDone := trace .QueryOnQueryRow (c .config .Trace (), & ctx ,
325328 stack .FunctionID ("github.com/ydb-platform/ydb-go-sdk/v3/internal/query.(*Client).QueryRow" ),
326- q ,
329+ q , settings . Label (),
327330 )
328331 defer func () {
329332 onDone (finalErr )
330333 }()
331334
332- row , err := clientQueryRow (ctx , c .pool , q , options . ExecuteSettings ( opts ... ) , withTrace (c .config .Trace ()))
335+ row , err := clientQueryRow (ctx , c .pool , q , settings , withTrace (c .config .Trace ()))
333336 if err != nil {
334337 return nil , xerrors .WithStackTrace (err )
335338 }
@@ -366,9 +369,11 @@ func (c *Client) Exec(ctx context.Context, q string, opts ...options.Execute) (f
366369 ctx , cancel := xcontext .WithDone (ctx , c .done )
367370 defer cancel ()
368371
372+ settings := options .ExecuteSettings (opts ... )
369373 onDone := trace .QueryOnExec (c .config .Trace (), & ctx ,
370374 stack .FunctionID ("github.com/ydb-platform/ydb-go-sdk/v3/internal/query.(*Client).Exec" ),
371375 q ,
376+ settings .Label (),
372377 )
373378 defer func () {
374379 onDone (finalErr )
@@ -413,9 +418,10 @@ func (c *Client) Query(ctx context.Context, q string, opts ...options.Execute) (
413418 ctx , cancel := xcontext .WithDone (ctx , c .done )
414419 defer cancel ()
415420
421+ settings := options .ExecuteSettings (opts ... )
416422 onDone := trace .QueryOnQuery (c .config .Trace (), & ctx ,
417423 stack .FunctionID ("github.com/ydb-platform/ydb-go-sdk/v3/internal/query.(*Client).Query" ),
418- q ,
424+ q , settings . Label (),
419425 )
420426 defer func () {
421427 onDone (err )
@@ -431,7 +437,7 @@ func (c *Client) Query(ctx context.Context, q string, opts ...options.Execute) (
431437
432438func clientQueryResultSet (
433439 ctx context.Context , pool sessionPool , q string , settings executeSettings , resultOpts ... resultOption ,
434- ) (rs result.ClosableResultSet , finalErr error ) {
440+ ) (rs result.ClosableResultSet , rowsCount int , finalErr error ) {
435441 err := do (ctx , pool , func (ctx context.Context , s * Session ) error {
436442 streamResult , err := s .execute (ctx , q , settings , resultOpts ... )
437443 if err != nil {
@@ -441,18 +447,18 @@ func clientQueryResultSet(
441447 _ = streamResult .Close (ctx )
442448 }()
443449
444- rs , err = readMaterializedResultSet (ctx , streamResult )
450+ rs , rowsCount , err = readMaterializedResultSet (ctx , streamResult )
445451 if err != nil {
446452 return xerrors .WithStackTrace (err )
447453 }
448454
449455 return nil
450456 }, settings .RetryOpts ()... )
451457 if err != nil {
452- return nil , xerrors .WithStackTrace (err )
458+ return nil , 0 , xerrors .WithStackTrace (err )
453459 }
454460
455- return rs , nil
461+ return rs , rowsCount , nil
456462}
457463
458464// QueryResultSet is a helper which read all rows from first result set in result
@@ -462,15 +468,21 @@ func (c *Client) QueryResultSet(
462468 ctx , cancel := xcontext .WithDone (ctx , c .done )
463469 defer cancel ()
464470
471+ var (
472+ settings = options .ExecuteSettings (opts ... )
473+ rowsCount int
474+ err error
475+ )
476+
465477 onDone := trace .QueryOnQueryResultSet (c .config .Trace (), & ctx ,
466478 stack .FunctionID ("github.com/ydb-platform/ydb-go-sdk/v3/internal/query.(*Client).QueryResultSet" ),
467- q ,
479+ q , settings . Label (),
468480 )
469481 defer func () {
470- onDone (finalErr )
482+ onDone (finalErr , rowsCount )
471483 }()
472484
473- rs , err : = clientQueryResultSet (ctx , c .pool , q , options . ExecuteSettings ( opts ... ) , withTrace (c .config .Trace ()))
485+ rs , rowsCount , err = clientQueryResultSet (ctx , c .pool , q , settings , withTrace (c .config .Trace ()))
474486 if err != nil {
475487 return nil , xerrors .WithStackTrace (err )
476488 }
@@ -486,6 +498,7 @@ func (c *Client) DoTx(ctx context.Context, op query.TxOperation, opts ...options
486498 settings = options .ParseDoTxOpts (c .config .Trace (), opts ... )
487499 onDone = trace .QueryOnDoTx (settings .Trace (), & ctx ,
488500 stack .FunctionID ("github.com/ydb-platform/ydb-go-sdk/v3/internal/query.(*Client).DoTx" ),
501+ settings .Label (),
489502 )
490503 attempts = 0
491504 )
0 commit comments