Skip to content

Commit 8ff09a9

Browse files
samikshya-dbclaude
andcommitted
Make telemetry logging silent by default
Remove verbose telemetry logs to minimize noise in customer logs. Only log essential startup/shutdown messages and errors: Kept (LogLevel.debug): - "Telemetry: enabled" - on successful initialization - "Telemetry: disabled" - when feature flag disables it - "Telemetry: closed" - on graceful shutdown - Error messages only when failures occur Removed: - Individual metric flushing logs - Export operation logs ("Exporting N metrics") - Success confirmations ("Successfully exported") - Client lifecycle logs (creation, ref counting) - All intermediate operational logs Updated spec/telemetry-design.md to document the silent logging policy. Telemetry still functions correctly - exports happen silently in the background without cluttering customer logs. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent d9cc2c9 commit 8ff09a9

6 files changed

Lines changed: 39 additions & 34 deletions

File tree

lib/DBSQLClient.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ export default class DBSQLClient extends EventEmitter implements IDBSQLClient, I
321321
const enabled = await this.featureFlagCache.isTelemetryEnabled(this.host);
322322

323323
if (!enabled) {
324-
this.logger.log(LogLevel.debug, 'Telemetry disabled via feature flag');
324+
this.logger.log(LogLevel.debug, 'Telemetry: disabled');
325325
return;
326326
}
327327

@@ -386,10 +386,10 @@ export default class DBSQLClient extends EventEmitter implements IDBSQLClient, I
386386
}
387387
});
388388

389-
this.logger.log(LogLevel.debug, 'Telemetry initialized successfully');
389+
this.logger.log(LogLevel.debug, 'Telemetry: enabled');
390390
} catch (error: any) {
391391
// Swallow all telemetry initialization errors
392-
this.logger.log(LogLevel.debug, `Telemetry initialization failed: ${error.message}`);
392+
this.logger.log(LogLevel.debug, `Telemetry initialization error: ${error.message}`);
393393
}
394394
}
395395

lib/telemetry/DatabricksTelemetryExporter.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ export default class DatabricksTelemetryExporter {
214214
*/
215215
private async exportInternal(metrics: TelemetryMetric[]): Promise<void> {
216216
const config = this.context.getConfig();
217-
const logger = this.context.getLogger();
218217

219218
// Determine endpoint based on authentication mode
220219
const authenticatedExport = config.telemetryAuthenticatedExport ?? DEFAULT_TELEMETRY_CONFIG.authenticatedExport;
@@ -232,13 +231,6 @@ export default class DatabricksTelemetryExporter {
232231
protoLogs,
233232
};
234233

235-
logger.log(
236-
LogLevel.debug,
237-
`Exporting ${metrics.length} telemetry metrics to ${
238-
authenticatedExport ? 'authenticated' : 'unauthenticated'
239-
} endpoint`,
240-
);
241-
242234
// Get authentication headers if using authenticated endpoint
243235
const authHeaders = authenticatedExport ? await this.context.getAuthHeaders() : {};
244236

@@ -258,8 +250,6 @@ export default class DatabricksTelemetryExporter {
258250
error.statusCode = response.status;
259251
throw error;
260252
}
261-
262-
logger.log(LogLevel.debug, `Successfully exported ${metrics.length} telemetry metrics`);
263253
}
264254

265255
/**

lib/telemetry/MetricsAggregator.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,6 @@ export default class MetricsAggregator {
347347
const metricsToExport = [...this.pendingMetrics];
348348
this.pendingMetrics = [];
349349

350-
logger.log(LogLevel.debug, `Flushing ${metricsToExport.length} telemetry metrics`);
351-
352350
// Export metrics (exporter.export never throws)
353351
this.exporter.export(metricsToExport);
354352
} catch (error: any) {

lib/telemetry/TelemetryClient.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ class TelemetryClient {
2626
private closed: boolean = false;
2727

2828
constructor(private context: IClientContext, private host: string) {
29-
const logger = context.getLogger();
30-
logger.log(LogLevel.debug, `Created TelemetryClient for host: ${host}`);
29+
// Client created silently
3130
}
3231

3332
/**
@@ -54,15 +53,13 @@ class TelemetryClient {
5453
}
5554

5655
try {
57-
const logger = this.context.getLogger();
58-
logger.log(LogLevel.debug, `Closing TelemetryClient for host: ${this.host}`);
5956
this.closed = true;
6057
} catch (error: any) {
6158
// Swallow all exceptions per requirement
6259
this.closed = true;
6360
try {
6461
const logger = this.context.getLogger();
65-
logger.log(LogLevel.debug, `Error closing TelemetryClient: ${error.message}`);
62+
logger.log(LogLevel.debug, `Telemetry close error: ${error.message}`);
6663
} catch (logError: any) {
6764
// If even logging fails, silently swallow
6865
}

lib/telemetry/TelemetryClientProvider.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ class TelemetryClientProvider {
4040

4141
constructor(private context: IClientContext) {
4242
this.clients = new Map();
43-
const logger = context.getLogger();
44-
logger.log(LogLevel.debug, 'Created TelemetryClientProvider');
4543
}
4644

4745
/**
@@ -52,7 +50,6 @@ class TelemetryClientProvider {
5250
* @returns The telemetry client for the host
5351
*/
5452
getOrCreateClient(host: string): TelemetryClient {
55-
const logger = this.context.getLogger();
5653
let holder = this.clients.get(host);
5754

5855
if (!holder) {
@@ -63,12 +60,10 @@ class TelemetryClientProvider {
6360
refCount: 0,
6461
};
6562
this.clients.set(host, holder);
66-
logger.log(LogLevel.debug, `Created new TelemetryClient for host: ${host}`);
6763
}
6864

6965
// Increment reference count
7066
holder.refCount += 1;
71-
logger.log(LogLevel.debug, `TelemetryClient reference count for ${host}: ${holder.refCount}`);
7267

7368
return holder.client;
7469
}
@@ -84,23 +79,21 @@ class TelemetryClientProvider {
8479
const holder = this.clients.get(host);
8580

8681
if (!holder) {
87-
logger.log(LogLevel.debug, `No TelemetryClient found for host: ${host}`);
8882
return;
8983
}
9084

9185
// Decrement reference count
9286
holder.refCount -= 1;
93-
logger.log(LogLevel.debug, `TelemetryClient reference count for ${host}: ${holder.refCount}`);
9487

9588
// Close and remove client when reference count reaches zero
9689
if (holder.refCount <= 0) {
9790
try {
9891
await holder.client.close();
9992
this.clients.delete(host);
100-
logger.log(LogLevel.debug, `Closed and removed TelemetryClient for host: ${host}`);
93+
logger.log(LogLevel.debug, 'Telemetry: closed');
10194
} catch (error: any) {
10295
// Swallow all exceptions per requirement
103-
logger.log(LogLevel.debug, `Error releasing TelemetryClient: ${error.message}`);
96+
logger.log(LogLevel.debug, `Telemetry close error: ${error.message}`);
10497
}
10598
}
10699
}

spec/telemetry-design.md

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1843,11 +1843,38 @@ process.on('SIGTERM', async () => {
18431843
- Telemetry failures should never impact the driver's core functionality
18441844
- **Critical**: Circuit breaker must catch errors **before** swallowing
18451845

1846+
#### Logging Policy - Silent by Default
1847+
1848+
**Telemetry logging is kept as silent as possible** to avoid noise in customer logs:
1849+
1850+
**Startup Messages** (LogLevel.debug):
1851+
1852+
- `Telemetry: enabled` - When telemetry is successfully initialized
1853+
- `Telemetry: disabled` - When feature flag disables telemetry
1854+
1855+
**Shutdown Messages** (LogLevel.debug):
1856+
1857+
- `Telemetry: closed` - When telemetry client is closed
1858+
1859+
**Error Messages** (LogLevel.debug):
1860+
1861+
- `Telemetry initialization error: <message>` - Only on initialization failures
1862+
- `Telemetry close error: <message>` - Only on cleanup failures
1863+
- `Telemetry export error: <message>` - Only on export failures
1864+
- `Circuit breaker OPEN - dropping telemetry` - Only when circuit breaker opens
1865+
1866+
**Never Logged**:
1867+
1868+
- Individual event emissions (connection.open, statement.start, etc.)
1869+
- Metric flushing operations
1870+
- Successful exports
1871+
- Reference counting changes
1872+
- Client creation/lifecycle events
1873+
18461874
#### Logging Levels
18471875

1848-
- **TRACE** (console.debug): Use for most telemetry errors (default)
1849-
- **DEBUG** (console.debug): Use only for circuit breaker state changes
1850-
- **WARN/ERROR**: Never use for telemetry errors
1876+
- **DEBUG** (LogLevel.debug): All telemetry messages use this level
1877+
- **WARN/ERROR**: Never used for telemetry - avoids customer anxiety
18511878

18521879
#### Exception Handling Pattern
18531880

@@ -1858,8 +1885,8 @@ try {
18581885
// Telemetry operation
18591886
this.telemetryEmitter.emitStatementComplete({ ... });
18601887
} catch (error) {
1861-
// Swallow ALL exceptions
1862-
console.debug('[TRACE] Telemetry error:', error);
1888+
// Swallow ALL exceptions - no logging unless critical
1889+
logger.log(LogLevel.debug, `Telemetry export error: ${error.message}`);
18631890
}
18641891
```
18651892

0 commit comments

Comments
 (0)