Skip to content

Commit abd87f5

Browse files
committed
Wire telemetry tuning params from DSN through to telemetry client
ParseTelemetryConfig existed and was tested but was never called in production — telemetry_batch_size and telemetry_flush_interval silently fell into sessionParams (sent to the server) instead of tuning the telemetry client. Fix by: - Extracting telemetry_batch_size and telemetry_flush_interval in ParseDSN and storing them on UserConfig - Adding batchSize/flushInterval params to InitializeForConnection and applying them over DefaultConfig() - Passing c.cfg.TelemetryBatchSize/FlushInterval from connector.go Also update .golangci.yml for golangci-lint v2 compatibility: add required version field, move gofmt to formatters section, and remove linters removed in v2 (deadcode, structcheck, varcheck, typecheck, gosimple). Co-authored-by: Isaac
1 parent a35153f commit abd87f5

File tree

4 files changed

+38
-14
lines changed

4 files changed

+38
-14
lines changed

.golangci.yml

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
1+
version: "2"
2+
13
linters:
24
disable-all: true
35
enable:
46
- bodyclose
5-
- deadcode
67
- depguard
78
- dogsled
89
# - dupl
910
- errcheck
10-
# - exportloopref
1111
# - funlen
1212
# - gochecknoinits
1313
# - goconst
1414
# - gocritic
1515
# - gocyclo
16-
- gofmt
1716
# - goimports
18-
# - gomnd
17+
# - mnd
1918
- goprintffuncname
2019
- gosec
21-
- gosimple
2220
- govet
2321
- ineffassign
2422
# - lll
@@ -27,30 +25,28 @@ linters:
2725
# - noctx
2826
- nolintlint
2927
- staticcheck
30-
- structcheck
3128
# - stylecheck
32-
- typecheck
3329
# - unconvert
3430
# - unparam
3531
- unused
36-
- varcheck
3732
# - whitespace
3833

3934
# don't enable:
4035
# - asciicheck
41-
# - scopelint
4236
# - gochecknoglobals
4337
# - gocognit
4438
# - godot
4539
# - godox
46-
# - goerr113
47-
# - interfacer
48-
# - maligned
40+
# - err113
41+
# - ireturn
4942
# - nestif
50-
# - prealloc
5143
# - testpackage
5244
# - revive
53-
# - wsl
45+
46+
formatters:
47+
enable:
48+
- gofmt
49+
# - goimports
5450

5551
linters-settings:
5652
depguard:

connector.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ func (c *connector) Connect(ctx context.Context) (driver.Conn, error) {
8787
c.cfg.DriverVersion,
8888
c.client,
8989
c.cfg.EnableTelemetry,
90+
c.cfg.TelemetryBatchSize,
91+
c.cfg.TelemetryFlushInterval,
9092
)
9193
if conn.telemetry != nil {
9294
log.Debug().Msg("telemetry initialized for connection")

internal/config/config.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ type UserConfig struct {
102102
// Uses config overlay pattern: client > server > default.
103103
// Unset = check server feature flag; explicitly true/false overrides the server.
104104
EnableTelemetry ConfigValue[bool]
105+
TelemetryBatchSize int // 0 = use default (100)
106+
TelemetryFlushInterval time.Duration // 0 = use default (5s)
105107
Transport http.RoundTripper
106108
UseLz4Compression bool
107109
EnableMetricViewMetadata bool
@@ -149,6 +151,8 @@ func (ucfg UserConfig) DeepCopy() UserConfig {
149151
EnableMetricViewMetadata: ucfg.EnableMetricViewMetadata,
150152
CloudFetchConfig: ucfg.CloudFetchConfig,
151153
EnableTelemetry: ucfg.EnableTelemetry,
154+
TelemetryBatchSize: ucfg.TelemetryBatchSize,
155+
TelemetryFlushInterval: ucfg.TelemetryFlushInterval,
152156
}
153157
}
154158

@@ -297,6 +301,19 @@ func ParseDSN(dsn string) (UserConfig, error) {
297301
}
298302
ucfg.EnableTelemetry = NewConfigValue(enableTelemetry)
299303
}
304+
if batchSize, ok, err := params.extractAsInt("telemetry_batch_size"); ok {
305+
if err != nil {
306+
return UserConfig{}, err
307+
}
308+
if batchSize > 0 {
309+
ucfg.TelemetryBatchSize = batchSize
310+
}
311+
}
312+
if flushInterval, ok := params.extract("telemetry_flush_interval"); ok {
313+
if d, err := time.ParseDuration(flushInterval); err == nil && d > 0 {
314+
ucfg.TelemetryFlushInterval = d
315+
}
316+
}
300317

301318
// for timezone we do a case insensitive key match.
302319
// We use getNoCase because we want to leave timezone in the params so that it will also

telemetry/driver_integration.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package telemetry
33
import (
44
"context"
55
"net/http"
6+
"time"
67

78
"github.com/databricks/databricks-sql-go/internal/config"
89
)
@@ -26,6 +27,8 @@ func InitializeForConnection(
2627
driverVersion string,
2728
httpClient *http.Client,
2829
enableTelemetry config.ConfigValue[bool],
30+
batchSize int,
31+
flushInterval time.Duration,
2932
) *Interceptor {
3033
// Create telemetry config and apply client overlay.
3134
// ConfigValue[bool] semantics:
@@ -38,6 +41,12 @@ func InitializeForConnection(
3841
} else {
3942
cfg.EnableTelemetry = true // Unset: default to enabled, server flag decides
4043
}
44+
if batchSize > 0 {
45+
cfg.BatchSize = batchSize
46+
}
47+
if flushInterval > 0 {
48+
cfg.FlushInterval = flushInterval
49+
}
4150

4251
// Get feature flag cache context FIRST (for reference counting)
4352
flagCache := getFeatureFlagCache()

0 commit comments

Comments
 (0)