diff --git a/relations/src/gr1cs/namespace.rs b/relations/src/gr1cs/namespace.rs index faf4a2fbe..399094f0e 100644 --- a/relations/src/gr1cs/namespace.rs +++ b/relations/src/gr1cs/namespace.rs @@ -1,26 +1,31 @@ use super::ConstraintSystemRef; use ark_ff::Field; +use tracing::Span; /// A namespaced `ConstraintSystemRef`. #[derive(Clone)] pub struct Namespace { inner: ConstraintSystemRef, - id: Option, + _guard: tracing::span::EnteredSpan, } impl From> for Namespace { fn from(other: ConstraintSystemRef) -> Self { + let span = tracing::info_span!(target: "gr1cs", "namespace"); + let guard = span.enter(); Self { inner: other, - id: None, + _guard: guard, } } } impl Namespace { /// Construct a new `Namespace`. - pub fn new(inner: ConstraintSystemRef, id: Option) -> Self { - Self { inner, id } + pub fn new(inner: ConstraintSystemRef, name: &str) -> Self { + let span = tracing::info_span!(target: "gr1cs", name); + let guard = span.enter(); + Self { inner, _guard: guard } } /// Obtain the inner `ConstraintSystemRef`. @@ -36,9 +41,6 @@ impl Namespace { impl Drop for Namespace { fn drop(&mut self) { - if let Some(id) = self.id.as_ref() { - tracing::dispatcher::get_default(|dispatch| dispatch.exit(id)); - } let _ = self.inner; } } @@ -90,14 +92,8 @@ impl Drop for Namespace { macro_rules! ns { ($cs:expr, $name:expr) => {{ // Define a span with `gr1cs` as the target and the given name - let span = $crate::gr1cs::info_span!(target: "gr1cs", $name); - let id = span.id(); - // Enter the span - let _enter_guard = span.enter(); - // We want the span and the guard to live forever so we forget them - core::mem::forget(_enter_guard); - core::mem::forget(span); - // Create a new namespace - $crate::gr1cs::Namespace::new($cs.clone(), id) + let span = $crate::gr1cs::tracing::info_span!(target: "gr1cs", $name); + let guard = span.enter(); + $crate::gr1cs::Namespace::new($cs.clone(), $name) }}; }