diff --git a/instrumented-object-store/src/instrumented_object_store.rs b/instrumented-object-store/src/instrumented_object_store.rs index 9ca5358..a4d80bb 100644 --- a/instrumented-object-store/src/instrumented_object_store.rs +++ b/instrumented-object-store/src/instrumented_object_store.rs @@ -42,23 +42,28 @@ pub fn instrument_object_store( /// A wrapper around an `ObjectStore` that instruments all public methods with tracing. #[derive(Clone, Debug)] -struct InstrumentedObjectStore { - inner: Arc, +pub struct InstrumentedObjectStore { + inner: T, name: String, } -impl InstrumentedObjectStore { +impl InstrumentedObjectStore { /// Creates a new `InstrumentedObjectStore` wrapping the provided `ObjectStore`. /// /// # Arguments /// - /// * `store` - An `Arc`-wrapped `dyn ObjectStore` to be instrumented. - pub fn new(store: Arc, name: &str) -> Self { + /// * `store` - An `ObjectStore` to be instrumented. + pub fn new(store: T, name: impl Into) -> Self { Self { inner: store, - name: name.to_owned(), + name: name.into(), } } + + /// Returns a reference to the inner `ObjectStore`. + pub fn inner(&self) -> &T { + &self.inner + } } trait Instrumentable { @@ -128,14 +133,14 @@ where result } -impl Display for InstrumentedObjectStore { +impl Display for InstrumentedObjectStore { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { Display::fmt(&self.inner, f) } } #[async_trait] -impl ObjectStore for InstrumentedObjectStore { +impl ObjectStore for InstrumentedObjectStore { /// Save the provided bytes to the specified location with tracing. #[instrument( skip_all, diff --git a/instrumented-object-store/src/lib.rs b/instrumented-object-store/src/lib.rs index 1ae1db1..befe6ce 100644 --- a/instrumented-object-store/src/lib.rs +++ b/instrumented-object-store/src/lib.rs @@ -60,4 +60,4 @@ mod instrumented_object_store; -pub use instrumented_object_store::instrument_object_store; +pub use instrumented_object_store::{instrument_object_store, InstrumentedObjectStore};