From bf2eb32f010ef20007324649a4e3868ef36b670d Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Tue, 30 Jul 2024 06:51:28 +0100 Subject: [PATCH] Add improved instrumentation to kvs module layer (#4418) --- core/src/cf/gc.rs | 7 +- core/src/cf/reader.rs | 5 +- core/src/key/debug.rs | 63 +++++-- core/src/kvs/api.rs | 43 +++-- core/src/kvs/ds.rs | 26 +-- core/src/kvs/fdb/mod.rs | 44 +++-- core/src/kvs/indxdb/mod.rs | 39 +++-- core/src/kvs/mem/mod.rs | 30 +++- core/src/kvs/node.rs | 14 +- core/src/kvs/rocksdb/mod.rs | 30 +++- core/src/kvs/surrealkv/mod.rs | 30 +++- core/src/kvs/tikv/mod.rs | 36 ++-- core/src/kvs/tr.rs | 80 +++------ core/src/kvs/tx.rs | 267 +++++++++-------------------- lib/src/api/engine/local/native.rs | 2 +- lib/src/api/engine/local/wasm.rs | 2 +- src/cnf/mod.rs | 7 +- src/dbs/mod.rs | 6 +- src/telemetry/logs/mod.rs | 2 +- src/telemetry/mod.rs | 4 +- tests/cli_integration.rs | 11 +- 21 files changed, 364 insertions(+), 384 deletions(-) diff --git a/core/src/cf/gc.rs b/core/src/cf/gc.rs index c26fc59e..b7121d3e 100644 --- a/core/src/cf/gc.rs +++ b/core/src/cf/gc.rs @@ -1,7 +1,6 @@ use crate::err::Error; use crate::key::change; -#[cfg(debug_assertions)] -use crate::key::debug::sprint; +use crate::key::debug::Sprintable; use crate::kvs::Transaction; use crate::vs; use crate::vs::Versionstamp; @@ -84,8 +83,8 @@ pub async fn gc_range( #[cfg(debug_assertions)] trace!( "Performing garbage collection on {ns}:{db} for watermark {watermark:?}, between {} and {}", - sprint(&beg), - sprint(&end) + beg.sprint(), + end.sprint() ); // Delete the entire range in grouped batches tx.delr(beg..end).await?; diff --git a/core/src/cf/reader.rs b/core/src/cf/reader.rs index 125c628c..25e6fb64 100644 --- a/core/src/cf/reader.rs +++ b/core/src/cf/reader.rs @@ -1,8 +1,7 @@ use crate::cf::{ChangeSet, DatabaseMutation, TableMutations}; use crate::err::Error; use crate::key::change; -#[cfg(debug_assertions)] -use crate::key::debug::sprint; +use crate::key::debug::Sprintable; use crate::kvs::Transaction; use crate::sql::statements::show::ShowSince; use crate::vs; @@ -52,7 +51,7 @@ pub async fn read( // iterate over _x and put decoded elements to r for (k, v) in tx.scan(beg..end, limit).await? { #[cfg(debug_assertions)] - trace!("Reading change feed entry: {}", sprint(&k)); + trace!("Reading change feed entry: {}", k.sprint()); // Decode the changefeed entry key let dec = crate::key::change::Cf::decode(&k).unwrap(); // Check the change is for the desired table diff --git a/core/src/key/debug.rs b/core/src/key/debug.rs index 0a82abe3..1db54f85 100644 --- a/core/src/key/debug.rs +++ b/core/src/key/debug.rs @@ -1,12 +1,53 @@ -/// Displays a key in a human-readable format. -#[cfg(debug_assertions)] -pub fn sprint(key: &T) -> String -where - T: AsRef<[u8]>, -{ - key.as_ref() - .iter() - .flat_map(|&byte| std::ascii::escape_default(byte)) - .map(|byte| byte as char) - .collect::() +use std::ops::Range; + +pub trait Sprintable { + fn sprint(&self) -> String; +} + +impl Sprintable for &str { + fn sprint(&self) -> String { + self.to_string() + } +} + +impl Sprintable for String { + fn sprint(&self) -> String { + self.to_string() + } +} + +impl Sprintable for Vec { + fn sprint(&self) -> String { + self.iter() + .flat_map(|&byte| std::ascii::escape_default(byte)) + .map(|byte| byte as char) + .collect::() + } +} + +impl Sprintable for &[u8] { + fn sprint(&self) -> String { + self.iter() + .flat_map(|&byte| std::ascii::escape_default(byte)) + .map(|byte| byte as char) + .collect::() + } +} + +impl Sprintable for Vec +where + T: Sprintable, +{ + fn sprint(&self) -> String { + self.iter().map(Sprintable::sprint).collect::>().join(" + ") + } +} + +impl Sprintable for Range +where + T: Sprintable, +{ + fn sprint(&self) -> String { + format!("{}..{}", self.start.sprint(), self.end.sprint()) + } } diff --git a/core/src/kvs/api.rs b/core/src/kvs/api.rs index af50b595..91d887e3 100644 --- a/core/src/kvs/api.rs +++ b/core/src/kvs/api.rs @@ -2,6 +2,7 @@ use super::kv::Add; use super::tr::Check; use crate::cnf::NORMAL_FETCH_SIZE; use crate::err::Error; +use crate::key::debug::Sprintable; use crate::kvs::batch::Batch; use crate::kvs::Key; use crate::kvs::Val; @@ -50,40 +51,40 @@ pub trait Transaction { /// Check if a key exists in the datastore. async fn exists(&mut self, key: K) -> Result where - K: Into + Debug; + K: Into + Sprintable + Debug; /// Fetch a key from the datastore. async fn get(&mut self, key: K) -> Result, Error> where - K: Into + Debug; + K: Into + Sprintable + Debug; /// Insert or update a key in the datastore. async fn set(&mut self, key: K, val: V) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, V: Into + Debug; /// Insert a key if it doesn't exist in the datastore. async fn put(&mut self, key: K, val: V) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, V: Into + Debug; /// Update a key in the datastore if the current value matches a condition. async fn putc(&mut self, key: K, val: V, chk: Option) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, V: Into + Debug; /// Delete a key from the datastore. async fn del(&mut self, key: K) -> Result<(), Error> where - K: Into + Debug; + K: Into + Sprintable + Debug; /// Delete a key from the datastore if the current value matches a condition. async fn delc(&mut self, key: K, chk: Option) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, V: Into + Debug; /// Retrieve a specific range of keys from the datastore. @@ -91,21 +92,22 @@ pub trait Transaction { /// This function fetches the full range of keys without values, in a single request to the underlying datastore. async fn keys(&mut self, rng: Range, limit: u32) -> Result, Error> where - K: Into + Debug; + K: Into + Sprintable + Debug; /// Retrieve a specific range of keys from the datastore. /// /// This function fetches the full range of key-value pairs, in a single request to the underlying datastore. async fn scan(&mut self, rng: Range, limit: u32) -> Result, Error> where - K: Into + Debug; + K: Into + Sprintable + Debug; /// Fetch many keys from the datastore. /// /// This function fetches all matching keys pairs from the underlying datastore concurrently. + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(keys = keys.sprint()))] async fn getm(&mut self, keys: Vec) -> Result, Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.closed() { @@ -126,9 +128,10 @@ pub trait Transaction { /// Retrieve a range of prefixed keys from the datastore. /// /// This function fetches all matching key-value pairs from the underlying datastore in grouped batches. + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn getp(&mut self, key: K) -> Result, Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.closed() { @@ -143,9 +146,10 @@ pub trait Transaction { /// Retrieve a range of keys from the datastore. /// /// This function fetches all matching key-value pairs from the underlying datastore in grouped batches. + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(rng = rng.sprint()))] async fn getr(&mut self, rng: Range) -> Result, Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.closed() { @@ -169,9 +173,10 @@ pub trait Transaction { /// Delete a range of prefixed keys from the datastore. /// /// This function deletes all matching key-value pairs from the underlying datastore in grouped batches. + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn delp(&mut self, key: K) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.closed() { @@ -190,9 +195,10 @@ pub trait Transaction { /// Delete a range of keys from the datastore. /// /// This function deletes all matching key-value pairs from the underlying datastore in grouped batches. + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(rng = rng.sprint()))] async fn delr(&mut self, rng: Range) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.closed() { @@ -219,9 +225,10 @@ pub trait Transaction { /// Retrieve a batched scan over a specific range of keys in the datastore. /// /// This function fetches keys or key-value pairs, in batches, with multiple requests to the underlying datastore. + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(rng = rng.sprint()))] async fn batch(&mut self, rng: Range, batch: u32, values: bool) -> Result where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.closed() { @@ -269,9 +276,10 @@ pub trait Transaction { /// NOTE: This should be called when composing the change feed entries for this transaction, /// which should be done immediately before the transaction commit. /// That is to keep other transactions commit delay(pessimistic) or conflict(optimistic) as less as possible. + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn get_timestamp(&mut self, key: K) -> Result where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.closed() { @@ -299,6 +307,7 @@ pub trait Transaction { } /// Insert the versionstamped key into the datastore. + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(ts_key = ts_key.sprint()))] async fn set_versionstamp( &mut self, ts_key: K, @@ -307,7 +316,7 @@ pub trait Transaction { val: V, ) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, V: Into + Debug, { // Check to see if transaction is closed diff --git a/core/src/kvs/ds.rs b/core/src/kvs/ds.rs index 5b3c97a2..48d4403f 100644 --- a/core/src/kvs/ds.rs +++ b/core/src/kvs/ds.rs @@ -390,7 +390,7 @@ impl Datastore { } // Initialise the cluster and run bootstrap utilities - #[instrument(err, level = "debug", target = "surrealdb::core::kvs::ds", skip_all)] + #[instrument(err, level = "trace", target = "surrealdb::core::kvs::ds", skip_all)] pub async fn bootstrap(&self) -> Result<(), Error> { // Insert this node in the cluster self.insert_node(self.id).await?; @@ -401,8 +401,8 @@ impl Datastore { } /// Setup the initial cluster access credentials - #[instrument(err, level = "debug", target = "surrealdb::core::kvs::ds", skip_all)] - pub async fn setup_initial_creds(&self, user: &str, pass: &str) -> Result<(), Error> { + #[instrument(err, level = "trace", target = "surrealdb::core::kvs::ds", skip_all)] + pub async fn initialise_credentials(&self, user: &str, pass: &str) -> Result<(), Error> { // Start a new writeable transaction let txn = self.transaction(Write, Optimistic).await?.enclose(); // Fetch the root users from the storage @@ -429,7 +429,7 @@ impl Datastore { // tick is called periodically to perform maintenance tasks. // This is called every TICK_INTERVAL. - #[instrument(level = "debug", skip(self))] + #[instrument(err, level = "trace", target = "surrealdb::core::kvs::ds", skip(self))] pub async fn tick(&self) -> Result<(), Error> { let now = SystemTime::now().duration_since(UNIX_EPOCH).map_err(|e| { Error::Internal(format!("Clock may have gone backwards: {:?}", e.duration())) @@ -442,7 +442,7 @@ impl Datastore { // tick_at is the utility function that is called by tick. // It is handy for testing, because it allows you to specify the timestamp, // without depending on a system clock. - #[instrument(level = "debug", skip(self))] + #[instrument(level = "trace", target = "surrealdb::core::kvs::ds", skip(self))] pub async fn tick_at(&self, ts: u64) -> Result<(), Error> { trace!(target: TARGET, "Ticking at timestamp {ts} ({:?})", conv::u64_to_versionstamp(ts)); let _vs = self.save_timestamp_for_versionstamp(ts).await?; @@ -621,7 +621,7 @@ impl Datastore { /// Ok(()) /// } /// ``` - #[instrument(level = "debug", skip_all)] + #[instrument(level = "debug", target = "surrealdb::core::kvs::ds", skip_all)] pub async fn execute( &self, txt: &str, @@ -651,7 +651,7 @@ impl Datastore { /// Ok(()) /// } /// ``` - #[instrument(level = "debug", skip_all)] + #[instrument(level = "debug", target = "surrealdb::core::kvs::ds", skip_all)] pub async fn process( &self, ast: Query, @@ -727,7 +727,7 @@ impl Datastore { /// Ok(()) /// } /// ``` - #[instrument(level = "debug", skip_all)] + #[instrument(level = "debug", target = "surrealdb::core::kvs::ds", skip_all)] pub async fn compute( &self, val: Value, @@ -814,7 +814,7 @@ impl Datastore { /// Ok(()) /// } /// ``` - #[instrument(level = "debug", skip_all)] + #[instrument(level = "debug", target = "surrealdb::core::kvs::ds", skip_all)] pub async fn evaluate( &self, val: Value, @@ -888,13 +888,13 @@ impl Datastore { /// Ok(()) /// } /// ``` - #[instrument(level = "debug", skip_all)] + #[instrument(level = "debug", target = "surrealdb::core::kvs::ds", skip_all)] pub fn notifications(&self) -> Option> { self.notification_channel.as_ref().map(|v| v.1.clone()) } /// Performs a database import from SQL - #[instrument(level = "debug", skip_all)] + #[instrument(level = "debug", target = "surrealdb::core::kvs::ds", skip_all)] pub async fn import(&self, sql: &str, sess: &Session) -> Result, Error> { // Check if the session has expired if sess.expired() { @@ -905,7 +905,7 @@ impl Datastore { } /// Performs a full database export as SQL - #[instrument(level = "debug", skip_all)] + #[instrument(level = "debug", target = "surrealdb::core::kvs::ds", skip_all)] pub async fn export( &self, sess: &Session, @@ -929,7 +929,7 @@ impl Datastore { } /// Checks the required permissions level for this session - #[instrument(level = "debug", skip(self, sess))] + #[instrument(level = "trace", target = "surrealdb::core::kvs::ds", skip(self, sess))] pub fn check(&self, sess: &Session, action: Action, resource: Resource) -> Result<(), Error> { // Check if the session has expired if sess.expired() { diff --git a/core/src/kvs/fdb/mod.rs b/core/src/kvs/fdb/mod.rs index 1e2971eb..fed8b4b3 100644 --- a/core/src/kvs/fdb/mod.rs +++ b/core/src/kvs/fdb/mod.rs @@ -3,6 +3,7 @@ mod cnf; use crate::err::Error; +use crate::key::debug::Sprintable; use crate::kvs::Check; use crate::kvs::Key; use crate::kvs::Val; @@ -176,6 +177,7 @@ impl super::api::Transaction for Transaction { } /// Cancel a transaction + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self))] async fn cancel(&mut self) -> Result<(), Error> { // Check to see if transaction is closed if self.done { @@ -193,6 +195,7 @@ impl super::api::Transaction for Transaction { } /// Commit a transaction + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self))] async fn commit(&mut self) -> Result<(), Error> { // Check to see if transaction is closed if self.done { @@ -214,9 +217,10 @@ impl super::api::Transaction for Transaction { } /// Check if a key exists + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn exists(&mut self, key: K) -> Result where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.done { @@ -229,9 +233,10 @@ impl super::api::Transaction for Transaction { } /// Fetch a key from the database + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn get(&mut self, key: K) -> Result, Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.done { @@ -250,9 +255,10 @@ impl super::api::Transaction for Transaction { } /// Inserts or update a key in the database + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn set(&mut self, key: K, val: V) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, V: Into + Debug, { // Check to see if transaction is closed @@ -270,9 +276,10 @@ impl super::api::Transaction for Transaction { } /// Insert a key if it doesn't exist in the database + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn put(&mut self, key: K, val: V) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, V: Into + Debug, { // Check to see if transaction is closed @@ -298,9 +305,10 @@ impl super::api::Transaction for Transaction { } /// Insert a key if the current value matches a condition. + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn putc(&mut self, key: K, val: V, chk: Option) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, V: Into + Debug, { // Check to see if transaction is closed @@ -328,9 +336,10 @@ impl super::api::Transaction for Transaction { } /// Delete a key + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn del(&mut self, key: K) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.done { @@ -347,9 +356,10 @@ impl super::api::Transaction for Transaction { } /// Delete a key if the current value matches a condition. + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn delc(&mut self, key: K, chk: Option) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, V: Into + Debug, { // Check to see if transaction is closed @@ -376,9 +386,10 @@ impl super::api::Transaction for Transaction { } /// Delete a range of keys from the databases + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(rng = rng.sprint()))] async fn delr(&mut self, rng: Range) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.done { @@ -395,9 +406,10 @@ impl super::api::Transaction for Transaction { } /// Retrieve a range of keys from the databases + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(rng = rng.sprint()))] async fn keys(&mut self, rng: Range, limit: u32) -> Result, Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.done { @@ -430,9 +442,10 @@ impl super::api::Transaction for Transaction { } /// Retrieve a range of keys from the databases + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(rng = rng.sprint()))] async fn scan(&mut self, rng: Range, limit: u32) -> Result, Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.done { @@ -465,7 +478,11 @@ impl super::api::Transaction for Transaction { } /// Obtain a new change timestamp for a key - async fn get_timestamp(&mut self, _: K) -> Result { + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] + async fn get_timestamp(&mut self, key: K) -> Result + where + K: Into + Sprintable + Debug, + { // Check to see if transaction is closed if self.done { return Err(Error::TxFinished); @@ -479,15 +496,16 @@ impl super::api::Transaction for Transaction { } // Sets the value for a versionstamped key prefixed with the user-supplied key. + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(ts_key = ts_key.sprint()))] async fn set_versionstamp( &mut self, - _: K, + ts_key: K, prefix: K, suffix: K, val: V, ) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, V: Into + Debug, { // Check to see if transaction is closed diff --git a/core/src/kvs/indxdb/mod.rs b/core/src/kvs/indxdb/mod.rs index e62ad002..93631ccf 100644 --- a/core/src/kvs/indxdb/mod.rs +++ b/core/src/kvs/indxdb/mod.rs @@ -1,9 +1,11 @@ #![cfg(feature = "kv-indxdb")] use crate::err::Error; +use crate::key::debug::Sprintable; use crate::kvs::Check; use crate::kvs::Key; use crate::kvs::Val; +use std::fmt::Debug; use std::ops::Range; #[non_exhaustive] @@ -100,6 +102,7 @@ impl super::api::Transaction for Transaction { } /// Cancel a transaction + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self))] async fn cancel(&mut self) -> Result<(), Error> { // Check to see if transaction is closed if self.done { @@ -114,6 +117,7 @@ impl super::api::Transaction for Transaction { } /// Commit a transaction + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self))] async fn commit(&mut self) -> Result<(), Error> { // Check to see if transaction is closed if self.done { @@ -132,9 +136,10 @@ impl super::api::Transaction for Transaction { } /// Check if a key exists + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn exists(&mut self, key: K) -> Result where - K: Into, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.done { @@ -147,9 +152,10 @@ impl super::api::Transaction for Transaction { } /// Fetch a key from the database + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn get(&mut self, key: K) -> Result, Error> where - K: Into, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.done { @@ -162,10 +168,11 @@ impl super::api::Transaction for Transaction { } /// Insert or update a key in the database + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn set(&mut self, key: K, val: V) -> Result<(), Error> where - K: Into, - V: Into, + K: Into + Sprintable + Debug, + V: Into + Debug, { // Check to see if transaction is closed if self.done { @@ -182,10 +189,11 @@ impl super::api::Transaction for Transaction { } /// Insert a key if it doesn't exist in the database + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn put(&mut self, key: K, val: V) -> Result<(), Error> where - K: Into, - V: Into, + K: Into + Sprintable + Debug, + V: Into + Debug, { // Check to see if transaction is closed if self.done { @@ -202,10 +210,11 @@ impl super::api::Transaction for Transaction { } /// Insert a key if the current value matches a condition + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn putc(&mut self, key: K, val: V, chk: Option) -> Result<(), Error> where - K: Into, - V: Into, + K: Into + Sprintable + Debug, + V: Into + Debug, { // Check to see if transaction is closed if self.done { @@ -222,9 +231,10 @@ impl super::api::Transaction for Transaction { } /// Delete a key + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn del(&mut self, key: K) -> Result<(), Error> where - K: Into, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.done { @@ -241,10 +251,11 @@ impl super::api::Transaction for Transaction { } /// Delete a key if the current value matches a condition + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn delc(&mut self, key: K, chk: Option) -> Result<(), Error> where - K: Into, - V: Into, + K: Into + Sprintable + Debug, + V: Into + Debug, { // Check to see if transaction is closed if self.done { @@ -261,9 +272,10 @@ impl super::api::Transaction for Transaction { } /// Retrieve a range of keys from the databases + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(rng = rng.sprint()))] async fn keys(&mut self, rng: Range, limit: u32) -> Result, Error> where - K: Into, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.done { @@ -281,9 +293,10 @@ impl super::api::Transaction for Transaction { } /// Retrieve a range of keys from the databases + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(rng = rng.sprint()))] async fn scan(&mut self, rng: Range, limit: u32) -> Result, Error> where - K: Into, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.done { diff --git a/core/src/kvs/mem/mod.rs b/core/src/kvs/mem/mod.rs index 26ccb86d..bb24bbcb 100644 --- a/core/src/kvs/mem/mod.rs +++ b/core/src/kvs/mem/mod.rs @@ -1,6 +1,7 @@ #![cfg(feature = "kv-mem")] use crate::err::Error; +use crate::key::debug::Sprintable; use crate::kvs::Check; use crate::kvs::Key; use crate::kvs::Val; @@ -98,6 +99,7 @@ impl super::api::Transaction for Transaction { } /// Cancel a transaction + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self))] async fn cancel(&mut self) -> Result<(), Error> { // Check to see if transaction is closed if self.done { @@ -112,6 +114,7 @@ impl super::api::Transaction for Transaction { } /// Commit a transaction + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self))] async fn commit(&mut self) -> Result<(), Error> { // Check to see if transaction is closed if self.done { @@ -130,9 +133,10 @@ impl super::api::Transaction for Transaction { } /// Check if a key exists + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn exists(&mut self, key: K) -> Result where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.done { @@ -145,9 +149,10 @@ impl super::api::Transaction for Transaction { } /// Fetch a key from the database + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn get(&mut self, key: K) -> Result, Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.done { @@ -160,9 +165,10 @@ impl super::api::Transaction for Transaction { } /// Insert or update a key in the database + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn set(&mut self, key: K, val: V) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, V: Into + Debug, { // Check to see if transaction is closed @@ -180,9 +186,10 @@ impl super::api::Transaction for Transaction { } /// Insert a key if it doesn't exist in the database + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn put(&mut self, key: K, val: V) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, V: Into + Debug, { // Check to see if transaction is closed @@ -200,9 +207,10 @@ impl super::api::Transaction for Transaction { } /// Insert a key if the current value matches a condition + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn putc(&mut self, key: K, val: V, chk: Option) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, V: Into + Debug, { // Check to see if transaction is closed @@ -220,9 +228,10 @@ impl super::api::Transaction for Transaction { } /// Delete a key + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn del(&mut self, key: K) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.done { @@ -239,9 +248,10 @@ impl super::api::Transaction for Transaction { } /// Delete a key if the current value matches a condition + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn delc(&mut self, key: K, chk: Option) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, V: Into + Debug, { // Check to see if transaction is closed @@ -259,9 +269,10 @@ impl super::api::Transaction for Transaction { } /// Retrieve a range of keys from the databases + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(rng = rng.sprint()))] async fn keys(&mut self, rng: Range, limit: u32) -> Result, Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.done { @@ -279,9 +290,10 @@ impl super::api::Transaction for Transaction { } /// Retrieve a range of keys from the databases + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(rng = rng.sprint()))] async fn scan(&mut self, rng: Range, limit: u32) -> Result, Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.done { diff --git a/core/src/kvs/node.rs b/core/src/kvs/node.rs index 260663d7..1ec7b6a9 100644 --- a/core/src/kvs/node.rs +++ b/core/src/kvs/node.rs @@ -18,7 +18,7 @@ impl Datastore { /// This function ensures that this node is entered into the clister /// membership entries. This function must be run at server or database /// startup, in order to write the initial entry and timestamp to storage. - #[instrument(err, level = "debug", target = "surrealdb::core::kvs::node", skip(self))] + #[instrument(err, level = "trace", target = "surrealdb::core::kvs::node", skip(self))] pub async fn insert_node(&self, id: uuid::Uuid) -> Result<(), Error> { // Log when this method is run trace!(target: TARGET, "Inserting node in the cluster"); @@ -42,7 +42,7 @@ impl Datastore { /// This function updates the entry for this node with an up-to-date /// timestamp. This ensures that the node is not marked as expired by any /// garbage collection tasks, preventing any data cleanup for this node. - #[instrument(err, level = "debug", target = "surrealdb::core::kvs::node", skip(self))] + #[instrument(err, level = "trace", target = "surrealdb::core::kvs::node", skip(self))] pub async fn update_node(&self, id: uuid::Uuid) -> Result<(), Error> { // Log when this method is run trace!(target: TARGET, "Updating node in the cluster"); @@ -61,7 +61,7 @@ impl Datastore { /// This function marks the node as archived, ready for garbage collection. /// Later on when garbage collection is running the live queries assigned /// to this node will be removed, along with the node itself. - #[instrument(err, level = "debug", target = "surrealdb::core::kvs::node", skip(self))] + #[instrument(err, level = "trace", target = "surrealdb::core::kvs::node", skip(self))] pub async fn delete_node(&self, id: uuid::Uuid) -> Result<(), Error> { // Log when this method is run trace!(target: TARGET, "Archiving node in the cluster"); @@ -80,7 +80,7 @@ impl Datastore { /// This function marks the node as archived, ready for garbage collection. /// Later on when garbage collection is running the live queries assigned /// to this node will be removed, along with the node itself. - #[instrument(err, level = "debug", target = "surrealdb::core::kvs::node", skip(self))] + #[instrument(err, level = "trace", target = "surrealdb::core::kvs::node", skip(self))] pub async fn expire_nodes(&self) -> Result<(), Error> { // Log when this method is run trace!(target: TARGET, "Archiving expired nodes in the cluster"); @@ -115,7 +115,7 @@ impl Datastore { /// This function clears up all nodes which have been marked as archived. /// When a matching node is found, all node queries, and table queries are /// garbage collected, before the node itself is completely deleted. - #[instrument(err, level = "debug", target = "surrealdb::core::kvs::node", skip(self))] + #[instrument(err, level = "trace", target = "surrealdb::core::kvs::node", skip(self))] pub async fn cleanup_nodes(&self) -> Result<(), Error> { // Log when this method is run trace!(target: TARGET, "Cleaning up archived nodes in the cluster"); @@ -188,7 +188,7 @@ impl Datastore { /// in the cluster, from all namespaces, databases, and tables. It uses /// a number of transactions in order to prevent failure of large or /// long-running transactions on distributed storage engines. - #[instrument(err, level = "debug", target = "surrealdb::core::kvs::node", skip(self))] + #[instrument(err, level = "trace", target = "surrealdb::core::kvs::node", skip(self))] pub async fn garbage_collect(&self) -> Result<(), Error> { // Log the node deletion trace!(target: TARGET, "Garbage collecting all miscellaneous data"); @@ -269,7 +269,7 @@ impl Datastore { /// are specified by uique live query UUIDs. This is necessary when a /// WebSocket disconnects, and any associated live queries need to be /// cleaned up and removed. - #[instrument(err, level = "debug", target = "surrealdb::core::kvs::node", skip(self))] + #[instrument(err, level = "trace", target = "surrealdb::core::kvs::node", skip(self))] pub async fn delete_queries(&self, ids: Vec) -> Result<(), Error> { // Log the node deletion trace!(target: TARGET, "Deleting live queries for a connection"); diff --git a/core/src/kvs/rocksdb/mod.rs b/core/src/kvs/rocksdb/mod.rs index 8aed8627..f7847f3e 100644 --- a/core/src/kvs/rocksdb/mod.rs +++ b/core/src/kvs/rocksdb/mod.rs @@ -3,6 +3,7 @@ mod cnf; use crate::err::Error; +use crate::key::debug::Sprintable; use crate::kvs::Check; use crate::kvs::Key; use crate::kvs::Val; @@ -176,6 +177,7 @@ impl super::api::Transaction for Transaction { } /// Cancel a transaction + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self))] async fn cancel(&mut self) -> Result<(), Error> { // Check to see if transaction is closed if self.done { @@ -193,6 +195,7 @@ impl super::api::Transaction for Transaction { } /// Commit a transaction + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self))] async fn commit(&mut self) -> Result<(), Error> { // Check to see if transaction is closed if self.done { @@ -214,9 +217,10 @@ impl super::api::Transaction for Transaction { } /// Check if a key exists + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn exists(&mut self, key: K) -> Result where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.done { @@ -229,9 +233,10 @@ impl super::api::Transaction for Transaction { } /// Fetch a key from the database + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn get(&mut self, key: K) -> Result, Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.done { @@ -244,9 +249,10 @@ impl super::api::Transaction for Transaction { } /// Insert or update a key in the database + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn set(&mut self, key: K, val: V) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, V: Into + Debug, { // Check to see if transaction is closed @@ -264,9 +270,10 @@ impl super::api::Transaction for Transaction { } /// Insert a key if it doesn't exist in the database + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn put(&mut self, key: K, val: V) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, V: Into + Debug, { // Check to see if transaction is closed @@ -292,9 +299,10 @@ impl super::api::Transaction for Transaction { } /// Insert a key if the current value matches a condition + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn putc(&mut self, key: K, val: V, chk: Option) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, V: Into + Debug, { // Check to see if transaction is closed @@ -322,9 +330,10 @@ impl super::api::Transaction for Transaction { } /// Delete a key + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn del(&mut self, key: K) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.done { @@ -341,9 +350,10 @@ impl super::api::Transaction for Transaction { } /// Delete a key if the current value matches a condition + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn delc(&mut self, key: K, chk: Option) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, V: Into + Debug, { // Check to see if transaction is closed @@ -370,9 +380,10 @@ impl super::api::Transaction for Transaction { } /// Retrieve a range of keys from the databases + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(rng = rng.sprint()))] async fn keys(&mut self, rng: Range, limit: u32) -> Result, Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.done { @@ -420,9 +431,10 @@ impl super::api::Transaction for Transaction { } /// Retrieve a range of keys from the databases + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(rng = rng.sprint()))] async fn scan(&mut self, rng: Range, limit: u32) -> Result, Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.done { diff --git a/core/src/kvs/surrealkv/mod.rs b/core/src/kvs/surrealkv/mod.rs index fbd6f4f4..a257edd3 100644 --- a/core/src/kvs/surrealkv/mod.rs +++ b/core/src/kvs/surrealkv/mod.rs @@ -1,6 +1,7 @@ #![cfg(feature = "kv-surrealkv")] use crate::err::Error; +use crate::key::debug::Sprintable; use crate::kvs::Check; use crate::kvs::Key; use crate::kvs::Val; @@ -107,6 +108,7 @@ impl super::api::Transaction for Transaction { } /// Cancels the transaction. + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self))] async fn cancel(&mut self) -> Result<(), Error> { // Check to see if transaction is closed if self.done { @@ -121,6 +123,7 @@ impl super::api::Transaction for Transaction { } /// Commits the transaction. + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self))] async fn commit(&mut self) -> Result<(), Error> { // Check to see if transaction is closed if self.done { @@ -139,9 +142,10 @@ impl super::api::Transaction for Transaction { } /// Checks if a key exists in the database. + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn exists(&mut self, key: K) -> Result where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.done { @@ -154,9 +158,10 @@ impl super::api::Transaction for Transaction { } /// Fetch a key from the database + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn get(&mut self, key: K) -> Result, Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.done { @@ -169,9 +174,10 @@ impl super::api::Transaction for Transaction { } /// Insert or update a key in the database + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn set(&mut self, key: K, val: V) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, V: Into + Debug, { // Check to see if transaction is closed @@ -189,9 +195,10 @@ impl super::api::Transaction for Transaction { } /// Insert a key if it doesn't exist in the database + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn put(&mut self, key: K, val: V) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, V: Into + Debug, { // Check to see if transaction is closed @@ -215,9 +222,10 @@ impl super::api::Transaction for Transaction { } /// Insert a key if the current value matches a condition + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn putc(&mut self, key: K, val: V, chk: Option) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, V: Into + Debug, { // Check to see if transaction is closed @@ -243,9 +251,10 @@ impl super::api::Transaction for Transaction { } /// Deletes a key from the database. + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn del(&mut self, key: K) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.done { @@ -262,9 +271,10 @@ impl super::api::Transaction for Transaction { } /// Delete a key if the current value matches a condition + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn delc(&mut self, key: K, chk: Option) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, V: Into + Debug, { // Check to see if transaction is closed @@ -289,9 +299,10 @@ impl super::api::Transaction for Transaction { } /// Retrieves a range of key-value pairs from the database. + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(rng = rng.sprint()))] async fn keys(&mut self, rng: Range, limit: u32) -> Result, Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.done { @@ -309,9 +320,10 @@ impl super::api::Transaction for Transaction { } /// Retrieves a range of key-value pairs from the database. + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(rng = rng.sprint()))] async fn scan(&mut self, rng: Range, limit: u32) -> Result, Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.done { diff --git a/core/src/kvs/tikv/mod.rs b/core/src/kvs/tikv/mod.rs index c3568cd9..d8736737 100644 --- a/core/src/kvs/tikv/mod.rs +++ b/core/src/kvs/tikv/mod.rs @@ -1,6 +1,7 @@ #![cfg(feature = "kv-tikv")] use crate::err::Error; +use crate::key::debug::Sprintable; use crate::kvs::Check; use crate::kvs::Key; use crate::kvs::Val; @@ -125,6 +126,7 @@ impl super::api::Transaction for Transaction { } /// Cancel a transaction + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self))] async fn cancel(&mut self) -> Result<(), Error> { // Check to see if transaction is closed if self.done { @@ -141,6 +143,7 @@ impl super::api::Transaction for Transaction { } /// Commit a transaction + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self))] async fn commit(&mut self) -> Result<(), Error> { // Check to see if transaction is closed if self.done { @@ -164,9 +167,10 @@ impl super::api::Transaction for Transaction { } /// Check if a key exists + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn exists(&mut self, key: K) -> Result where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.done { @@ -179,9 +183,10 @@ impl super::api::Transaction for Transaction { } /// Fetch a key from the database + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn get(&mut self, key: K) -> Result, Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.done { @@ -194,9 +199,10 @@ impl super::api::Transaction for Transaction { } /// Insert or update a key in the database + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn set(&mut self, key: K, val: V) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, V: Into + Debug, { // Check to see if transaction is closed @@ -214,9 +220,10 @@ impl super::api::Transaction for Transaction { } /// Insert a key if it doesn't exist in the database + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn put(&mut self, key: K, val: V) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, V: Into + Debug, { // Check to see if transaction is closed @@ -241,9 +248,10 @@ impl super::api::Transaction for Transaction { } /// Insert a key if the current value matches a condition + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn putc(&mut self, key: K, val: V, chk: Option) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, V: Into + Debug, { // Check to see if transaction is closed @@ -271,9 +279,10 @@ impl super::api::Transaction for Transaction { } /// Delete a key + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn del(&mut self, key: K) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.done { @@ -290,9 +299,10 @@ impl super::api::Transaction for Transaction { } /// Delete a key if the current value matches a condition + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn delc(&mut self, key: K, chk: Option) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, V: Into + Debug, { // Check to see if transaction is closed @@ -318,9 +328,10 @@ impl super::api::Transaction for Transaction { } /// Delete a range of keys from the databases + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(rng = rng.sprint()))] async fn delr(&mut self, rng: Range) -> Result<(), Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.done { @@ -337,9 +348,10 @@ impl super::api::Transaction for Transaction { } /// Delete a range of keys from the database + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(rng = rng.sprint()))] async fn keys(&mut self, rng: Range, limit: u32) -> Result, Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.done { @@ -357,9 +369,10 @@ impl super::api::Transaction for Transaction { } /// Retrieve a range of keys from the database + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(rng = rng.sprint()))] async fn scan(&mut self, rng: Range, limit: u32) -> Result, Error> where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.done { @@ -377,9 +390,10 @@ impl super::api::Transaction for Transaction { } /// Obtain a new change timestamp for a key + #[instrument(level = "trace", target = "surrealdb::core::kvs::api", skip(self), fields(key = key.sprint()))] async fn get_timestamp(&mut self, key: K) -> Result where - K: Into + Debug, + K: Into + Sprintable + Debug, { // Check to see if transaction is closed if self.done { diff --git a/core/src/kvs/tr.rs b/core/src/kvs/tr.rs index 1376619d..5eb5c6f7 100644 --- a/core/src/kvs/tr.rs +++ b/core/src/kvs/tr.rs @@ -5,8 +5,7 @@ use crate::cf; use crate::dbs::node::Timestamp; use crate::err::Error; use crate::idg::u32::U32; -#[cfg(debug_assertions)] -use crate::key::debug::sprint; +use crate::key::debug::Sprintable; use crate::kvs::batch::Batch; use crate::kvs::clock::SizedClock; use crate::kvs::stash::Stash; @@ -21,11 +20,8 @@ use std::fmt::Debug; use std::ops::Range; use std::sync::Arc; -#[cfg(debug_assertions)] -const TARGET: &str = "surrealdb::core::kvs::tr"; - /// Used to determine the behaviour when a transaction is not closed correctly -#[derive(Default)] +#[derive(Debug, Default)] pub enum Check { #[default] None, @@ -147,9 +143,8 @@ impl Transactor { /// transactions, whilst in development we should panic /// so that any unintended behaviour is detected, and in /// production we should only log a warning. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tr", skip_all)] pub(crate) fn check_level(&mut self, check: Check) { - #[cfg(debug_assertions)] - trace!(target: TARGET, "check_level"); expand_inner!(&mut self.inner, v => { v.check_level(check) }) } @@ -159,207 +154,191 @@ impl Transactor { /// then this function will return [`true`], and any further /// calls to functions on this transaction will result /// in a [`Error::TxFinished`] error. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tr", skip_all)] pub async fn closed(&self) -> bool { - #[cfg(debug_assertions)] - trace!(target: TARGET, "closed"); expand_inner!(&self.inner, v => { v.closed() }) } /// Cancel a transaction. /// /// This reverses all changes made within the transaction. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tr", skip_all)] pub async fn cancel(&mut self) -> Result<(), Error> { - #[cfg(debug_assertions)] - trace!(target: TARGET, "cancel"); expand_inner!(&mut self.inner, v => { v.cancel().await }) } /// Commit a transaction. /// /// This attempts to commit all changes made within the transaction. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tr", skip_all)] pub async fn commit(&mut self) -> Result<(), Error> { - #[cfg(debug_assertions)] - trace!(target: TARGET, "commit"); expand_inner!(&mut self.inner, v => { v.commit().await }) } /// Check if a key exists in the datastore. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tr", skip_all)] pub async fn exists(&mut self, key: K) -> Result where K: Into + Debug, { let key = key.into(); - #[cfg(debug_assertions)] - trace!(target: TARGET, "exists {}", sprint(&key)); expand_inner!(&mut self.inner, v => { v.exists(key).await }) } /// Fetch a key from the datastore. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tr", skip_all)] pub async fn get(&mut self, key: K) -> Result, Error> where K: Into + Debug, { let key = key.into(); - #[cfg(debug_assertions)] - trace!(target: TARGET, "get {}", sprint(&key)); expand_inner!(&mut self.inner, v => { v.get(key).await }) } /// Fetch many keys from the datastore. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tr", skip_all)] pub async fn getm(&mut self, keys: Vec) -> Result, Error> where K: Into + Debug, { let keys = keys.into_iter().map(Into::into).collect::>(); - #[cfg(debug_assertions)] - trace!(target: TARGET, "getm {}", keys.iter().map(sprint).collect::>().join(" + ")); expand_inner!(&mut self.inner, v => { v.getm(keys).await }) } /// Retrieve a specific range of keys from the datastore. /// /// This function fetches all matching key-value pairs from the underlying datastore in grouped batches. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tr", skip_all)] pub async fn getr(&mut self, rng: Range) -> Result, Error> where K: Into + Debug, { let beg: Key = rng.start.into(); let end: Key = rng.end.into(); - #[cfg(debug_assertions)] - trace!(target: TARGET, "getr {}..{}", sprint(&beg), sprint(&end)); expand_inner!(&mut self.inner, v => { v.getr(beg..end).await }) } /// Retrieve a specific prefixed range of keys from the datastore. /// /// This function fetches all matching key-value pairs from the underlying datastore in grouped batches. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tr", skip_all)] pub async fn getp(&mut self, key: K) -> Result, Error> where K: Into + Debug, { let key: Key = key.into(); - #[cfg(debug_assertions)] - trace!(target: TARGET, "getp {}", sprint(&key)); expand_inner!(&mut self.inner, v => { v.getp(key).await }) } /// Insert or update a key in the datastore. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tr", skip_all)] pub async fn set(&mut self, key: K, val: V) -> Result<(), Error> where K: Into + Debug, V: Into + Debug, { let key = key.into(); - #[cfg(debug_assertions)] - trace!(target: TARGET, "set {} => {:?}", sprint(&key), val); expand_inner!(&mut self.inner, v => { v.set(key, val).await }) } /// Insert a key if it doesn't exist in the datastore. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tr", skip_all)] pub async fn put(&mut self, key: K, val: V) -> Result<(), Error> where K: Into + Debug, V: Into + Debug, { let key = key.into(); - #[cfg(debug_assertions)] - trace!(target: TARGET, "put {} => {:?}", sprint(&key), val); expand_inner!(&mut self.inner, v => { v.put(key, val).await }) } /// Update a key in the datastore if the current value matches a condition. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tr", skip_all)] pub async fn putc(&mut self, key: K, val: V, chk: Option) -> Result<(), Error> where K: Into + Debug, V: Into + Debug, { let key = key.into(); - #[cfg(debug_assertions)] - trace!(target: TARGET, "putc {} if {:?} => {:?}", sprint(&key), chk, val); expand_inner!(&mut self.inner, v => { v.putc(key, val, chk).await }) } /// Delete a key from the datastore. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tr", skip_all)] pub async fn del(&mut self, key: K) -> Result<(), Error> where K: Into + Debug, { let key = key.into(); - #[cfg(debug_assertions)] - trace!(target: TARGET, "del {}", sprint(&key)); expand_inner!(&mut self.inner, v => { v.del(key).await }) } /// Delete a key from the datastore if the current value matches a condition. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tr", skip_all)] pub async fn delc(&mut self, key: K, chk: Option) -> Result<(), Error> where K: Into + Debug, V: Into + Debug, { let key = key.into(); - #[cfg(debug_assertions)] - trace!(target: TARGET, "delc {} if {:?}", sprint(&key), chk); expand_inner!(&mut self.inner, v => { v.delc(key, chk).await }) } /// Delete a range of keys from the datastore. /// /// This function deletes all matching key-value pairs from the underlying datastore in grouped batches. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tr", skip_all)] pub async fn delr(&mut self, rng: Range) -> Result<(), Error> where K: Into + Debug, { let beg: Key = rng.start.into(); let end: Key = rng.end.into(); - #[cfg(debug_assertions)] - trace!(target: TARGET, "delr {}..{}", sprint(&beg), sprint(&end)); expand_inner!(&mut self.inner, v => { v.delr(beg..end).await }) } /// Delete a prefixed range of keys from the datastore. /// /// This function deletes all matching key-value pairs from the underlying datastore in grouped batches. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tr", skip_all)] pub async fn delp(&mut self, key: K) -> Result<(), Error> where K: Into + Debug, { let key: Key = key.into(); - #[cfg(debug_assertions)] - trace!(target: TARGET, "delp {}", sprint(&key)); expand_inner!(&mut self.inner, v => { v.delp(key).await }) } /// Retrieve a specific range of keys from the datastore. /// /// This function fetches the full range of keys without values, in a single request to the underlying datastore. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tr", skip_all)] pub async fn keys(&mut self, rng: Range, limit: u32) -> Result, Error> where K: Into + Debug, { let beg: Key = rng.start.into(); let end: Key = rng.end.into(); - #[cfg(debug_assertions)] - trace!(target: TARGET, "keys {}..{} (limit: {limit})", sprint(&beg), sprint(&end)); expand_inner!(&mut self.inner, v => { v.keys(beg..end, limit).await }) } /// Retrieve a specific range of keys from the datastore. /// /// This function fetches the full range of key-value pairs, in a single request to the underlying datastore. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tr", skip_all)] pub async fn scan(&mut self, rng: Range, limit: u32) -> Result, Error> where K: Into + Debug, { let beg: Key = rng.start.into(); let end: Key = rng.end.into(); - #[cfg(debug_assertions)] - trace!(target: TARGET, "scan {}..{} (limit: {limit})", sprint(&beg), sprint(&end)); expand_inner!(&mut self.inner, v => { v.scan(beg..end, limit).await }) } /// Retrieve a batched scan over a specific range of keys in the datastore. /// /// This function fetches keys or key-value pairs, in batches, with multiple requests to the underlying datastore. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tr", skip_all)] pub async fn batch( &mut self, rng: Range, @@ -371,8 +350,6 @@ impl Transactor { { let beg: Key = rng.start.into(); let end: Key = rng.end.into(); - #[cfg(debug_assertions)] - trace!(target: TARGET, "batch {}..{} (batch: {batch})", sprint(&beg), sprint(&end)); expand_inner!(&mut self.inner, v => { v.batch(beg..end, batch, values).await }) } @@ -381,20 +358,15 @@ impl Transactor { /// NOTE: This should be called when composing the change feed entries for this transaction, /// which should be done immediately before the transaction commit. /// That is to keep other transactions commit delay(pessimistic) or conflict(optimistic) as less as possible. - #[allow(unused)] pub async fn get_timestamp(&mut self, key: K) -> Result where K: Into + Debug, { - // We convert to byte slice as its easier at this level let key = key.into(); - #[cfg(debug_assertions)] - trace!(target: TARGET, "get_timestamp {}", sprint(&key)); expand_inner!(&mut self.inner, v => { v.get_timestamp(key).await }) } /// Insert or update a key in the datastore. - #[allow(unused_variables)] pub async fn set_versionstamped( &mut self, ts_key: K, @@ -409,14 +381,6 @@ impl Transactor { let ts_key = ts_key.into(); let prefix = prefix.into(); let suffix = suffix.into(); - #[cfg(debug_assertions)] - trace!( - target: TARGET, - "set_versionstamp ts={} prefix={} suffix={}", - sprint(&ts_key), - sprint(&prefix), - sprint(&suffix) - ); expand_inner!(&mut self.inner, v => { v.set_versionstamp(ts_key, prefix, suffix, val).await }) } @@ -605,7 +569,7 @@ impl Transactor { ts, ns, db, - sprint(k) + k.sprint() ); let k = crate::key::database::ts::Ts::decode(k)?; let latest_ts = k.ts; diff --git a/core/src/kvs/tx.rs b/core/src/kvs/tx.rs index eb75a0f2..5d2ddd15 100644 --- a/core/src/kvs/tx.rs +++ b/core/src/kvs/tx.rs @@ -36,9 +36,6 @@ use std::ops::Range; use std::sync::Arc; use uuid::Uuid; -#[cfg(debug_assertions)] -const TARGET: &str = "surrealdb::core::kvs::tx"; - #[non_exhaustive] pub struct Transaction { /// The underlying transactor @@ -52,7 +49,11 @@ impl Transaction { pub fn new(tx: Transactor) -> Transaction { Transaction { tx: Mutex::new(tx), - cache: Cache::with_weighter(*TRANSACTION_CACHE_SIZE, 10_000, EntryWeighter), + cache: Cache::with_weighter( + *TRANSACTION_CACHE_SIZE, + *TRANSACTION_CACHE_SIZE as u64, + EntryWeighter, + ), } } @@ -84,6 +85,7 @@ impl Transaction { /// Cancel a transaction. /// /// This reverses all changes made within the transaction. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip_all)] pub async fn cancel(&self) -> Result<(), Error> { self.lock().await.cancel().await } @@ -91,11 +93,13 @@ impl Transaction { /// Commit a transaction. /// /// This attempts to commit all changes made within the transaction. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip_all)] pub async fn commit(&self) -> Result<(), Error> { self.lock().await.commit().await } /// Check if a key exists in the datastore. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip_all)] pub async fn exists(&self, key: K) -> Result where K: Into + Debug, @@ -104,6 +108,7 @@ impl Transaction { } /// Fetch a key from the datastore. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip_all)] pub async fn get(&self, key: K) -> Result, Error> where K: Into + Debug, @@ -112,6 +117,7 @@ impl Transaction { } /// Retrieve a batch set of keys from the datastore. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip_all)] pub async fn getm(&self, keys: Vec) -> Result, Error> where K: Into + Debug, @@ -122,6 +128,7 @@ impl Transaction { /// Retrieve a specific prefix of keys from the datastore. /// /// This function fetches key-value pairs from the underlying datastore in grouped batches. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip_all)] pub async fn getp(&self, key: K) -> Result, Error> where K: Into + Debug, @@ -132,6 +139,7 @@ impl Transaction { /// Retrieve a specific range of keys from the datastore. /// /// This function fetches key-value pairs from the underlying datastore in grouped batches. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip_all)] pub async fn getr(&self, rng: Range) -> Result, Error> where K: Into + Debug, @@ -140,6 +148,7 @@ impl Transaction { } /// Delete a key from the datastore. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip_all)] pub async fn del(&self, key: K) -> Result<(), Error> where K: Into + Debug, @@ -148,6 +157,7 @@ impl Transaction { } /// Delete a key from the datastore if the current value matches a condition. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip_all)] pub async fn delc(&self, key: K, chk: Option) -> Result<(), Error> where K: Into + Debug, @@ -159,6 +169,7 @@ impl Transaction { /// Delete a range of keys from the datastore. /// /// This function deletes entries from the underlying datastore in grouped batches. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip_all)] pub async fn delr(&self, rng: Range) -> Result<(), Error> where K: Into + Debug, @@ -169,6 +180,7 @@ impl Transaction { /// Delete a prefix of keys from the datastore. /// /// This function deletes entries from the underlying datastore in grouped batches. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip_all)] pub async fn delp(&self, key: K) -> Result<(), Error> where K: Into + Debug, @@ -177,6 +189,7 @@ impl Transaction { } /// Insert or update a key in the datastore. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip_all)] pub async fn set(&self, key: K, val: V) -> Result<(), Error> where K: Into + Debug, @@ -186,6 +199,7 @@ impl Transaction { } /// Insert a key if it doesn't exist in the datastore. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip_all)] pub async fn put(&self, key: K, val: V) -> Result<(), Error> where K: Into + Debug, @@ -195,6 +209,7 @@ impl Transaction { } /// Update a key in the datastore if the current value matches a condition. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip_all)] pub async fn putc(&self, key: K, val: V, chk: Option) -> Result<(), Error> where K: Into + Debug, @@ -206,6 +221,7 @@ impl Transaction { /// Retrieve a specific range of keys from the datastore. /// /// This function fetches the full range of keys, in a single request to the underlying datastore. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip_all)] pub async fn keys(&self, rng: Range, limit: u32) -> Result, Error> where K: Into + Debug, @@ -216,6 +232,7 @@ impl Transaction { /// Retrieve a specific range of keys from the datastore. /// /// This function fetches the full range of key-value pairs, in a single request to the underlying datastore. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip_all)] pub async fn scan(&self, rng: Range, limit: u32) -> Result, Error> where K: Into + Debug, @@ -226,6 +243,7 @@ impl Transaction { /// Retrieve a batched scan over a specific range of keys in the datastore. /// /// This function fetches the key-value pairs in batches, with multiple requests to the underlying datastore. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip_all)] pub async fn batch(&self, rng: Range, batch: u32, values: bool) -> Result where K: Into + Debug, @@ -236,6 +254,7 @@ impl Transaction { /// Retrieve a stream over a specific range of keys in the datastore. /// /// This function fetches the key-value pairs in batches, with multiple requests to the underlying datastore. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip_all)] pub fn stream(&self, rng: Range) -> impl Stream> + '_ where K: Into + Debug, @@ -276,11 +295,9 @@ impl Transaction { // Cache methods // -------------------------------------------------- + /// Retrieve all nodes belonging to this cluster. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn all_nodes(&self) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "all_nodes"); - // Continue with the function logic let key = crate::key::root::nd::prefix(); let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { @@ -298,11 +315,8 @@ impl Transaction { } /// Retrieve all ROOT level users in a datastore. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn all_root_users(&self) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "all_root_users"); - // Continue with the function logic let key = crate::key::root::us::prefix(); let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { @@ -321,10 +335,6 @@ impl Transaction { /// Retrieve all ROOT level accesses in a datastore. pub async fn all_root_accesses(&self) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "all_root_accesses"); - // Continue with the function logic let key = crate::key::root::ac::prefix(); let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { @@ -342,11 +352,8 @@ impl Transaction { } /// Retrieve all namespace definitions in a datastore. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn all_ns(&self) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "all_ns"); - // Continue with the function logic let key = crate::key::root::ns::prefix(); let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { @@ -364,11 +371,8 @@ impl Transaction { } /// Retrieve all namespace user definitions for a specific namespace. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn all_ns_users(&self, ns: &str) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "all_ns_users {ns}"); - // Continue with the function logic let key = crate::key::namespace::us::prefix(ns); let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { @@ -386,11 +390,8 @@ impl Transaction { } /// Retrieve all namespace access definitions for a specific namespace. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn all_ns_accesses(&self, ns: &str) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "all_ns_accesses {ns}"); - // Continue with the function logic let key = crate::key::namespace::ac::prefix(ns); let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { @@ -408,11 +409,8 @@ impl Transaction { } /// Retrieve all database definitions for a specific namespace. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn all_db(&self, ns: &str) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "all_db {ns}"); - // Continue with the function logic let key = crate::key::namespace::db::prefix(ns); let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { @@ -430,15 +428,12 @@ impl Transaction { } /// Retrieve all database user definitions for a specific database. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn all_db_users( &self, ns: &str, db: &str, ) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "all_db_users {ns} {db}"); - // Continue with the function logic let key = crate::key::database::us::prefix(ns, db); let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { @@ -456,15 +451,12 @@ impl Transaction { } /// Retrieve all database access definitions for a specific database. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn all_db_accesses( &self, ns: &str, db: &str, ) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "all_db_accesses {ns} {db}"); - // Continue with the function logic let key = crate::key::database::ac::prefix(ns, db); let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { @@ -482,15 +474,12 @@ impl Transaction { } /// Retrieve all analyzer definitions for a specific database. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn all_db_analyzers( &self, ns: &str, db: &str, ) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "all_db_analyzers {ns} {db}"); - // Continue with the function logic let key = crate::key::database::az::prefix(ns, db); let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { @@ -508,15 +497,12 @@ impl Transaction { } /// Retrieve all function definitions for a specific database. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn all_db_functions( &self, ns: &str, db: &str, ) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "all_db_functions {ns} {db}"); - // Continue with the function logic let key = crate::key::database::fc::prefix(ns, db); let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { @@ -534,15 +520,12 @@ impl Transaction { } /// Retrieve all param definitions for a specific database. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn all_db_params( &self, ns: &str, db: &str, ) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "all_db_params {ns} {db}"); - // Continue with the function logic let key = crate::key::database::pa::prefix(ns, db); let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { @@ -560,15 +543,12 @@ impl Transaction { } /// Retrieve all model definitions for a specific database. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn all_db_models( &self, ns: &str, db: &str, ) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "all_db_models {ns} {db}"); - // Continue with the function logic let key = crate::key::database::ml::prefix(ns, db); let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { @@ -586,11 +566,8 @@ impl Transaction { } /// Retrieve all table definitions for a specific database. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn all_tb(&self, ns: &str, db: &str) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "all_tb {ns} {db}"); - // Continue with the function logic let key = crate::key::database::tb::prefix(ns, db); let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { @@ -608,16 +585,13 @@ impl Transaction { } /// Retrieve all event definitions for a specific table. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn all_tb_events( &self, ns: &str, db: &str, tb: &str, ) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "all_tb_events {ns} {db} {tb}"); - // Continue with the function logic let key = crate::key::table::ev::prefix(ns, db, tb); let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { @@ -635,16 +609,13 @@ impl Transaction { } /// Retrieve all field definitions for a specific table. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn all_tb_fields( &self, ns: &str, db: &str, tb: &str, ) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "all_tb_fields {ns} {db} {tb}"); - // Continue with the function logic let key = crate::key::table::fd::prefix(ns, db, tb); let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { @@ -662,16 +633,13 @@ impl Transaction { } /// Retrieve all index definitions for a specific table. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn all_tb_indexes( &self, ns: &str, db: &str, tb: &str, ) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "all_tb_indexes {ns} {db} {tb}"); - // Continue with the function logic let key = crate::key::table::ix::prefix(ns, db, tb); let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { @@ -689,16 +657,13 @@ impl Transaction { } /// Retrieve all view definitions for a specific table. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn all_tb_views( &self, ns: &str, db: &str, tb: &str, ) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "all_tb_views {ns} {db} {tb}"); - // Continue with the function logic let key = crate::key::table::ft::prefix(ns, db, tb); let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { @@ -716,16 +681,13 @@ impl Transaction { } /// Retrieve all live definitions for a specific table. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn all_tb_lives( &self, ns: &str, db: &str, tb: &str, ) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "all_tb_lives {ns} {db} {tb}"); - // Continue with the function logic let key = crate::key::table::lq::prefix(ns, db, tb); let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { @@ -743,11 +705,8 @@ impl Transaction { } /// Retrieve a specific namespace definition. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn get_node(&self, id: Uuid) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "get_node {id}"); - // Continue with the function logic let key = crate::key::root::nd::new(id).encode()?; let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { @@ -766,18 +725,15 @@ impl Transaction { } /// Retrieve a specific namespace user definition. - pub async fn get_root_user(&self, user: &str) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "get_root_user {user}"); - // Continue with the function logic - let key = crate::key::root::us::new(user).encode()?; + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] + pub async fn get_root_user(&self, us: &str) -> Result, Error> { + let key = crate::key::root::us::new(us).encode()?; let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { Ok(val) => val, Err(cache) => { let val = self.get(key).await?.ok_or(Error::UserRootNotFound { - value: user.to_owned(), + value: us.to_owned(), })?; let val: DefineUserStatement = val.into(); let val = Entry::Any(Arc::new(val)); @@ -790,10 +746,6 @@ impl Transaction { /// Retrieve a specific namespace user definition. pub async fn get_root_access(&self, user: &str) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "get_root_access {user}"); - // Continue with the function logic let key = crate::key::root::ac::new(user).encode()?; let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { @@ -812,11 +764,8 @@ impl Transaction { } /// Retrieve a specific namespace definition. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn get_ns(&self, ns: &str) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "get_ns {ns}"); - // Continue with the function logic let key = crate::key::root::ns::new(ns).encode()?; let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { @@ -835,22 +784,15 @@ impl Transaction { } /// Retrieve a specific namespace user definition. - pub async fn get_ns_user( - &self, - ns: &str, - user: &str, - ) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "get_ns_user {ns} {user}"); - // Continue with the function logic - let key = crate::key::namespace::us::new(ns, user).encode()?; + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] + pub async fn get_ns_user(&self, ns: &str, us: &str) -> Result, Error> { + let key = crate::key::namespace::us::new(ns, us).encode()?; let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { Ok(val) => val, Err(cache) => { let val = self.get(key).await?.ok_or(Error::UserNsNotFound { - value: user.to_owned(), + value: us.to_owned(), ns: ns.to_owned(), })?; let val: DefineUserStatement = val.into(); @@ -863,15 +805,12 @@ impl Transaction { } /// Retrieve a specific namespace access definition. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn get_ns_access( &self, ns: &str, na: &str, ) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "get_ns_access {ns} {na}"); - // Continue with the function logic let key = crate::key::namespace::ac::new(ns, na).encode()?; let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { @@ -891,11 +830,8 @@ impl Transaction { } /// Retrieve a specific database definition. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn get_db(&self, ns: &str, db: &str) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "get_db {ns} {db}"); - // Continue with the function logic let key = crate::key::namespace::db::new(ns, db).encode()?; let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { @@ -914,23 +850,20 @@ impl Transaction { } /// Retrieve a specific user definition from a database. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn get_db_user( &self, ns: &str, db: &str, - user: &str, + us: &str, ) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "get_db_user {ns} {db} {user}"); - // Continue with the function logic - let key = crate::key::database::us::new(ns, db, user).encode()?; + let key = crate::key::database::us::new(ns, db, us).encode()?; let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { Ok(val) => val, Err(cache) => { let val = self.get(key).await?.ok_or(Error::UserDbNotFound { - value: user.to_owned(), + value: us.to_owned(), ns: ns.to_owned(), db: db.to_owned(), })?; @@ -944,16 +877,13 @@ impl Transaction { } /// Retrieve a specific database access definition. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn get_db_access( &self, ns: &str, db: &str, da: &str, ) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "get_db_access {ns} {db} {da}"); - // Continue with the function logic let key = crate::key::database::ac::new(ns, db, da).encode()?; let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { @@ -974,6 +904,7 @@ impl Transaction { } /// Retrieve a specific model definition from a database. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn get_db_model( &self, ns: &str, @@ -981,10 +912,6 @@ impl Transaction { ml: &str, vn: &str, ) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "get_db_model {ns} {db} {ml} {vn}"); - // Continue with the function logic let key = crate::key::database::ml::new(ns, db, ml, vn).encode()?; let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { @@ -1003,16 +930,13 @@ impl Transaction { } /// Retrieve a specific analyzer definition. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn get_db_analyzer( &self, ns: &str, db: &str, az: &str, ) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "get_db_analyzer {ns} {db} {az}"); - // Continue with the function logic let key = crate::key::database::az::new(ns, db, az).encode()?; let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { @@ -1031,16 +955,13 @@ impl Transaction { } /// Retrieve a specific function definition from a database. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn get_db_function( &self, ns: &str, db: &str, fc: &str, ) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "get_db_function {ns} {db} {fc}"); - // Continue with the function logic let key = crate::key::database::fc::new(ns, db, fc).encode()?; let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { @@ -1059,16 +980,13 @@ impl Transaction { } /// Retrieve a specific function definition from a database. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn get_db_param( &self, ns: &str, db: &str, pa: &str, ) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "get_db_param {ns} {db} {pa}"); - // Continue with the function logic let key = crate::key::database::pa::new(ns, db, pa).encode()?; let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { @@ -1087,16 +1005,13 @@ impl Transaction { } /// Retrieve a specific table definition. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn get_tb( &self, ns: &str, db: &str, tb: &str, ) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "get_tb {ns} {db} {tb}"); - // Continue with the function logic let key = crate::key::database::tb::new(ns, db, tb).encode()?; let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { @@ -1115,6 +1030,7 @@ impl Transaction { } /// Retrieve an event for a table. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn get_tb_event( &self, ns: &str, @@ -1122,10 +1038,6 @@ impl Transaction { tb: &str, ev: &str, ) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "get_tb_event {ns} {db} {tb} {ev}"); - // Continue with the function logic let key = crate::key::table::ev::new(ns, db, tb, ev).encode()?; let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { @@ -1144,6 +1056,7 @@ impl Transaction { } /// Retrieve a field for a table. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn get_tb_field( &self, ns: &str, @@ -1151,10 +1064,6 @@ impl Transaction { tb: &str, fd: &str, ) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "get_tb_field {ns} {db} {tb} {fd}"); - // Continue with the function logic let key = crate::key::table::fd::new(ns, db, tb, fd).encode()?; let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { @@ -1173,6 +1082,7 @@ impl Transaction { } /// Retrieve an index for a table. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn get_tb_index( &self, ns: &str, @@ -1180,10 +1090,6 @@ impl Transaction { tb: &str, ix: &str, ) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "get_tb_index {ns} {db} {tb} {ix}"); - // Continue with the function logic let key = crate::key::table::ix::new(ns, db, tb, ix).encode()?; let res = self.cache.get_value_or_guard_async(&key).await; Ok(match res { @@ -1202,6 +1108,7 @@ impl Transaction { } /// Fetch a specific record value. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn get_record( &self, ns: &str, @@ -1209,10 +1116,6 @@ impl Transaction { tb: &str, id: &Id, ) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "get_record {ns} {db} {tb} {id}"); - // Continue with the function logic let key = crate::key::thing::new(ns, db, tb, id).encode()?; let res = self.cache.get_value_or_guard_async(&key).await; match res { @@ -1232,6 +1135,7 @@ impl Transaction { } } + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn set_record( &self, ns: &str, @@ -1240,10 +1144,6 @@ impl Transaction { id: &Id, val: Value, ) -> Result<(), Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "set_record {ns} {db} {tb} {id} {val}"); - // Continue with the function logic let key = crate::key::thing::new(ns, db, tb, id); let enc = crate::key::thing::new(ns, db, tb, id).encode()?; // Set the value in the datastore @@ -1255,33 +1155,28 @@ impl Transaction { } /// Get or add a namespace with a default configuration, only if we are in dynamic mode. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn get_or_add_ns( &self, ns: &str, strict: bool, ) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "get_or_add_ns {ns}"); - // Continue with the function logic self.get_or_add_ns_upwards(ns, strict, false).await } /// Get or add a database with a default configuration, only if we are in dynamic mode. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn get_or_add_db( &self, ns: &str, db: &str, strict: bool, ) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "get_or_add_db {ns} {db}"); - // Continue with the function logic self.get_or_add_db_upwards(ns, db, strict, false).await } /// Get or add a table with a default configuration, only if we are in dynamic mode. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] pub async fn get_or_add_tb( &self, ns: &str, @@ -1289,14 +1184,11 @@ impl Transaction { tb: &str, strict: bool, ) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "get_or_add_tb {ns} {db} {tb}"); - // Continue with the function logic self.get_or_add_tb_upwards(ns, db, tb, strict, false).await } /// Ensures that a table, database, and namespace are all fully defined. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] #[inline(always)] pub async fn ensure_ns_db_tb( &self, @@ -1305,14 +1197,11 @@ impl Transaction { tb: &str, strict: bool, ) -> Result, Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "ensure_ns_db_tb {ns} {db} {tb}"); - // Continue with the function logic self.get_or_add_tb_upwards(ns, db, tb, strict, true).await } /// Ensure a specific table (and database, and namespace) exist. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] #[inline(always)] pub(crate) async fn check_ns_db_tb( &self, @@ -1321,10 +1210,6 @@ impl Transaction { tb: &str, strict: bool, ) -> Result<(), Error> { - // Log this function call in development - #[cfg(debug_assertions)] - trace!(target: TARGET, "check_ns_db_tb {ns} {db} {tb}"); - // Continue with the function logic match strict { // Strict mode is disabled false => Ok(()), @@ -1373,6 +1258,7 @@ impl Transaction { } /// Clears all keys from the transaction cache. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] #[inline(always)] pub fn clear(&self) { self.cache.clear() @@ -1383,6 +1269,7 @@ impl Transaction { // -------------------------------------------------- /// Get or add a namespace with a default configuration, only if we are in dynamic mode. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] async fn get_or_add_ns_upwards( &self, ns: &str, @@ -1434,6 +1321,7 @@ impl Transaction { } /// Get or add a database with a default configuration, only if we are in dynamic mode. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] async fn get_or_add_db_upwards( &self, ns: &str, @@ -1500,6 +1388,7 @@ impl Transaction { } /// Get or add a table with a default configuration, only if we are in dynamic mode. + #[instrument(level = "trace", target = "surrealdb::core::kvs::tx", skip(self))] async fn get_or_add_tb_upwards( &self, ns: &str, diff --git a/lib/src/api/engine/local/native.rs b/lib/src/api/engine/local/native.rs index 29367ffe..749a372c 100644 --- a/lib/src/api/engine/local/native.rs +++ b/lib/src/api/engine/local/native.rs @@ -86,7 +86,7 @@ pub(crate) async fn run_router( } // If a root user is specified, setup the initial datastore credentials if let Some(root) = configured_root { - if let Err(error) = kvs.setup_initial_creds(root.username, root.password).await { + if let Err(error) = kvs.initialise_credentials(root.username, root.password).await { let _ = conn_tx.send(Err(error.into())).await; return; } diff --git a/lib/src/api/engine/local/wasm.rs b/lib/src/api/engine/local/wasm.rs index 1708f2bc..623504a9 100644 --- a/lib/src/api/engine/local/wasm.rs +++ b/lib/src/api/engine/local/wasm.rs @@ -82,7 +82,7 @@ pub(crate) async fn run_router( } // If a root user is specified, setup the initial datastore credentials if let Some(root) = configured_root { - if let Err(error) = kvs.setup_initial_creds(root.username, root.password).await { + if let Err(error) = kvs.initialise_credentials(root.username, root.password).await { let _ = conn_tx.send(Err(error.into())).await; return; } diff --git a/src/cnf/mod.rs b/src/cnf/mod.rs index 0f761504..ee6605ca 100644 --- a/src/cnf/mod.rs +++ b/src/cnf/mod.rs @@ -17,10 +17,9 @@ Y88b d88P Y88b 888 888 888 Y8b. 888 888 888 888 .d88P 888 d88P #[cfg(debug_assertions)] pub const DEBUG_BUILD_WARNING: &str = "\ ┌─────────────────────────────────────────────────────────────────────────────┐ -│ !!! THIS IS A DEBUG BUILD !!! │ -│ Debug builds are not intended for production use and include │ -│ tooling and features that we would not recommend people run on │ -│ live data. │ +│ !!! THIS IS A DEVELOPMENT BUILD !!! │ +│ Development builds are not intended for production use and include │ +│ tooling and features that may affect the performance of the database. | └─────────────────────────────────────────────────────────────────────────────┘"; /// The publicly visible name of the server diff --git a/src/dbs/mod.rs b/src/dbs/mod.rs index e02c7de5..cc36f77a 100644 --- a/src/dbs/mod.rs +++ b/src/dbs/mod.rs @@ -241,7 +241,7 @@ pub async fn init( .with_capabilities(capabilities); // Setup initial server auth credentials if let (Some(user), Some(pass)) = (opt.user.as_ref(), opt.pass.as_ref()) { - dbs.setup_initial_creds(user, pass).await?; + dbs.initialise_credentials(user, pass).await?; } // Bootstrap the datastore dbs.bootstrap().await?; @@ -275,7 +275,7 @@ mod tests { ds.transaction(Read, Optimistic).await.unwrap().all_root_users().await.unwrap().len(), 0 ); - ds.setup_initial_creds(creds.username, creds.password).await.unwrap(); + ds.initialise_credentials(creds.username, creds.password).await.unwrap(); assert_eq!( ds.transaction(Read, Optimistic).await.unwrap().all_root_users().await.unwrap().len(), 1 @@ -297,7 +297,7 @@ mod tests { .hash .clone(); - ds.setup_initial_creds(creds.username, creds.password).await.unwrap(); + ds.initialise_credentials(creds.username, creds.password).await.unwrap(); assert_eq!( pass_hash, ds.transaction(Read, Optimistic) diff --git a/src/telemetry/logs/mod.rs b/src/telemetry/logs/mod.rs index 7ede22ae..ff70e6fc 100644 --- a/src/telemetry/logs/mod.rs +++ b/src/telemetry/logs/mod.rs @@ -28,7 +28,7 @@ where .with_line_number(true) .with_thread_ids(false) .with_thread_names(false) - .with_span_events(FmtSpan::NONE) + .with_span_events(FmtSpan::NEW | FmtSpan::CLOSE) .with_writer(std::io::stderr) .with_filter(filter.0) .boxed() diff --git a/src/telemetry/mod.rs b/src/telemetry/mod.rs index aa9421f1..f2861586 100644 --- a/src/telemetry/mod.rs +++ b/src/telemetry/mod.rs @@ -108,10 +108,10 @@ pub fn filter_from_value(v: &str) -> Result { "info" => Ok(EnvFilter::default().add_directive(Level::INFO.into())), // Otherwise, let's show debugs and above "debug" => EnvFilter::builder() - .parse("warn,surreal=debug,surrealdb=debug,surrealdb::core::kvs=info"), + .parse("warn,surreal=debug,surrealdb=debug,surrealdb::core::kvs=debug"), // Specify the log level for each code area "trace" => EnvFilter::builder() - .parse("warn,surreal=trace,surrealdb=trace,surrealdb::core::kvs=info"), + .parse("warn,surreal=trace,surrealdb=trace,surrealdb::core::kvs=debug"), // Check if we should show all surreal logs "full" => EnvFilter::builder().parse("debug,surreal=trace,surrealdb=trace"), // Check if we should show all module logs diff --git a/tests/cli_integration.rs b/tests/cli_integration.rs index 6edeeab2..e559926e 100644 --- a/tests/cli_integration.rs +++ b/tests/cli_integration.rs @@ -82,12 +82,12 @@ mod cli_integration { #[cfg(debug_assertions)] { - info!("* Debug builds contain debug message"); + info!("* Development builds contain debug message"); let args = format!( "sql --conn http://{addr} {creds} --ns {ns} --db {db} --multi --hide-welcome" ); let output = common::run(&args).input("CREATE any:any;\n").output().unwrap(); - assert!(output.contains("Debug builds are not intended for production use")); + assert!(output.contains("Development builds are not intended for production use")); } info!("* Create a record"); @@ -1456,10 +1456,9 @@ fn remove_debug_info(output: String) -> String { // Look... sometimes you just gotta copy paste let output_warning = "\ ┌─────────────────────────────────────────────────────────────────────────────┐ -│ !!! THIS IS A DEBUG BUILD !!! │ -│ Debug builds are not intended for production use and include │ -│ tooling and features that we would not recommend people run on │ -│ live data. │ +│ !!! THIS IS A DEVELOPMENT BUILD !!! │ +│ Development builds are not intended for production use and include │ +│ tooling and features that may affect the performance of the database. | └─────────────────────────────────────────────────────────────────────────────┘ "; // The last line in the above is important