Skip to content

Commit e95b61b

Browse files
committed
Instrument on:
- async - threaded - par_ - send on channels Missing: - create fn from closures that use above and instrument them for smaller scopes Signed-off-by: simonsan <[email protected]>
1 parent 62aa898 commit e95b61b

File tree

14 files changed

+40
-0
lines changed

14 files changed

+40
-0
lines changed

crates/backend/src/opendal.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ impl ReadBackend for OpenDALBackend {
235235

236236
impl WriteBackend for OpenDALBackend {
237237
/// Create a repository on the backend.
238+
#[tracing::instrument(skip(self))]
238239
fn create(&self) -> Result<()> {
239240
trace!("creating repo at {:?}", self.location());
240241

crates/backend/src/rclone.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ impl RcloneBackend {
127127
///
128128
/// If the rclone command is not found.
129129
// TODO: This should be an error, not a panic.
130+
#[tracing::instrument(skip(url))]
130131
pub fn new(url: impl AsRef<str>, options: HashMap<String, String>) -> Result<Self> {
131132
let rclone_command = options.get("rclone-command");
132133
let use_password = options

crates/backend/src/rest.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ impl ReadBackend for RestBackend {
245245
/// A vector of tuples containing the id and size of the files.
246246
///
247247
/// [`RestErrorKind::JoiningUrlFailed`]: RestErrorKind::JoiningUrlFailed
248+
#[tracing::instrument(skip(self))]
248249
fn list_with_size(&self, tpe: FileType) -> Result<Vec<(Id, u32)>> {
249250
// format which is delivered by the REST-service
250251
#[derive(Deserialize)]
@@ -313,6 +314,7 @@ impl ReadBackend for RestBackend {
313314
/// * [`RestErrorKind::BackoffError`] - If the backoff failed.
314315
///
315316
/// [`RestErrorKind::BackoffError`]: RestErrorKind::BackoffError
317+
#[tracing::instrument(skip(self))]
316318
fn read_full(&self, tpe: FileType, id: &Id) -> Result<Bytes> {
317319
trace!("reading tpe: {tpe:?}, id: {id}");
318320
let url = self.url(tpe, id)?;
@@ -346,6 +348,7 @@ impl ReadBackend for RestBackend {
346348
/// * [`RestErrorKind::BackoffError`] - If the backoff failed.
347349
///
348350
/// [`RestErrorKind::BackoffError`]: RestErrorKind::BackoffError
351+
#[tracing::instrument(skip(self, _cacheable))]
349352
fn read_partial(
350353
&self,
351354
tpe: FileType,
@@ -383,6 +386,7 @@ impl WriteBackend for RestBackend {
383386
/// * [`RestErrorKind::BackoffError`] - If the backoff failed.
384387
///
385388
/// [`RestErrorKind::BackoffError`]: RestErrorKind::BackoffError
389+
#[tracing::instrument(skip(self))]
386390
fn create(&self) -> Result<()> {
387391
let url = self
388392
.url
@@ -413,6 +417,7 @@ impl WriteBackend for RestBackend {
413417
/// * [`RestErrorKind::BackoffError`] - If the backoff failed.
414418
///
415419
/// [`RestErrorKind::BackoffError`]: RestErrorKind::BackoffError
420+
#[tracing::instrument(skip(self, _cacheable))]
416421
fn write_bytes(&self, tpe: FileType, id: &Id, _cacheable: bool, buf: Bytes) -> Result<()> {
417422
trace!("writing tpe: {:?}, id: {}", &tpe, &id);
418423
let req_builder = self.client.post(self.url(tpe, id)?).body(buf);
@@ -441,6 +446,7 @@ impl WriteBackend for RestBackend {
441446
/// * [`RestErrorKind::BackoffError`] - If the backoff failed.
442447
///
443448
/// [`RestErrorKind::BackoffError`]: RestErrorKind::BackoffError
449+
#[tracing::instrument(skip(self, _cacheable))]
444450
fn remove(&self, tpe: FileType, id: &Id, _cacheable: bool) -> Result<()> {
445451
trace!("removing tpe: {:?}, id: {}", &tpe, &id);
446452
let url = self.url(tpe, id)?;

crates/core/src/archiver.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ impl<'a, BE: DecryptFullBackend, I: ReadGlobalIndex> Archiver<'a, BE, I> {
121121
/// [`PackerErrorKind::SendingCrossbeamMessageFailed`]: crate::error::PackerErrorKind::SendingCrossbeamMessageFailed
122122
/// [`CryptBackendErrorKind::SerializingToJsonByteVectorFailed`]: crate::error::CryptBackendErrorKind::SerializingToJsonByteVectorFailed
123123
/// [`SnapshotFileErrorKind::OutOfRange`]: crate::error::SnapshotFileErrorKind::OutOfRange
124+
#[tracing::instrument(skip(self, src, p))]
124125
pub fn archive<R>(
125126
mut self,
126127
src: &R,

crates/core/src/backend/decrypt.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ pub trait DecryptReadBackend: ReadBackend + Clone + 'static {
161161
/// # Errors
162162
///
163163
/// If the files could not be read.
164+
#[tracing::instrument(skip(self, p))]
164165
fn stream_list<F: RepoFile>(&self, list: &[Id], p: &impl Progress) -> StreamResult<F::Id, F> {
165166
p.set_length(list.len() as u64);
166167
let (tx, rx) = unbounded();
@@ -279,6 +280,7 @@ pub trait DecryptWriteBackend: WriteBackend + Clone + 'static {
279280
/// # Errors
280281
///
281282
/// * [`CryptBackendErrorKind::SerializingToJsonByteVectorFailed`] - If the file could not be serialized to json.
283+
#[tracing::instrument(skip(self, list, p))]
282284
fn save_list<'a, F: RepoFile, I: ExactSizeIterator<Item = &'a F> + Send>(
283285
&self,
284286
list: I,
@@ -306,6 +308,7 @@ pub trait DecryptWriteBackend: WriteBackend + Clone + 'static {
306308
/// # Panics
307309
///
308310
/// If the files could not be deleted.
311+
#[tracing::instrument(skip(self, list, p))]
309312
fn delete_list<'a, ID: RepoId, I: ExactSizeIterator<Item = &'a ID> + Send>(
310313
&self,
311314
cacheable: bool,

crates/core/src/blob/packer.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ impl<BE: DecryptWriteBackend> Packer<BE> {
194194
/// [`PackerErrorKind::SendingCrossbeamMessageFailed`]: crate::error::PackerErrorKind::SendingCrossbeamMessageFailed
195195
/// [`PackerErrorKind::IntConversionFailed`]: crate::error::PackerErrorKind::IntConversionFailed
196196
#[allow(clippy::unnecessary_wraps)]
197+
#[tracing::instrument(skip(be, indexer))]
197198
pub fn new(
198199
be: BE,
199200
blob_type: BlobType,
@@ -295,6 +296,7 @@ impl<BE: DecryptWriteBackend> Packer<BE> {
295296
/// * [`PackerErrorKind::SendingCrossbeamMessageFailed`] - If sending the message to the raw packer fails.
296297
///
297298
/// [`PackerErrorKind::SendingCrossbeamMessageFailed`]: crate::error::PackerErrorKind::SendingCrossbeamMessageFailed
299+
#[tracing::instrument(skip(self))]
298300
fn add_with_sizelimit(
299301
&self,
300302
data: Bytes,
@@ -602,6 +604,7 @@ impl<BE: DecryptWriteBackend> RawPacker<BE> {
602604
///
603605
/// [`PackerErrorKind::IntConversionFailed`]: crate::error::PackerErrorKind::IntConversionFailed
604606
/// [`PackFileErrorKind::WritingBinaryRepresentationFailed`]: crate::error::PackFileErrorKind::WritingBinaryRepresentationFailed
607+
#[tracing::instrument(skip(self))]
605608
fn save(&mut self) -> RusticResult<()> {
606609
if self.size == 0 {
607610
return Ok(());
@@ -677,6 +680,7 @@ impl Actor {
677680
/// * `fwh` - The file writer handle.
678681
/// * `queue_len` - The length of the queue.
679682
/// * `par` - The number of parallel threads.
683+
#[tracing::instrument(skip(fwh, _par))]
680684
fn new<BE: DecryptWriteBackend>(
681685
fwh: FileWriterHandle<BE>,
682686
queue_len: usize,
@@ -718,6 +722,7 @@ impl Actor {
718722
/// # Errors
719723
///
720724
/// If sending the message to the actor fails.
725+
#[tracing::instrument(skip(self))]
721726
fn send(&self, load: (Bytes, IndexPack)) -> RusticResult<()> {
722727
self.sender
723728
.send(load)

crates/core/src/blob/tree.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,7 @@ impl<P: Progress> TreeStreamerOnce<P> {
671671
/// * [`TreeErrorKind::SendingCrossbeamMessageFailed`] - If sending the message fails.
672672
///
673673
/// [`TreeErrorKind::SendingCrossbeamMessageFailed`]: crate::error::TreeErrorKind::SendingCrossbeamMessageFailed
674+
#[tracing::instrument(skip(be, index, p))]
674675
pub fn new<BE: DecryptReadBackend, I: ReadGlobalIndex>(
675676
be: &BE,
676677
index: &I,
@@ -733,6 +734,7 @@ impl<P: Progress> TreeStreamerOnce<P> {
733734
/// * [`TreeErrorKind::SendingCrossbeamMessageFailed`] - If sending the message fails.
734735
///
735736
/// [`TreeErrorKind::SendingCrossbeamMessageFailed`]: crate::error::TreeErrorKind::SendingCrossbeamMessageFailed
737+
#[tracing::instrument(skip(self))]
736738
fn add_pending(&mut self, path: PathBuf, id: TreeId, count: usize) -> RusticResult<bool> {
737739
if self.visited.insert(id) {
738740
self.queue_in

crates/core/src/commands/check.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ pub struct CheckOptions {
202202
/// # Panics
203203
///
204204
// TODO: Add panics
205+
#[tracing::instrument(skip(repo))]
205206
pub(crate) fn check_repository<P: ProgressBars, S: Open>(
206207
repo: &Repository<P, S>,
207208
opts: CheckOptions,
@@ -350,6 +351,7 @@ fn check_hot_files(
350351
/// # Errors
351352
///
352353
/// If a file is missing or has a different size
354+
#[tracing::instrument(skip(be, p, _concurrency))]
353355
fn check_cache_files(
354356
_concurrency: usize,
355357
cache: &Cache,

crates/core/src/commands/copy.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ pub struct CopySnapshot {
4141
/// # Errors
4242
///
4343
// TODO: Document errors
44+
#[tracing::instrument(skip(repo, repo_dest, snapshots))]
4445
pub(crate) fn copy<'a, Q, R: IndexedFull, P: ProgressBars, S: IndexedIds>(
4546
repo: &Repository<Q, R>,
4647
repo_dest: &Repository<P, S>,

crates/core/src/commands/prune.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,6 +1182,7 @@ impl PrunePlan {
11821182
/// TODO! In weird circumstances, should be fixed.
11831183
#[allow(clippy::significant_drop_tightening)]
11841184
#[allow(clippy::too_many_lines)]
1185+
#[tracing::instrument(skip(repo))]
11851186
pub(crate) fn prune_repository<P: ProgressBars, S: Open>(
11861187
repo: &Repository<P, S>,
11871188
opts: &PruneOptions,

crates/core/src/commands/restore.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ pub(crate) fn set_metadata(
430430
/// [`CommandErrorKind::ErrorSettingLength`]: crate::error::CommandErrorKind::ErrorSettingLength
431431
/// [`CommandErrorKind::FromRayonError`]: crate::error::CommandErrorKind::FromRayonError
432432
#[allow(clippy::too_many_lines)]
433+
#[tracing::instrument(skip(repo))]
433434
fn restore_contents<P: ProgressBars, S: Open>(
434435
repo: &Repository<P, S>,
435436
dest: &LocalDestination,

crates/core/src/index/binarysorted.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ impl IndexCollector {
120120
}
121121

122122
// Turns Collector into an index by sorting the entries by ID.
123+
#[tracing::instrument(skip(self))]
123124
#[must_use]
124125
pub fn into_index(self) -> Index {
125126
Index(self.0.map(|_, mut tc| {
@@ -223,6 +224,7 @@ impl IntoIterator for Index {
223224
type IntoIter = PackIndexes;
224225

225226
// Turns Collector into an iterator yielding PackIndex by sorting the entries by pack.
227+
#[tracing::instrument(skip(self))]
226228
fn into_iter(mut self) -> Self::IntoIter {
227229
for tc in self.0.values_mut() {
228230
if let EntriesVariants::FullEntries(entries) = &mut tc.entries {

crates/core/src/repository/warm_up.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ fn warm_up_command<P: ProgressBars>(
119119
/// * [`RepositoryErrorKind::FromThreadPoolbilderError`] - If the thread pool could not be created.
120120
///
121121
/// [`RepositoryErrorKind::FromThreadPoolbilderError`]: crate::error::RepositoryErrorKind::FromThreadPoolbilderError
122+
#[tracing::instrument(skip(repo, packs))]
122123
fn warm_up_repo<P: ProgressBars, S>(
123124
repo: &Repository<P, S>,
124125
packs: impl ExactSizeIterator<Item = PackId>,

crates/core/src/vfs/webdavfs.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,12 @@ impl<P, S: IndexedFull> Clone for WebDavFS<P, S> {
132132
impl<P: Debug + Send + Sync + 'static, S: IndexedFull + Debug + Send + Sync + 'static> DavFileSystem
133133
for WebDavFS<P, S>
134134
{
135+
#[tracing::instrument(skip(self))]
135136
fn metadata<'a>(&'a self, davpath: &'a DavPath) -> FsFuture<'_, Box<dyn DavMetaData>> {
136137
self.symlink_metadata(davpath)
137138
}
138139

140+
#[tracing::instrument(skip(self))]
139141
fn symlink_metadata<'a>(&'a self, davpath: &'a DavPath) -> FsFuture<'_, Box<dyn DavMetaData>> {
140142
async move {
141143
let node = self.node_from_path(davpath)?;
@@ -145,6 +147,7 @@ impl<P: Debug + Send + Sync + 'static, S: IndexedFull + Debug + Send + Sync + 's
145147
.boxed()
146148
}
147149

150+
#[tracing::instrument(skip(self, _meta))]
148151
fn read_dir<'a>(
149152
&'a self,
150153
davpath: &'a DavPath,
@@ -162,6 +165,7 @@ impl<P: Debug + Send + Sync + 'static, S: IndexedFull + Debug + Send + Sync + 's
162165
.boxed()
163166
}
164167

168+
#[tracing::instrument(skip(self))]
165169
fn open<'a>(
166170
&'a self,
167171
path: &'a DavPath,
@@ -204,6 +208,7 @@ impl<P: Debug + Send + Sync + 'static, S: IndexedFull + Debug + Send + Sync + 's
204208
struct DavFsDirEntry(Node);
205209

206210
impl DavDirEntry for DavFsDirEntry {
211+
#[tracing::instrument(skip(self))]
207212
fn metadata(&self) -> FsFuture<'_, Box<dyn DavMetaData>> {
208213
async move {
209214
let meta: Box<dyn DavMetaData> = Box::new(DavFsMetaData(self.0.clone()));
@@ -213,11 +218,13 @@ impl DavDirEntry for DavFsDirEntry {
213218
}
214219

215220
#[cfg(not(windows))]
221+
#[tracing::instrument(skip(self))]
216222
fn name(&self) -> Vec<u8> {
217223
self.0.name().as_bytes().to_vec()
218224
}
219225

220226
#[cfg(windows)]
227+
#[tracing::instrument(skip(self))]
221228
fn name(&self) -> Vec<u8> {
222229
self.0
223230
.name()
@@ -252,6 +259,7 @@ impl<P, S> Debug for DavFsFile<P, S> {
252259
}
253260

254261
impl<P: Debug + Send + Sync, S: IndexedFull + Debug + Send + Sync> DavFile for DavFsFile<P, S> {
262+
#[tracing::instrument(skip(self))]
255263
fn metadata(&mut self) -> FsFuture<'_, Box<dyn DavMetaData>> {
256264
async move {
257265
let meta: Box<dyn DavMetaData> = Box::new(DavFsMetaData(self.node.clone()));
@@ -260,14 +268,17 @@ impl<P: Debug + Send + Sync, S: IndexedFull + Debug + Send + Sync> DavFile for D
260268
.boxed()
261269
}
262270

271+
#[tracing::instrument(skip(self, _buf))]
263272
fn write_bytes(&mut self, _buf: Bytes) -> FsFuture<'_, ()> {
264273
async move { Err(FsError::Forbidden) }.boxed()
265274
}
266275

276+
#[tracing::instrument(skip(self, _buf))]
267277
fn write_buf(&mut self, _buf: Box<dyn Buf + Send>) -> FsFuture<'_, ()> {
268278
async move { Err(FsError::Forbidden) }.boxed()
269279
}
270280

281+
#[tracing::instrument(skip(self))]
271282
fn read_bytes(&mut self, count: usize) -> FsFuture<'_, Bytes> {
272283
async move {
273284
let data = self
@@ -281,6 +292,7 @@ impl<P: Debug + Send + Sync, S: IndexedFull + Debug + Send + Sync> DavFile for D
281292
.boxed()
282293
}
283294

295+
#[tracing::instrument(skip(self))]
284296
fn seek(&mut self, pos: SeekFrom) -> FsFuture<'_, u64> {
285297
async move {
286298
match pos {
@@ -306,6 +318,7 @@ impl<P: Debug + Send + Sync, S: IndexedFull + Debug + Send + Sync> DavFile for D
306318
.boxed()
307319
}
308320

321+
#[tracing::instrument(skip(self))]
309322
fn flush(&mut self) -> FsFuture<'_, ()> {
310323
async move { Ok(()) }.boxed()
311324
}

0 commit comments

Comments
 (0)