Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion diskann/src/graph/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use futures_util::FutureExt;
use hashbrown::HashSet;
use thiserror::Error;
use tokio::task::JoinSet;
use tracing::{debug, trace};

use super::{
AdjacencyList, Config, ConsolidateKind, InplaceDeleteMethod, RangeSearchParams, SearchParams,
Expand Down Expand Up @@ -52,6 +51,7 @@ use crate::{
NeighborAccessorMut, SetElement,
},
tracked_error,
tracing::{debug, trace},
utils::{
IntoUsize, TryIntoVectorId, VectorId,
async_tools::{self, DynamicBalancer, VectorIdBoxSlice},
Expand Down
44 changes: 44 additions & 0 deletions diskann/src/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
///
/// Upstream handling should first look for these fields and only if they don't exist should
/// we inspect the file and line included as part of the tracing record.
#[cfg(feature = "tracing")]
#[macro_export]
macro_rules! tracked_error {
($($arg:tt)+) => {{
Expand All @@ -22,6 +23,13 @@ macro_rules! tracked_error {
}};
}

#[cfg(not(feature = "tracing"))]
#[macro_export]
macro_rules! tracked_error {
($($arg:tt)+) => {{}};
}

#[cfg(feature = "tracing")]
#[macro_export]
macro_rules! tracked_warn {
($($arg:tt)+) => {{
Expand All @@ -30,6 +38,13 @@ macro_rules! tracked_warn {
}};
}

#[cfg(not(feature = "tracing"))]
#[macro_export]
macro_rules! tracked_warn {
($($arg:tt)+) => {{}};
}

#[cfg(feature = "tracing")]
#[macro_export]
macro_rules! tracked_debug {
($($arg:tt)+) => {{
Expand All @@ -38,6 +53,35 @@ macro_rules! tracked_debug {
}};
}

#[cfg(not(feature = "tracing"))]
#[macro_export]
macro_rules! tracked_debug {
($($arg:tt)+) => {{}};
}

pub use tracked_debug;
pub use tracked_error;
pub use tracked_warn;

// Re-export tracing macros when the feature is enabled
#[cfg(feature = "tracing")]
pub use tracing::{debug, trace};

// Define no-op macros when the tracing feature is disabled
#[cfg(not(feature = "tracing"))]
#[macro_export]
macro_rules! debug {
($($arg:tt)*) => {{}};
}

#[cfg(not(feature = "tracing"))]
#[macro_export]
macro_rules! trace {
($($arg:tt)*) => {{}};
}

#[cfg(not(feature = "tracing"))]
pub use debug;

#[cfg(not(feature = "tracing"))]
pub use trace;