feat(go/adbc): add context.Context support for uniform OpenTelemetry instrumentation#4009
Open
zeroshade wants to merge 7 commits intoapache:mainfrom
Open
feat(go/adbc): add context.Context support for uniform OpenTelemetry instrumentation#4009zeroshade wants to merge 7 commits intoapache:mainfrom
zeroshade wants to merge 7 commits intoapache:mainfrom
Conversation
- Add DatabaseContext, ConnectionContext, StatementContext interfaces - Add extension Context interfaces (PostInitOptions, GetSetOptions, etc.) - Add context_adapters.go with DatabaseContext adapter implementation - Add context_adapters_test.go with tests for DatabaseContext adapter - Update .gitignore to exclude docs/plans Relates to apache#2772
Implement adapter to wrap existing Connection and Statement implementations as ConnectionContext and StatementContext for backward compatibility. Relates to apache#2772
Ensure adapters handle nil inputs correctly and return nil when given nil inputs. Tests verify that AsDatabaseContext, AsConnectionContext, and AsStatementContext all handle nil correctly. Note: Tests for avoiding double-wrapping are not applicable because Database/DatabaseContext, Connection/ConnectionContext, and Statement/StatementContext have conflicting method signatures (Close() vs Close(ctx)), making it impossible for a type to implement both interfaces simultaneously. Relates to apache#2772
- Update package docs to explain Context interfaces - Add IngestStreamContext helper for context-aware ingestion - Add example code demonstrating Context usage Relates to apache#2772
lidavidm
reviewed
Feb 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements context.Context support for all Go ADBC methods to enable uniform OpenTelemetry instrumentation, cancellation, and deadline propagation (addresses #2772).
DatabaseContext,ConnectionContext, andStatementContextinterfaces that mirror existing interfaces but requirecontext.Contextfor all methodsPostInitOptionsContext,GetSetOptionsContext,ConnectionGetStatisticsContext,StatementExecuteSchemaContextAsDatabaseContext,AsConnectionContext,AsStatementContext) to wrap non-context implementations for backward compatibilityIngestStreamContexthelper for context-aware bulk ingestionChanges
New Interfaces (
go/adbc/adbc.go):DatabaseContext- Database with context support for all operationsConnectionContext- Connection with context support for all operationsStatementContext- Statement with context support for all operationsAdapter Implementation (
go/adbc/context_adapters.go):Tests (
go/adbc/context_adapters_test.go):Documentation & Examples:
IngestStreamContexthelper functionMigration Path
For Applications:
For Driver Implementers:
Test Plan
Notes
This is the first step toward uniform OpenTelemetry support. Future work includes: