Skip to main content

QueryTraceBuilder

Struct QueryTraceBuilder 

Source
pub struct QueryTraceBuilder { /* private fields */ }
Expand description

Builder for creating and tracking query execution traces.

§Example

use fraiseql_core::runtime::query_tracing::QueryTraceBuilder;

let mut builder = QueryTraceBuilder::new("query_123", "{ user { id name } }");

// Record parse phase (2.5ms = 2500 microseconds)
builder.record_phase_success("parse", 2500);

// Record validate phase (3ms = 3000 microseconds)
builder.record_phase_success("validate", 3000);

// Record execute phase (7ms = 7000 microseconds)
builder.record_phase_success("execute", 7000);

// Finalize trace with result count
let trace = builder.finish(true, None, Some(42))?;
assert_eq!(trace.success, true);
assert_eq!(trace.result_count, Some(42));
println!("Query took {} microseconds", trace.total_duration_us);

Implementations§

Source§

impl QueryTraceBuilder

Source

pub fn new(query_id: &str, query: &str) -> Self

Create new query trace builder.

§Arguments
  • query_id - Unique ID for query correlation
  • query - Query string (will be truncated if very long)
Source

pub fn record_phase_success(&mut self, phase_name: &str, duration_us: u64)

Record a phase that completed successfully.

§Arguments
  • phase_name - Name of phase (e.g., “parse”, “validate”)
  • duration_us - Duration in microseconds
Source

pub fn record_phase_error( &mut self, phase_name: &str, duration_us: u64, error: &str, )

Record a phase that failed.

§Arguments
  • phase_name - Name of phase (e.g., “parse”, “validate”)
  • duration_us - Duration in microseconds
  • error - Error message
Source

pub fn finish( self, success: bool, error: Option<&str>, result_count: Option<usize>, ) -> Result<QueryExecutionTrace>

Finish tracing and create final trace record.

§Arguments
  • success - Whether query executed successfully
  • error - Optional error message
  • result_count - Number of results returned (if applicable)
§Returns

Complete query execution trace

Source

pub fn query_id(&self) -> &str

Get query ID for logging/correlation.

Source

pub fn elapsed_us(&self) -> u64

Get current elapsed time in microseconds.

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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