pub struct Client { /* private fields */ }Implementations§
Source§impl Client
impl Client
Sourcepub fn new(cfg: Config<'_>) -> Result<Self, ClientError>
pub fn new(cfg: Config<'_>) -> Result<Self, ClientError>
Sourcepub async fn stream_logs_by_fingerprint(
&self,
filter: QueryLogFilter,
sender: Sender<QueryLog>,
) -> Result<(), ClientError>
pub async fn stream_logs_by_fingerprint( &self, filter: QueryLogFilter, sender: Sender<QueryLog>, ) -> Result<(), ClientError>
Streams grouped query log data matching the specified filter, grouped by fingerprint (normalized_query_hash).
Useful for identifying query patterns and their cumulative impact across the system.
§Arguments
filter- Filter criteria (time range, user, etc.).sender- ASender<QueryLog>to push results into a stream or channel.
§Errors
Returns ClientError if the query fails, parsing fails, or sending on the channel fails.
§ClickHouse schema dependency
This relies on the system.query_log table and expects ClickHouse to be configured to log queries.
Sourcepub async fn stream_log_by_fingerprint(
&self,
fingerprint: u64,
filter: QueryLogFilter,
sender: Sender<QueryLogExtended>,
) -> Result<(), ClientError>
pub async fn stream_log_by_fingerprint( &self, fingerprint: u64, filter: QueryLogFilter, sender: Sender<QueryLogExtended>, ) -> Result<(), ClientError>
Retrieves detailed query log metrics for a specific query fingerprint.
This method is intended for drill-down analysis of a known query fingerprint
(normalized_query_hash). Unlike Self::stream_logs_by_fingerprint,
which aggregates metrics across all fingerprints, this function focuses on a
single query group, providing extended information.
§Arguments
fingerprint— Thenormalized_query_hashof the query group to inspect.filter— Optional additional filtering (e.g., time range, user).sender— ASender<QueryLogExtended>to stream the result.
§Returns
Ok(())— If the query completed successfully.Err(ClientError)— On ClickHouse query failure or channel send error.
§ClickHouse schema dependency
Relies on the system.query_log table and assumes it includes normalized query hashes.
Sourcepub async fn stream_logs_total(
&self,
filter: QueryLogFilter,
sender: Sender<QueryLogTotal>,
) -> Result<(), ClientError>
pub async fn stream_logs_total( &self, filter: QueryLogFilter, sender: Sender<QueryLogTotal>, ) -> Result<(), ClientError>
Streams total aggregated query log metrics matching the specified filter.
Unlike Self::stream_logs_by_fingerprint, this method does not group by query fingerprint.
Instead, it aggregates metrics across all matching Select queries within the query_log
for a given filter, returning a single total result.
Useful for high-level monitoring of cluster-wide query impact over a period of time.
§Arguments
filter- Filter criteria to restrict the aggregation scope (e.g., time range, user).sender- ASender<QueryLogTotal>to deliver the aggregated result to consumers.
§Returns
Ok(())- If the aggregation completed successfully.Err(ClientError)- On query failure, data parsing issue, or channel send error.
§ClickHouse schema dependency
Relies on the system.query_log table with query profiling enabled.
Sourcepub async fn stream_error_by_code(
&self,
filter: ErrorFilter,
sender: Sender<Error>,
) -> Result<(), ClientError>
pub async fn stream_error_by_code( &self, filter: ErrorFilter, sender: Sender<Error>, ) -> Result<(), ClientError>
Streams error statistics from ClickHouse’s system.errors table based on the provided filter.
Useful for monitoring the frequency and severity of runtime errors by error code.
§Arguments
filter- Filter criteria (e.g. time range, minimum count).sender- ASender<Error>to stream the results.
§Errors
Returns ClientError for query or channel failures.
§ClickHouse schema dependency
Requires that system.errors is populated (i.e., error collection is enabled in ClickHouse).