binarycat-dremio commented on code in PR #4486:
URL: https://github.com/apache/arrow-adbc/pull/4486#discussion_r3554528911


##########
go/adbc/driver/flightsql/flightsql_database.go:
##########
@@ -480,7 +481,10 @@ type support struct {
        transactions bool
 }
 
-func (d *databaseImpl) Open(ctx context.Context) (adbc.Connection, error) {
+func (d *databaseImpl) Open(ctx context.Context) (cnxn adbc.Connection, err 
error) {
+       ctx, span := internal.StartSpan(ctx, "FlightSQLDatabase.Open", d)
+       defer func() { internal.EndSpan(span, err) }()

Review Comment:
   thx for pointing this. 
   so, the reason is that deferred closure is required so EndSpan gets the 
final err. 
   bare `defer internal.EndSpan(span, err)` would capture err too early.
   
   can be tested like this
   
   ```golang
   func direct() (err error) {
       defer fmt.Println("direct:", err)
       err = fmt.Errorf("boom")
       return
   }
   
   func closure() (err error) {
       defer func() { fmt.Println("closure:", err) }()
       err = fmt.Errorf("boom")
       return
   }
   ```
   
   ```
   direct: <nil>
   closure: boom
   ```
   
   WDYT?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to