Was this page helpful?
Caution
You're viewing documentation for an unstable version of Scylla Rust Driver. Switch to the latest stable version.
Simple query, prepared query and batch query
return a QueryResult
which contains a tracing_id
if tracing was enabled.
use scylla::query::Query;
use scylla::QueryResult;
use scylla::tracing::TracingInfo;
use uuid::Uuid;
// Create a Query manually and enable tracing
let mut query: Query = Query::new("INSERT INTO ks.tab (a) VALUES(4)");
query.set_tracing(true);
let res: QueryResult = session.query_unpaged(query, &[]).await?;
let tracing_id: Option<Uuid> = res.tracing_id;
if let Some(id) = tracing_id {
// Query tracing info from system_traces.sessions and system_traces.events
let tracing_info: TracingInfo = session.get_tracing_info(&id).await?;
println!("tracing_info: {:#?}", tracing_info);
}
use scylla::prepared_statement::PreparedStatement;
use scylla::QueryResult;
use scylla::tracing::TracingInfo;
use uuid::Uuid;
// Prepare the query
let mut prepared: PreparedStatement = session
.prepare("SELECT a FROM ks.tab")
.await?;
// Enable tracing for the prepared query
prepared.set_tracing(true);
let res: QueryResult = session.execute_unpaged(&prepared, &[]).await?;
let tracing_id: Option<Uuid> = res.tracing_id;
if let Some(id) = tracing_id {
// Query tracing info from system_traces.sessions and system_traces.events
let tracing_info: TracingInfo = session.get_tracing_info(&id).await?;
println!("tracing_info: {:#?}", tracing_info);
}
use scylla::batch::Batch;
use scylla::QueryResult;
use scylla::tracing::TracingInfo;
use uuid::Uuid;
// Create a batch statement
let mut batch: Batch = Default::default();
batch.append_statement("INSERT INTO ks.tab (a) VALUES(4)");
// Enable tracing
batch.set_tracing(true);
let res: QueryResult = session.batch(&batch, ((),)).await?;
let tracing_id: Option<Uuid> = res.tracing_id;
if let Some(id) = tracing_id {
// Query tracing info from system_traces.sessions and system_traces.events
let tracing_info: TracingInfo = session.get_tracing_info(&id).await?;
println!("tracing_info: {:#?}", tracing_info);
}
Was this page helpful?