Skip to content

Commit b2fc43c

Browse files
committed
Fix lint issues: gofmt, errcheck, and staticcheck
- Run gofmt -s on all telemetry files - Add explicit error ignore for json.Encoder.Encode in tests - Add comment to empty select case to fix SA9003 staticcheck warning
1 parent f5b0e91 commit b2fc43c

6 files changed

Lines changed: 22 additions & 23 deletions

File tree

telemetry/config.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ type Config struct {
4848
// Clients can override by explicitly setting enableTelemetry=true/false.
4949
func DefaultConfig() *Config {
5050
return &Config{
51-
Enabled: false, // Will be set based on overlay logic
51+
Enabled: false, // Will be set based on overlay logic
5252
EnableTelemetry: config.ConfigValue[bool]{}, // Unset = use server feature flag
5353
BatchSize: 100,
5454
FlushInterval: 5 * time.Second,
@@ -119,4 +119,3 @@ func isTelemetryEnabled(ctx context.Context, cfg *Config, host string, httpClien
119119

120120
return serverEnabled
121121
}
122-

telemetry/config_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ func TestIsTelemetryEnabled_ClientOverrideEnabled(t *testing.T) {
211211
"databricks.partnerplatform.clientConfigsFeatureFlags.enableTelemetryForGoDriver": false,
212212
},
213213
}
214-
json.NewEncoder(w).Encode(resp)
214+
_ = json.NewEncoder(w).Encode(resp)
215215
}))
216216
defer server.Close()
217217

@@ -245,7 +245,7 @@ func TestIsTelemetryEnabled_ClientOverrideDisabled(t *testing.T) {
245245
"databricks.partnerplatform.clientConfigsFeatureFlags.enableTelemetryForGoDriver": true,
246246
},
247247
}
248-
json.NewEncoder(w).Encode(resp)
248+
_ = json.NewEncoder(w).Encode(resp)
249249
}))
250250
defer server.Close()
251251

@@ -277,7 +277,7 @@ func TestIsTelemetryEnabled_ServerEnabled(t *testing.T) {
277277
"databricks.partnerplatform.clientConfigsFeatureFlags.enableTelemetryForGoDriver": true,
278278
},
279279
}
280-
json.NewEncoder(w).Encode(resp)
280+
_ = json.NewEncoder(w).Encode(resp)
281281
}))
282282
defer server.Close()
283283

@@ -309,7 +309,7 @@ func TestIsTelemetryEnabled_ServerDisabled(t *testing.T) {
309309
"databricks.partnerplatform.clientConfigsFeatureFlags.enableTelemetryForGoDriver": false,
310310
},
311311
}
312-
json.NewEncoder(w).Encode(resp)
312+
_ = json.NewEncoder(w).Encode(resp)
313313
}))
314314
defer server.Close()
315315

telemetry/exporter.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ type telemetryExporter struct {
2020

2121
// telemetryMetric represents a metric to export.
2222
type telemetryMetric struct {
23-
metricType string
24-
timestamp time.Time
25-
workspaceID string
26-
sessionID string
27-
statementID string
28-
latencyMs int64
29-
errorType string
30-
tags map[string]interface{}
23+
metricType string
24+
timestamp time.Time
25+
workspaceID string
26+
sessionID string
27+
statementID string
28+
latencyMs int64
29+
errorType string
30+
tags map[string]interface{}
3131
}
3232

3333
// telemetryPayload is the JSON structure sent to Databricks.
@@ -120,6 +120,7 @@ func (e *telemetryExporter) doExport(ctx context.Context, metrics []*telemetryMe
120120
backoff := time.Duration(1<<uint(attempt-1)) * e.cfg.RetryDelay
121121
select {
122122
case <-time.After(backoff):
123+
// Backoff completed, continue to retry
123124
case <-ctx.Done():
124125
return ctx.Err()
125126
}

telemetry/exporter_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,8 @@ func TestToExportedMetric_TagFiltering(t *testing.T) {
296296

297297
func TestIsRetryableStatus(t *testing.T) {
298298
tests := []struct {
299-
status int
300-
retryable bool
299+
status int
300+
retryable bool
301301
description string
302302
}{
303303
{200, false, "200 OK is not retryable"},

telemetry/featureflag.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ type featureFlagCache struct {
3333

3434
// featureFlagContext holds feature flag state and reference count for a host.
3535
type featureFlagContext struct {
36-
mu sync.RWMutex // protects flags, lastFetched, fetching
37-
flags map[string]bool // cached feature flags by name
38-
lastFetched time.Time // when flags were last fetched
39-
refCount int // protected by featureFlagCache.mu
40-
cacheDuration time.Duration // how long to cache flags
41-
fetching bool // true if a fetch is in progress
36+
mu sync.RWMutex // protects flags, lastFetched, fetching
37+
flags map[string]bool // cached feature flags by name
38+
lastFetched time.Time // when flags were last fetched
39+
refCount int // protected by featureFlagCache.mu
40+
cacheDuration time.Duration // how long to cache flags
41+
fetching bool // true if a fetch is in progress
4242
}
4343

4444
var (

telemetry/featureflag_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,4 +441,3 @@ func TestFetchFeatureFlags_ContextCancellation(t *testing.T) {
441441
t.Error("Expected error for cancelled context")
442442
}
443443
}
444-

0 commit comments

Comments
 (0)