Skip to content

feat(go/adbc): refactor logging instrumentation into OTel tracing - part 3/3 - #4661

Open
birschick-bq wants to merge 41 commits into
apache:mainfrom
birschick-bq:dev/birschick-bq/flight-sql-log-to-trace-5-statements
Open

feat(go/adbc): refactor logging instrumentation into OTel tracing - part 3/3#4661
birschick-bq wants to merge 41 commits into
apache:mainfrom
birschick-bq:dev/birschick-bq/flight-sql-log-to-trace-5-statements

Conversation

@birschick-bq

@birschick-bq birschick-bq commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

This pull request makes significant improvements to the FlightSQL driver's tracing and logging, replacing legacy logging with structured OpenTelemetry tracing, enhancing error recording, and ensuring better test coverage for tracing-related cleanup. The changes modernize how operation metadata is captured and reported, making tracing more consistent and useful for observability and debugging.

Tracing and Logging Modernization:

  • Replaced slog-based logging with OpenTelemetry tracing throughout flightsql_statement.go and flightsql_bulk_ingest.go, using attribute.KeyValue for structured event attributes and adding detailed span events for operation start and finish. This includes updating helper functions to return attributes in the new format. [1] [2] [3] [4] [5] [6] [7]

  • Updated error handling in tracing: errors are now consistently recorded as span errors with stack traces, and operation-specific error wrapping is improved for clarity. [1] [2] [3] [4] [5] [6]

API and Internal Refactoring:

  • Refactored method signatures and internal calls to use the new tracing and attribute formats, including changes to SetSqlQuery, ExecuteQuery, ExecuteUpdate, and Prepare methods in statement. [1] [2] [3] [4] [5]

  • Changed the construction of the Flight client to add a unary interceptor for response metadata, improving consistency for both unary and stream calls.

Testing Improvements:

  • Added a new test TestFlightSQLTracingCleansUpAfterConstructionFailure to ensure that tracing resources are properly cleaned up even when database construction fails, preventing resource leaks.

Dependency and Import Updates:

  • Updated imports to include OpenTelemetry packages and internal helpers for tracing, and removed unused logging imports. [1] [2]

Helper and Utility Updates:

  • Updated helper functions for generating tracing attributes and correlation metadata to use the new attribute-based approach, improving code clarity and maintainability. [1] [2] [3]

These changes collectively ensure that the driver emits rich, structured telemetry for all major operations, facilitates easier debugging, and aligns with modern observability practices.


Extends: #4659
Part 3/3

… dev/birschick-bq/flight-sql-log-to-trace-4-connection
… dev/birschick-bq/flight-sql-log-to-trace-5-statements
…into dev/birschick-bq/flight-sql-log-to-trace-5-statements
… dev/birschick-bq/flight-sql-log-to-trace-4-connection
…into dev/birschick-bq/flight-sql-log-to-trace-5-statements
@birschick-bq
birschick-bq marked this pull request as ready for review August 25, 2026 03:40
@birschick-bq

Copy link
Copy Markdown
Contributor Author

@lidavidm - The last of the PRs for moving logging to OTel tracing.
(Note: I have started the follow-on PR for returning an EndSpanHelper from internal.StartSpanWithEndSpanHelper)

@lidavidm lidavidm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable

require.Contains(t, output, "FlightSQL.Statement.ExecuteQuery")
}

func TestFlightSQLTracingCleansUpAfterConstructionFailure(t *testing.T) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly is this testing/how would this test fail before?

// For queries expected to be executed repeatedly, Prepare should be
// called before execution.
func (s *statement) SetSqlQuery(query string) error {
func (s *statement) SetSqlQuery(query string) (err error) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, is this worth tracing? Seems like as long as the underlying close is traced this should be fine


type recordReaderCallerContextKey struct{}

func isRecordReaderSiblingCancellation(ctx context.Context) bool {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should document what this is checking/trying to do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants