Repository navigation
feat(telemetry): add result stream metrics - #273
jay-xiao446 wants to merge 1 commit into
Conversation
Signed-off-by: Jay Xiao <jay.xiao@databricks.com>
|
Closing in favor of #274, which uses the stack branch naming convention and is based on kernel-telemetry-phase-3. |
There was a problem hiding this comment.
Verdict: 2 Low
Looks good overall — the telemetry-finalization refactor is sound: all four success paths (execute, execute_direct, await_result, fetch_result) now attach telemetry to the ResultStream and rely on ResultStreamTelemetry::finish/Drop, and the shared Arc-backed finalized AtomicBool guarantees exactly one terminal event across clones and repeated materialise_result calls. Test coverage (exhaustion, drop-unexhausted, CloudFetch chunk details) is appropriate. Two Low-severity semantic notes on chunk/consumption metric definitions are inline; neither blocks.
|
|
||
| fn record_chunk_download(&self, elapsed: std::time::Duration) { | ||
| let millis = elapsed.as_millis().try_into().unwrap_or(i64::MAX); | ||
| let _ = self.initial_chunk_latency_ms.compare_exchange( |
There was a problem hiding this comment.
🔵 Low — initial_chunk_latency_ms is set by the first download to complete, not the latency of chunk 0. record_chunk_download runs inside the Ok(batches) arm of each concurrently-spawned download_chunk_with_retry task, and the compare_exchange(-1, millis) seats whichever task finishes first. Because chunk downloads run in parallel (spawned at streaming_provider.rs:647), the "first completed" chunk is frequently not chunk 0 — a small later chunk can win the race. If this metric is meant to mirror the reference drivers' notion of time-to-first-chunk (chunk 0 in result order), the value reported here can be misleading. Consider recording chunk 0's own download time specifically, or renaming the field to reflect "first-completed-download" semantics.
| sum_chunks_download_time: metrics.sum_chunks_download_time, | ||
| }); | ||
| } | ||
| if !self.consumed_recorded { |
There was a problem hiding this comment.
🔵 Low — finish unconditionally calls record_result_consumed() (setting consumption_latency) even when invoked from ResultStreamTelemetry::drop on a stream that was never exhausted. A caller that consumes a few batches and drops the stream — or drops it without reading at all — will still report a result_set_consumption_latency_millis, indistinguishable in the emitted event from a fully-drained stream. This can skew aggregate consumption-latency metrics with abandoned/partial reads. If consumption latency is intended to mean "time to fully drain the result set," consider only recording it on the true exhaustion paths (Ok(None) in next_batch/OwnedBatchIter::next) and leaving it unset on the drop-without-exhaustion path.
Summary
Flow
sequenceDiagram participant Statement participant Stream as ResultStream participant Telemetry as StatementTelemetry participant Exporter as TelemetryClient Statement->>Telemetry: on_statement_submitted Statement-->>Stream: attach telemetry Stream->>Telemetry: record first batch + rows loop batches Stream->>Telemetry: accumulate batch/row counts end Stream->>Telemetry: record consumed + chunk metrics Stream->>Exporter: finalize one terminal eventCloudFetch Metrics
flowchart LR CF[CloudFetch Provider] -->|download success| M[Chunk metrics] CF -->|chunk released| M M --> R[ResultReader::metrics] R --> S[ResultStream finalization] S --> T[Statement telemetry event]Validation