Skip to main content

Client

Struct Client 

Source
pub struct Client { /* private fields */ }

Implementations§

Source§

impl Client

Source

pub fn new(cfg: Config<'_>) -> Result<Self, ClientError>

Creates a new Client instance that connects to the provided ClickHouse nodes.

§Arguments
  • cfg - Configuration with URLs, credentials, and TLS settings.
§Errors

Returns ClientError if initialization fails, including problems with TLS or URL handling.

Source

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 - A Sender<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.

Source

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 — The normalized_query_hash of the query group to inspect.
  • filter — Optional additional filtering (e.g., time range, user).
  • sender — A Sender<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.

Source

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 - A Sender<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.

Source

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 - A Sender<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).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,