From cfa4154131719db3ff687261bca95481cba609ab Mon Sep 17 00:00:00 2001 From: Bob van der Linden Date: Wed, 6 Nov 2024 23:13:33 +0100 Subject: feat(tvix): add instance_name to instrumentation of *Services Currently it is not possible to distinguish between tracing of the same *Service type whenever there are multiple of them. Now the instance_name of ServiceBuilder is passed into the *Service and used in the existing instrument as the `instance_name` field. Places that did not already have a instance_name in its context use `"default"`. In tests I used `"test"`. Change-Id: Ia20bf2a7bb849a781e370d087ba7ddb3be79f654 Reviewed-on: https://cl.tvl.fyi/c/depot/+/12739 Tested-by: BuildkiteCI Autosubmit: Bob van der Linden Reviewed-by: flokli --- tvix/castore/src/blobservice/combinator.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'tvix/castore/src/blobservice/combinator.rs') diff --git a/tvix/castore/src/blobservice/combinator.rs b/tvix/castore/src/blobservice/combinator.rs index 6a964c8a8440..e5f61d6d0c2a 100644 --- a/tvix/castore/src/blobservice/combinator.rs +++ b/tvix/castore/src/blobservice/combinator.rs @@ -16,6 +16,7 @@ use super::{BlobReader, BlobService, BlobWriter, ChunkedReader}; /// blobservice again, before falling back to the remote one. /// The remote BlobService is never written to. pub struct CombinedBlobService { + instance_name: String, local: BL, remote: BR, } @@ -27,6 +28,7 @@ where { fn clone(&self) -> Self { Self { + instance_name: self.instance_name.clone(), local: self.local.clone(), remote: self.remote.clone(), } @@ -39,12 +41,12 @@ where BL: AsRef + Clone + Send + Sync + 'static, BR: AsRef + Clone + Send + Sync + 'static, { - #[instrument(skip(self, digest), fields(blob.digest=%digest))] + #[instrument(skip(self, digest), fields(blob.digest=%digest, instance_name=%self.instance_name))] async fn has(&self, digest: &B3Digest) -> std::io::Result { Ok(self.local.as_ref().has(digest).await? || self.remote.as_ref().has(digest).await?) } - #[instrument(skip(self, digest), fields(blob.digest=%digest), err)] + #[instrument(skip(self, digest), fields(blob.digest=%digest, instance_name=%self.instance_name), err)] async fn open_read(&self, digest: &B3Digest) -> std::io::Result>> { if self.local.as_ref().has(digest).await? { // local store has the blob, so we can assume it also has all chunks. @@ -84,7 +86,7 @@ where } } - #[instrument(skip_all)] + #[instrument(skip_all, fields(instance_name=%self.instance_name))] async fn open_write(&self) -> Box { // direct writes to the local one. self.local.as_ref().open_write().await @@ -113,7 +115,7 @@ impl ServiceBuilder for CombinedBlobServiceConfig { type Output = dyn BlobService; async fn build<'a>( &'a self, - _instance_name: &str, + instance_name: &str, context: &CompositionContext, ) -> Result, Box> { let (local, remote) = futures::join!( @@ -121,6 +123,7 @@ impl ServiceBuilder for CombinedBlobServiceConfig { context.resolve(self.remote.clone()) ); Ok(Arc::new(CombinedBlobService { + instance_name: instance_name.to_string(), local: local?, remote: remote?, })) -- cgit 1.4.1