feat(tvix/nix-daemon): instrument for TvixDaemon

This makes it easier to see what's being communicated, by setting
`RUST_LOG=nix_daemon=debug`.

Change-Id: Ifcd89ff6c5c1727e97569e29d4f63993cc37ed8e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12884
Tested-by: BuildkiteCI
Reviewed-by: Vladimir Kryachko <v.kryachko@gmail.com>
Autosubmit: flokli <flokli@flokli.de>
Reviewed-by: flokli <flokli@flokli.de>
This commit is contained in:
Florian Klink 2024-12-09 22:14:08 +02:00 committed by flokli
parent c283116c2e
commit 6068d044b3

View file

@ -11,7 +11,7 @@ use nix_compat::{
nixbase32, nixbase32,
store_path::{build_ca_path, StorePath}, store_path::{build_ca_path, StorePath},
}; };
use tracing::warn; use tracing::{instrument, warn};
use tvix_castore::{blobservice::BlobService, directoryservice::DirectoryService}; use tvix_castore::{blobservice::BlobService, directoryservice::DirectoryService};
use tvix_store::{nar::ingest_nar_and_hash, path_info::PathInfo, pathinfoservice::PathInfoService}; use tvix_store::{nar::ingest_nar_and_hash, path_info::PathInfo, pathinfoservice::PathInfoService};
@ -38,6 +38,7 @@ impl TvixDaemon {
/// Implements [NixDaemonIO] backed by tvix services. /// Implements [NixDaemonIO] backed by tvix services.
impl NixDaemonIO for TvixDaemon { impl NixDaemonIO for TvixDaemon {
#[instrument(skip_all, fields(path), level = "debug", ret(Debug))]
async fn query_path_info( async fn query_path_info(
&self, &self,
path: &StorePath<String>, path: &StorePath<String>,
@ -50,6 +51,7 @@ impl NixDaemonIO for TvixDaemon {
Ok(None) Ok(None)
} }
#[instrument(skip_all, fields(hash=nix_compat::nixbase32::encode(hash)), level = "debug", ret(Debug))]
async fn query_path_from_hash_part(&self, hash: &[u8]) -> Result<Option<UnkeyedValidPathInfo>> { async fn query_path_from_hash_part(&self, hash: &[u8]) -> Result<Option<UnkeyedValidPathInfo>> {
let digest = hash let digest = hash
.try_into() .try_into()
@ -60,6 +62,7 @@ impl NixDaemonIO for TvixDaemon {
} }
} }
#[instrument(skip_all, fields(request), level = "debug", ret(Debug))]
async fn add_to_store_nar<R>(&self, request: AddToStoreNarRequest, reader: &mut R) -> Result<()> async fn add_to_store_nar<R>(&self, request: AddToStoreNarRequest, reader: &mut R) -> Result<()>
where where
R: tokio::io::AsyncRead + Send + Unpin, R: tokio::io::AsyncRead + Send + Unpin,