Package com.databricks.jdbc.telemetry.latency

## Class TelemetryCollector

- java.lang.Object
- - com.databricks.jdbc.telemetry.latency.TelemetryCollector

    public class TelemetryCollector
    extends Object

Context handler for tracking telemetry details for Databricks JDBC driver. This class manages per-statement telemetry details and provides logic for data collection.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `exportAllPendingTelemetryDetails()` Exports all pending telemetry details and clears the trackers.
`StatementTelemetryDetails` `getOrCreateTelemetryDetails​(String statementId)` Gets the telemetry details for a statement if present Otherwise creates a new one and persist
`void` `recordChunkDownloadLatency​(String statementId, long chunkIndex, long latencyMillis)` Records the latency for downloading a chunk and updates metrics.
`void` `recordGetOperationStatus​(String statementId, long latencyMillis)`
`void` `recordOperationLatency​(long latencyMillis, String methodName)`
`void` `recordResultSetIteration​(String statementId, Long totalChunks, boolean hasNext)` Records when a result set is iterated/consumed.
`void` `recordTotalChunks​(StatementId statementId, long totalChunks)`
`void` `setResultFormat​(IDatabricksStatementInternal statement, TSparkRowSetType executionResultFormat)`
`void` `setResultFormat​(StatementId statementId, com.databricks.sdk.service.sql.Format executionResultFormat)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### recordChunkDownloadLatency

    public void recordChunkDownloadLatency​(String statementId,
                                           long chunkIndex,
                                           long latencyMillis)

Records the latency for downloading a chunk and updates metrics.

Parameters:
  `statementId` - the statement ID string
  `chunkIndex` - the index of the chunk being downloaded
  `latencyMillis` - the time taken to download the chunk in milliseconds

#### recordTotalChunks

    public void recordTotalChunks​(StatementId statementId,
                                  long totalChunks)

#### recordOperationLatency

    public void recordOperationLatency​(long latencyMillis,
                                       String methodName)

#### recordResultSetIteration

    public void recordResultSetIteration​(String statementId,
                                         Long totalChunks,
                                         boolean hasNext)

Records when a result set is iterated/consumed.

Parameters:
  `statementId` - the statement ID
  `totalChunks` - the total chunks present (if any)
  `hasNext` - if there are any more results left to be iterated

#### getOrCreateTelemetryDetails

    public StatementTelemetryDetails getOrCreateTelemetryDetails​(String statementId)

Gets the telemetry details for a statement if present Otherwise creates a new one and persist

Parameters:
  `statementId` - the statement ID

#### exportAllPendingTelemetryDetails

    public void exportAllPendingTelemetryDetails()

Exports all pending telemetry details and clears the trackers. This method is called when the connection/client is being closed.

#### recordGetOperationStatus

    public void recordGetOperationStatus​(String statementId,
                                         long latencyMillis)

#### setResultFormat

    public void setResultFormat​(IDatabricksStatementInternal statement,
                                TSparkRowSetType executionResultFormat)

#### setResultFormat

    public void setResultFormat​(StatementId statementId,
                                com.databricks.sdk.service.sql.Format executionResultFormat)