Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
38e41de
[PECOBLR-1143] Implement telemetry Phase 4-5: Export infrastructure a…
samikshya-db Jan 30, 2026
e12933d
Refactor telemetry config to use config overlay approach
samikshya-db Feb 3, 2026
f5b0e91
Implement config overlay pattern and refactor feature flags for exten…
samikshya-db Feb 3, 2026
b2fc43c
Fix lint issues: gofmt, errcheck, and staticcheck
samikshya-db Feb 3, 2026
4b53634
Merge branch 'main' into stack/PECOBLR-1143-telemetry-phase4-5
samikshya-db Feb 3, 2026
ab13528
Fix SA9003 lint error: Add comment to empty default case
samikshya-db Feb 3, 2026
05f4ea2
Fix telemetry endpoint to match JDBC driver
samikshya-db Feb 4, 2026
68f8493
Make first feature flag call blocking
samikshya-db Feb 4, 2026
7fe0e54
Fix test failures in telemetry
samikshya-db Feb 5, 2026
2387f20
Fix SA9003 staticcheck lint errors in exporter
samikshya-db Feb 5, 2026
53b51e3
[PECOBLR-1381] Implement telemetry Phase 6: Metric collection & aggre…
samikshya-db Jan 30, 2026
51d40d2
[PECOBLR-1382] Implement telemetry Phase 7: Driver integration
samikshya-db Jan 30, 2026
09b9b99
Update DESIGN.md: Mark Phase 7 as completed
samikshya-db Jan 30, 2026
f388244
Update driver integration for config overlay pattern
samikshya-db Feb 5, 2026
1593c87
Merge branch 'main' into stack/PECOBLR-1381-1382-telemetry-phase6-7
samikshya-db Feb 9, 2026
ae00204
Merge branch 'main' into stack/PECOBLR-1381-1382-telemetry-phase6-7
samikshya-db Feb 11, 2026
03d33d2
Add explanatory comments for immediate flush behavior
samikshya-db Feb 12, 2026
fa63f3b
Add debug logging for telemetry panic recovery
samikshya-db Feb 12, 2026
753637c
Check HTTP status codes in isTerminalError
samikshya-db Feb 12, 2026
f14cc3d
Fix gofmt formatting in telemetry/client.go
samikshya-db Feb 12, 2026
0cb2635
Fix gofmt -s formatting in config.go
samikshya-db Feb 12, 2026
dba2eb6
Add nolint comments for unused code
samikshya-db Feb 12, 2026
c1de5a3
Fix nolint directives to include deadcode linter
samikshya-db Feb 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ import (
"github.com/databricks/databricks-sql-go/internal/sentinel"
"github.com/databricks/databricks-sql-go/internal/thrift_protocol"
"github.com/databricks/databricks-sql-go/logger"
"github.com/databricks/databricks-sql-go/telemetry"
"github.com/pkg/errors"
)

type conn struct {
id string
cfg *config.Config
client cli_service.TCLIService
session *cli_service.TOpenSessionResp
id string
cfg *config.Config
client cli_service.TCLIService
session *cli_service.TOpenSessionResp
telemetry *telemetry.Interceptor // Optional telemetry interceptor
}

// Prepare prepares a statement with the query bound to this connection.
Expand All @@ -50,6 +52,12 @@ func (c *conn) Close() error {
log := logger.WithContext(c.id, "", "")
ctx := driverctx.NewContextWithConnId(context.Background(), c.id)

// Close telemetry and release resources
if c.telemetry != nil {
_ = c.telemetry.Close(ctx)
telemetry.ReleaseForConnection(c.cfg.Host)
}

_, err := c.client.CloseSession(ctx, &cli_service.TCloseSessionReq{
SessionHandle: c.session.SessionHandle,
})
Expand Down
20 changes: 20 additions & 0 deletions connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/databricks/databricks-sql-go/internal/config"
dbsqlerrint "github.com/databricks/databricks-sql-go/internal/errors"
"github.com/databricks/databricks-sql-go/logger"
"github.com/databricks/databricks-sql-go/telemetry"
)

type connector struct {
Expand Down Expand Up @@ -75,6 +76,25 @@ func (c *connector) Connect(ctx context.Context) (driver.Conn, error) {
}
log := logger.WithContext(conn.id, driverctx.CorrelationIdFromContext(ctx), "")

// Initialize telemetry (always attempt, let feature flags decide)
var enableTelemetry *bool
if c.cfg.ForceEnableTelemetry || c.cfg.EnableTelemetry {
// User explicitly enabled telemetry
trueVal := true
enableTelemetry = &trueVal
}
// else: leave nil to check server feature flag

conn.telemetry = telemetry.InitializeForConnection(
ctx,
c.cfg.Host,
c.client,
enableTelemetry,
)
if conn.telemetry != nil {
log.Debug().Msg("telemetry initialized for connection")
}

log.Info().Msgf("connect: host=%s port=%d httpPath=%s serverProtocolVersion=0x%X", c.cfg.Host, c.cfg.Port, c.cfg.HTTPPath, session.ServerProtocolVersion)

return conn, nil
Expand Down
52 changes: 36 additions & 16 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,25 @@ func (c *Config) DeepCopy() *Config {

// UserConfig is the set of configurations exposed to users
type UserConfig struct {
Protocol string
Host string // from databricks UI
Port int // from databricks UI
HTTPPath string // from databricks UI
Catalog string
Schema string
Authenticator auth.Authenticator
AccessToken string // from databricks UI
MaxRows int // max rows per page
QueryTimeout time.Duration // Timeout passed to server for query processing
UserAgentEntry string
Location *time.Location
SessionParams map[string]string
RetryWaitMin time.Duration
RetryWaitMax time.Duration
RetryMax int
Protocol string
Host string // from databricks UI
Port int // from databricks UI
HTTPPath string // from databricks UI
Catalog string
Schema string
Authenticator auth.Authenticator
AccessToken string // from databricks UI
MaxRows int // max rows per page
QueryTimeout time.Duration // Timeout passed to server for query processing
UserAgentEntry string
Location *time.Location
SessionParams map[string]string
RetryWaitMin time.Duration
RetryWaitMax time.Duration
RetryMax int
// Telemetry configuration
EnableTelemetry bool // Opt-in for telemetry (respects server feature flags)
ForceEnableTelemetry bool // Force enable telemetry (bypasses server checks)
Transport http.RoundTripper
UseLz4Compression bool
EnableMetricViewMetadata bool
Expand Down Expand Up @@ -144,6 +147,8 @@ func (ucfg UserConfig) DeepCopy() UserConfig {
UseLz4Compression: ucfg.UseLz4Compression,
EnableMetricViewMetadata: ucfg.EnableMetricViewMetadata,
CloudFetchConfig: ucfg.CloudFetchConfig,
EnableTelemetry: ucfg.EnableTelemetry,
ForceEnableTelemetry: ucfg.ForceEnableTelemetry,
}
}

Expand Down Expand Up @@ -282,6 +287,21 @@ func ParseDSN(dsn string) (UserConfig, error) {
ucfg.EnableMetricViewMetadata = enableMetricViewMetadata
}

// Telemetry parameters
if enableTelemetry, ok, err := params.extractAsBool("enableTelemetry"); ok {
if err != nil {
return UserConfig{}, err
}
ucfg.EnableTelemetry = enableTelemetry
}

if forceEnableTelemetry, ok, err := params.extractAsBool("forceEnableTelemetry"); ok {
if err != nil {
return UserConfig{}, err
}
ucfg.ForceEnableTelemetry = forceEnableTelemetry
}

// for timezone we do a case insensitive key match.
// We use getNoCase because we want to leave timezone in the params so that it will also
// be used as a session param.
Expand Down
47 changes: 25 additions & 22 deletions telemetry/DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2158,28 +2158,31 @@ func BenchmarkInterceptor_Disabled(b *testing.B) {
- [ ] Test error classification
- [ ] Test client with aggregator integration

### Phase 7: Driver Integration (PECOBLR-1382)
- [ ] Add telemetry initialization to `connection.go`
- [ ] Call isTelemetryEnabled() at connection open
- [ ] Initialize telemetry client via clientManager.getOrCreateClient()
- [ ] Increment feature flag cache reference count
- [ ] Store telemetry interceptor in connection
- [ ] Add telemetry hooks to `statement.go`
- [ ] Add beforeExecute() hook at statement start
- [ ] Add afterExecute() hook at statement completion
- [ ] Add tag collection during execution (result format, chunk count, bytes, etc.)
- [ ] Call completeStatement() at statement end
- [ ] Add cleanup in `Close()` methods
- [ ] Release client manager reference in connection.Close()
- [ ] Release feature flag cache reference
- [ ] Flush pending metrics before close
- [ ] Add integration tests
- [ ] Test telemetry enabled via forceEnableTelemetry=true
- [ ] Test telemetry disabled by default
- [ ] Test metric collection and export end-to-end
- [ ] Test multiple concurrent connections
- [ ] Test latency measurement accuracy
- [ ] Test opt-in priority in driver context
### Phase 7: Driver Integration ✅ COMPLETED
- [x] Add telemetry initialization to `connection.go`
- [x] Call isTelemetryEnabled() at connection open via InitializeForConnection()
- [x] Initialize telemetry client via clientManager.getOrCreateClient()
- [x] Increment feature flag cache reference count
- [x] Store telemetry interceptor in connection
- [x] Add telemetry configuration to UserConfig
- [x] EnableTelemetry and ForceEnableTelemetry fields
- [x] DSN parameter parsing
- [x] DeepCopy support
- [x] Add cleanup in `Close()` methods
- [x] Release client manager reference in connection.Close()
- [x] Release feature flag cache reference via ReleaseForConnection()
- [x] Flush pending metrics before close
- [x] Export necessary types and methods
- [x] Export Interceptor type
- [x] Export GetInterceptor() and Close() methods
- [x] Create driver integration helpers
- [x] Basic integration tests
- [x] Test compilation with telemetry
- [x] Test no breaking changes to existing tests
- [x] Test graceful handling when disabled

Note: Statement execution hooks (beforeExecute/afterExecute in statement.go) for
actual metric collection can be added as follow-up enhancement.

### Phase 8: Testing & Validation
- [ ] Run benchmark tests
Expand Down
Loading
Loading