Skip to main content

Module query_audit

Module query_audit 

Source
Expand description

structured per-query audit record emitted by the FlightSQL service Structured per-query audit record for the FlightSQL service.

execute_query (see flight_sql_service_impl) emits one JSON-serialized crate::servers::query_audit::QueryAuditRecord per query, at completion, under the dedicated flightsql_query_audit log target. Unlike the untagged imetric! cost metrics (whose properties are meant for bounded-cardinality dimensions, not values such as SQL text), a free-text log msg has no cardinality constraint, so it can carry both attribution and cost in one self-contained, queryable record.

peak_memory_bytes/spilled_bytes/spill_count complement the cost fields above: the peak comes from the query’s ScopedMemoryPool (see micromegas_analytics::lakehouse::scoped_memory_pool), while the spill counters are summed from the physical plan tree, same as bytes_scanned.

Structs§

QueryAuditRecord
One structured record per FlightSQL query, emitted as a JSON log line under the flightsql_query_audit target when the query completes, fails, or is abandoned mid-drain (client disconnect/cancel).
ScanMetrics
Aggregated DataFusion plan metrics for one query, read after the stream drains.

Functions§

aggregate_scan_metrics
Walk the physical-plan tree: output_rows from the root node (final result grain), bytes_scanned/spilled_bytes/spill_count summed across every node (leaf DataSourceExec nodes carry bytes_scanned; spilling operators such as ExternalSorter carry the other two). sum_by_name cannot be used for the spill counters: MetricsSet::sum_by_name explicitly returns false for MetricValue::SpillCount/SpilledBytes, so it would silently report zero; the dedicated MetricsSet::spill_count()/spilled_bytes() accessors are used instead.