refactor(tvix/castore): instrument DirectoryPutter impls consistently
Log the entire span with "trace" level, not just its `ret` level. The level of the error value event defaults to ERROR, so we don't loose these. B3Digest implements Debug and Display the same way, so we can omit the `(Display)` part in `ret(Display)` for them. Change-Id: Id00d123a5798e5bdc9820dd97ae2b4d4eb5455f0 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11218 Tested-by: BuildkiteCI Reviewed-by: Connor Brewster <cbrewster@hey.com>
This commit is contained in:
		
							parent
							
								
									60b47b336b
								
							
						
					
					
						commit
						345a639e79
					
				
					 2 changed files with 5 additions and 4 deletions
				
			
		| 
						 | 
					@ -234,6 +234,7 @@ impl GRPCPutter {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[async_trait]
 | 
					#[async_trait]
 | 
				
			||||||
impl DirectoryPutter for GRPCPutter {
 | 
					impl DirectoryPutter for GRPCPutter {
 | 
				
			||||||
 | 
					    #[instrument(level = "trace", skip_all, fields(directory.digest=%directory.digest()), err)]
 | 
				
			||||||
    async fn put(&mut self, directory: proto::Directory) -> Result<(), crate::Error> {
 | 
					    async fn put(&mut self, directory: proto::Directory) -> Result<(), crate::Error> {
 | 
				
			||||||
        match self.rq {
 | 
					        match self.rq {
 | 
				
			||||||
            // If we're not already closed, send the directory to directory_sender.
 | 
					            // If we're not already closed, send the directory to directory_sender.
 | 
				
			||||||
| 
						 | 
					@ -253,7 +254,8 @@ impl DirectoryPutter for GRPCPutter {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Closes the stream for sending, and returns the value
 | 
					    /// Closes the stream for sending, and returns the value.
 | 
				
			||||||
 | 
					    #[instrument(level = "trace", skip_all, ret, err)]
 | 
				
			||||||
    async fn close(&mut self) -> Result<B3Digest, crate::Error> {
 | 
					    async fn close(&mut self) -> Result<B3Digest, crate::Error> {
 | 
				
			||||||
        // get self.rq, and replace it with None.
 | 
					        // get self.rq, and replace it with None.
 | 
				
			||||||
        // This ensures we can only close it once.
 | 
					        // This ensures we can only close it once.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,7 +9,6 @@ use std::collections::{HashSet, VecDeque};
 | 
				
			||||||
use tonic::async_trait;
 | 
					use tonic::async_trait;
 | 
				
			||||||
use tracing::instrument;
 | 
					use tracing::instrument;
 | 
				
			||||||
use tracing::warn;
 | 
					use tracing::warn;
 | 
				
			||||||
use tracing::Level;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// Traverses a [proto::Directory] from the root to the children.
 | 
					/// Traverses a [proto::Directory] from the root to the children.
 | 
				
			||||||
///
 | 
					///
 | 
				
			||||||
| 
						 | 
					@ -105,7 +104,7 @@ impl<DS: DirectoryService> SimplePutter<DS> {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[async_trait]
 | 
					#[async_trait]
 | 
				
			||||||
impl<DS: DirectoryService + 'static> DirectoryPutter for SimplePutter<DS> {
 | 
					impl<DS: DirectoryService + 'static> DirectoryPutter for SimplePutter<DS> {
 | 
				
			||||||
    #[instrument(skip_all, fields(directory.digest=%directory.digest()), err)]
 | 
					    #[instrument(level = "trace", skip_all, fields(directory.digest=%directory.digest()), err)]
 | 
				
			||||||
    async fn put(&mut self, directory: proto::Directory) -> Result<(), Error> {
 | 
					    async fn put(&mut self, directory: proto::Directory) -> Result<(), Error> {
 | 
				
			||||||
        if self.closed {
 | 
					        if self.closed {
 | 
				
			||||||
            return Err(Error::StorageError("already closed".to_string()));
 | 
					            return Err(Error::StorageError("already closed".to_string()));
 | 
				
			||||||
| 
						 | 
					@ -119,7 +118,7 @@ impl<DS: DirectoryService + 'static> DirectoryPutter for SimplePutter<DS> {
 | 
				
			||||||
        Ok(())
 | 
					        Ok(())
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    #[instrument(skip_all, ret(Display, level=Level::TRACE), err)]
 | 
					    #[instrument(level = "trace", skip_all, ret, err)]
 | 
				
			||||||
    async fn close(&mut self) -> Result<B3Digest, Error> {
 | 
					    async fn close(&mut self) -> Result<B3Digest, Error> {
 | 
				
			||||||
        if self.closed {
 | 
					        if self.closed {
 | 
				
			||||||
            return Err(Error::StorageError("already closed".to_string()));
 | 
					            return Err(Error::StorageError("already closed".to_string()));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue