Skip to content

Commit 42f1e23

Browse files
samikshya-dbclaude
andcommitted
Only populate sql_operation fields when present
- statement_type only included if operationType is set - is_compressed only included if compressed value is set - execution_result only included if resultFormat is set - sql_operation object only created if any field is present Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent a8ec232 commit 42f1e23

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

lib/telemetry/DatabricksTelemetryExporter.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -308,18 +308,20 @@ export default class DatabricksTelemetryExporter {
308308
} else if (metric.metricType === 'statement') {
309309
log.entry.sql_driver_log.operation_latency_ms = metric.latencyMs;
310310

311-
// Always create sql_operation for statement events
312-
log.entry.sql_driver_log.sql_operation = {
313-
statement_type: metric.operationType,
314-
is_compressed: metric.compressed,
315-
execution_result: metric.resultFormat,
316-
};
317-
318-
if (metric.chunkCount && metric.chunkCount > 0) {
319-
log.entry.sql_driver_log.sql_operation.chunk_details = {
320-
total_chunks_present: metric.chunkCount,
321-
total_chunks_iterated: metric.chunkCount,
311+
// Only create sql_operation if we have any fields to include
312+
if (metric.operationType || metric.compressed !== undefined || metric.resultFormat || metric.chunkCount) {
313+
log.entry.sql_driver_log.sql_operation = {
314+
...(metric.operationType && { statement_type: metric.operationType }),
315+
...(metric.compressed !== undefined && { is_compressed: metric.compressed }),
316+
...(metric.resultFormat && { execution_result: metric.resultFormat }),
322317
};
318+
319+
if (metric.chunkCount && metric.chunkCount > 0) {
320+
log.entry.sql_driver_log.sql_operation.chunk_details = {
321+
total_chunks_present: metric.chunkCount,
322+
total_chunks_iterated: metric.chunkCount,
323+
};
324+
}
323325
}
324326
} else if (metric.metricType === 'error') {
325327
log.entry.sql_driver_log.error_info = {

0 commit comments

Comments
 (0)