diff --git a/freva/src/drs/ingest.rs b/freva/src/drs/ingest.rs index e284a65a34301d683849c85e214cfd3c6d794cdc..73d957ab1d4c1ade35c7a53bdae9cbeaa146f248 100644 --- a/freva/src/drs/ingest.rs +++ b/freva/src/drs/ingest.rs @@ -9,7 +9,7 @@ use camino::Utf8PathBuf; use thiserror::Error; use tokio::sync::mpsc::{channel, Receiver}; use tokio::time::Instant; -use tracing::{error, info, trace, warn}; +use tracing::{error, info, instrument, trace, warn}; use walkdir::{DirEntry, WalkDir}; use crate::drs::Structure; @@ -56,8 +56,8 @@ pub struct StructureReport { /// One task is the computation thread which processes the file names as they come in and it spawns the second task /// which is a blocking thread that uses `walkdir` synchronously and feeds the paths it finds into a channel. /// -/// `files_collection` and `latest_collection` are optional. If `None`, then this will use Freva's defaults: `"files"` -/// and `"latest"`, respectively. +/// `files_collection` and `latest_collection` are optional. If `None`, then this will use Freva's defaults: +/// [`DEFAULT_FILES_COLLECTION`] and [`DEFAULT_LATEST_COLLECTION`], respectively. pub async fn ingest<P: AsRef<Path>>( solr: &Solr, drs_conf: &Config, @@ -126,6 +126,7 @@ pub async fn ingest<P: AsRef<Path>>( /// /// Invalid files, whatever the reason they're invalid, will be skipped. Failing to send to solr will result in this /// ending early with an error. Any files that were already sent to solr will not be cleaned up. +#[instrument(skip(solr, structure), fields(structure = structure.activity().as_str()))] async fn ingest_structure( solr: Solr, structure: Structure, diff --git a/freva/src/drs/metadata.rs b/freva/src/drs/metadata.rs index 1f52ad94f4841aa9b0a11e2a03753d80ef90689c..359b7d4ac0410d379a956783b9871a493e4aa78d 100644 --- a/freva/src/drs/metadata.rs +++ b/freva/src/drs/metadata.rs @@ -50,6 +50,14 @@ pub enum Error { #[derive(Debug, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash, Clone)] pub struct Activity(pub String); +impl Activity { + /// Gets the Activity as a string. Convenience method for accessing its value as a string without using tuple + /// syntax. + pub fn as_str(&self) -> &str { + &self.0 + } +} + impl Display for Activity { fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), std::fmt::Error> { write!(f, "{}", self.0) diff --git a/freva/src/lib.rs b/freva/src/lib.rs index 723f852b0efffb3b67ed9d2f5b26b6a20ff5a676..77ed2e23235ac6f2a8639019546441ec16a68d67 100644 --- a/freva/src/lib.rs +++ b/freva/src/lib.rs @@ -4,5 +4,7 @@ pub mod drs; pub mod solr; -const DEFAULT_FILES_COLLECTION: &str = "files"; -const DEFAULT_LATEST_COLLECTION: &str = "latest"; +/// Default collection name in Solr for all files +pub const DEFAULT_FILES_COLLECTION: &str = "files"; +/// Default collection name in Solr for the latest versions of all versioned files +pub const DEFAULT_LATEST_COLLECTION: &str = "latest";