You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "binarycat-dremio (via GitHub)" <gi...@apache.org> on 2026/07/08 10:32:03 UTC

[PR] feat(go/adbc/driver/flightsql): implement tracing for core Flight SQL operations [arrow-adbc]

binarycat-dremio opened a new pull request, #4486:
URL: https://github.com/apache/arrow-adbc/pull/4486

   ## Summary
   This change wires OpenTelemetry tracing into the core Flight SQL execution path and ensures configured trace exporters are flushed when the database is closed.
   
   Before this change, the Flight SQL driver accepted tracing configuration but did not emit trace data for the main open/query path. The Flight SQL database close path also did not delegate to the shared database close implementation, so tracer shutdown and exporter flush did not run.
   
   ## Changes
   - add tracing spans for `FlightSQLDatabase.Open`
   - add tracing spans for `FlightSQLStatement.Prepare`
   - add tracing spans for `FlightSQLStatement.ExecuteQuery`
   - add tracing spans for `FlightSQLStatement.ExecuteUpdate`
   - call `DatabaseImplBase.Close()` from Flight SQL database close handling
   - add a regression test that verifies the `adbcfile` exporter produces trace output for the Flight SQL query path
   
   ## Validation
   - `go test ./driver/flightsql -run TestFlightSQLTracingProducesTraceFiles -count=1`
   - `go test ./driver/flightsql -count=1`
   


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(go/adbc/driver/flightsql): implement tracing for core Flight SQL operations [arrow-adbc]

Posted by "binarycat-dremio (via GitHub)" <gi...@apache.org>.
binarycat-dremio commented on code in PR #4486:
URL: https://github.com/apache/arrow-adbc/pull/4486#discussion_r3554994696


##########
go/adbc/driver/flightsql/flightsql_database.go:
##########
@@ -588,11 +592,12 @@ func (d *databaseImpl) Open(ctx context.Context) (adbc.Connection, error) {
 		"driver", infoDriverName,
 	)
 
-	return driverbase.NewConnectionBuilder(conn).
+	cnxn = driverbase.NewConnectionBuilder(conn).
 		WithDriverInfoPreparer(conn).
 		WithAutocommitSetter(conn).
 		WithCurrentNamespacer(conn).
-		Connection(), nil
+		Connection()
+	return cnxn, nil

Review Comment:
   reverted 👌 



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(go/adbc/driver/flightsql): implement tracing for core Flight SQL operations [arrow-adbc]

Posted by "lidavidm (via GitHub)" <gi...@apache.org>.
lidavidm commented on code in PR #4486:
URL: https://github.com/apache/arrow-adbc/pull/4486#discussion_r3547751927


##########
go/adbc/driver/flightsql/flightsql_adbc_test.go:
##########
@@ -316,6 +317,56 @@ func TestADBCFlightSQL(t *testing.T) {
 	suite.Run(t, &DomainSocketTests{db: db})
 }
 
+func TestFlightSQLTracingProducesTraceFiles(t *testing.T) {
+	db, err := sql.Open("sqlite", fmt.Sprintf("file:%s-%d?mode=memory&cache=private", strings.ToLower(t.Name()), time.Now().UnixNano()))
+	require.NoError(t, err)
+	defer func() { require.NoError(t, db.Close()) }()

Review Comment:
   There's already infra for this above (see TestADBCFlightSQL)



##########
go/adbc/driver/flightsql/flightsql_adbc_test.go:
##########
@@ -316,6 +317,56 @@ func TestADBCFlightSQL(t *testing.T) {
 	suite.Run(t, &DomainSocketTests{db: db})
 }
 
+func TestFlightSQLTracingProducesTraceFiles(t *testing.T) {
+	db, err := sql.Open("sqlite", fmt.Sprintf("file:%s-%d?mode=memory&cache=private", strings.ToLower(t.Name()), time.Now().UnixNano()))
+	require.NoError(t, err)
+	defer func() { require.NoError(t, db.Close()) }()
+
+	q := &FlightSQLQuirks{db: db}
+	drv := q.SetupDriver(t)
+	defer q.TearDownDriver(t, drv)
+
+	traceDir := t.TempDir()
+	opts := q.DatabaseOptions()
+	opts[adbc.OptionKeyTelemetryTracesExporter] = string(adbc.TelemetryExporterAdbcFile)
+	opts[adbc.OptionKeyTelemetryTracesFolderPath] = traceDir
+
+	adbcDB, err := drv.NewDatabase(opts)
+	require.NoError(t, err)
+
+	cnxn, err := adbcDB.Open(context.Background())
+	require.NoError(t, err)
+
+	stmt, err := cnxn.NewStatement()
+	require.NoError(t, err)
+	require.NoError(t, stmt.SetSqlQuery("SELECT 1"))
+
+	reader, _, err := stmt.ExecuteQuery(context.Background())
+	require.NoError(t, err)
+	for reader.Next() {
+	}
+	reader.Release()
+
+	validation.CheckedClose(t, stmt)
+	validation.CheckedClose(t, cnxn)
+	validation.CheckedClose(t, adbcDB)

Review Comment:
   Shouldn't these be `defer`ed?



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(go/adbc/driver/flightsql): implement tracing for core Flight SQL operations [arrow-adbc]

Posted by "binarycat-dremio (via GitHub)" <gi...@apache.org>.
binarycat-dremio commented on code in PR #4486:
URL: https://github.com/apache/arrow-adbc/pull/4486#discussion_r3554976779


##########
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:
   I turned it into "refactoring" issue and left the TODOs. To do not forget to make it prettier 👌 



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(go/adbc/driver/flightsql): implement tracing for core Flight SQL operations [arrow-adbc]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on code in PR #4486:
URL: https://github.com/apache/arrow-adbc/pull/4486#discussion_r3554710426


##########
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:
   ah, fair enough. Can you add a comment just pointing this out so no one makes the mistake of changing this in the future?



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(go/adbc/driver/flightsql): implement tracing for core Flight SQL operations [arrow-adbc]

Posted by "binarycat-dremio (via GitHub)" <gi...@apache.org>.
binarycat-dremio commented on code in PR #4486:
URL: https://github.com/apache/arrow-adbc/pull/4486#discussion_r3557478423


##########
go/adbc/driver/internal/driverbase/connection.go:
##########
@@ -154,6 +154,7 @@ func (base *ConnectionImplBase) Rollback(context.Context) error {
 
 func (base *ConnectionImplBase) GetInfo(ctx context.Context, infoCodes []adbc.InfoCode) (reader array.RecordReader, err error) {
 	_, span := internal.StartSpan(ctx, "ConnectionImplBase.GetInfo", base)
+	// TODO(apache/arrow-adbc#4494): replace with a shared telemetry helper.
 	defer internal.EndSpan(span, err)

Review Comment:
   you are right. was lost after back-n-forth refactoring 👍 



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(go/adbc/driver/flightsql): implement tracing for core Flight SQL operations [arrow-adbc]

Posted by "lidavidm (via GitHub)" <gi...@apache.org>.
lidavidm merged PR #4486:
URL: https://github.com/apache/arrow-adbc/pull/4486


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(go/adbc/driver/flightsql): implement tracing for core Flight SQL operations [arrow-adbc]

Posted by "binarycat-dremio (via GitHub)" <gi...@apache.org>.
binarycat-dremio commented on code in PR #4486:
URL: https://github.com/apache/arrow-adbc/pull/4486#discussion_r3551593556


##########
go/adbc/driver/flightsql/flightsql_adbc_test.go:
##########
@@ -316,6 +317,56 @@ func TestADBCFlightSQL(t *testing.T) {
 	suite.Run(t, &DomainSocketTests{db: db})
 }
 
+func TestFlightSQLTracingProducesTraceFiles(t *testing.T) {
+	db, err := sql.Open("sqlite", fmt.Sprintf("file:%s-%d?mode=memory&cache=private", strings.ToLower(t.Name()), time.Now().UnixNano()))
+	require.NoError(t, err)
+	defer func() { require.NoError(t, db.Close()) }()

Review Comment:
   Thanks for pointing this. 
   `example.CreateDB()` was tried, but caused cross-test interference in the full go test ./driver/flightsql run.
   I propose to refactor this in a foolow-up issue/PR http://github.com/apache/arrow-go/issues/916



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(go/adbc/driver/flightsql): implement tracing for core Flight SQL operations [arrow-adbc]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on code in PR #4486:
URL: https://github.com/apache/arrow-adbc/pull/4486#discussion_r3553779349


##########
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:
   should just be
   
   ```suggestion
   	defer internal.EndSpan(span, err)
   ```
   
   right?



##########
go/adbc/driver/flightsql/flightsql_statement.go:
##########
@@ -530,6 +531,9 @@ func (s *statement) ExecuteQuery(ctx context.Context) (rdr array.RecordReader, n
 		}
 	}
 
+	ctx, span := internal.StartSpan(ctx, "FlightSQLStatement.ExecuteQuery", s.cnxn)
+	defer func() { internal.EndSpan(span, err) }()

Review Comment:
   ```suggestion
   	defer internal.EndSpan(span, err)
   ```



##########
go/adbc/driver/flightsql/flightsql_database.go:
##########
@@ -588,11 +592,12 @@ func (d *databaseImpl) Open(ctx context.Context) (adbc.Connection, error) {
 		"driver", infoDriverName,
 	)
 
-	return driverbase.NewConnectionBuilder(conn).
+	cnxn = driverbase.NewConnectionBuilder(conn).
 		WithDriverInfoPreparer(conn).
 		WithAutocommitSetter(conn).
 		WithCurrentNamespacer(conn).
-		Connection(), nil
+		Connection()
+	return cnxn, nil

Review Comment:
   why this change?



##########
go/adbc/driver/flightsql/flightsql_statement.go:
##########
@@ -602,6 +606,9 @@ func (s *statement) ExecuteUpdate(ctx context.Context) (n int64, err error) {
 		}
 	}
 
+	ctx, span := internal.StartSpan(ctx, "FlightSQLStatement.ExecuteUpdate", s.cnxn)
+	defer func() { internal.EndSpan(span, err) }()

Review Comment:
   ```suggestion
   	defer internal.EndSpan(span, err)
   ```



##########
go/adbc/driver/flightsql/flightsql_statement.go:
##########
@@ -647,7 +654,10 @@ func (s *statement) ExecuteUpdate(ctx context.Context) (n int64, err error) {
 
 // Prepare turns this statement into a prepared statement to be executed
 // multiple times. This invalidates any prior result sets.
-func (s *statement) Prepare(ctx context.Context) error {
+func (s *statement) Prepare(ctx context.Context) (err error) {
+	ctx, span := internal.StartSpan(ctx, "FlightSQLStatement.Prepare", s.cnxn)
+	defer func() { internal.EndSpan(span, err) }()

Review Comment:
   ```suggestion
   	defer internal.EndSpan(span, err)
   ```



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(go/adbc/driver/flightsql): implement tracing for core Flight SQL operations [arrow-adbc]

Posted by "lidavidm (via GitHub)" <gi...@apache.org>.
lidavidm commented on code in PR #4486:
URL: https://github.com/apache/arrow-adbc/pull/4486#discussion_r3555458135


##########
go/adbc/driver/internal/driverbase/connection.go:
##########
@@ -154,6 +154,7 @@ func (base *ConnectionImplBase) Rollback(context.Context) error {
 
 func (base *ConnectionImplBase) GetInfo(ctx context.Context, infoCodes []adbc.InfoCode) (reader array.RecordReader, err error) {
 	_, span := internal.StartSpan(ctx, "ConnectionImplBase.GetInfo", base)
+	// TODO(apache/arrow-adbc#4494): replace with a shared telemetry helper.
 	defer internal.EndSpan(span, err)

Review Comment:
   doesn't this need to be `defer func() { }()`? 



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(go/adbc/driver/flightsql): implement tracing for core Flight SQL operations [arrow-adbc]

Posted by "binarycat-dremio (via GitHub)" <gi...@apache.org>.
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org