diff options
author | Ferris Tseng <ferristseng@fastmail.fm> | 2021-02-14 00:31:14 -0500 |
---|---|---|
committer | Ferris Tseng <ferristseng@fastmail.fm> | 2021-02-14 00:31:14 -0500 |
commit | 548304fd69614479790c36ddb0615599df0130b2 (patch) | |
tree | db0534ba6575e9ad897f6554ff41cddfdcc4ca7c /ipfs-api/src | |
parent | 5fe7c4f8bae147db49aaa275fe540b2b4667b3a1 (diff) |
add tracing
Diffstat (limited to 'ipfs-api/src')
-rw-r--r-- | ipfs-api/src/client/internal.rs | 3 | ||||
-rw-r--r-- | ipfs-api/src/read.rs | 6 |
2 files changed, 9 insertions, 0 deletions
diff --git a/ipfs-api/src/client/internal.rs b/ipfs-api/src/client/internal.rs index 94bd490..eb48857 100644 --- a/ipfs-api/src/client/internal.rs +++ b/ipfs-api/src/client/internal.rs @@ -31,6 +31,7 @@ use std::{ path::{Path, PathBuf}, }; use tokio_util::codec::{Decoder, FramedRead}; +use tracing::{event, Level}; const FILE_DESCRIPTOR_LIMIT: usize = 127; @@ -99,6 +100,8 @@ impl IpfsClient { ::serde_urlencoded::to_string(req)? ); + event!(Level::INFO, url = ?url); + #[cfg(feature = "with-hyper")] { url.parse::<Uri>().map_err(From::from).and_then(move |url| { diff --git a/ipfs-api/src/read.rs b/ipfs-api/src/read.rs index bf19157..d17e396 100644 --- a/ipfs-api/src/read.rs +++ b/ipfs-api/src/read.rs @@ -16,6 +16,7 @@ use serde::Deserialize; use std::{cmp, fmt::Display, io, marker::PhantomData, pin::Pin}; use tokio::io::{AsyncRead, ReadBuf}; use tokio_util::codec::Decoder; +use tracing::{event, instrument, Level}; /// A decoder for a response where each line is a full json object. /// @@ -49,10 +50,13 @@ where /// Tries to find a new line character. If it does, it will split the buffer, /// and parse the first slice. /// + #[instrument(skip(self, src), fields(stream_trailer = self.parse_stream_error))] fn decode(&mut self, src: &mut BytesMut) -> Result<Option<Self::Item>, Self::Error> { let nl_index = src.iter().position(|b| *b == b'\n'); if let Some(pos) = nl_index { + event!(Level::INFO, "Found new line delimeter in buffer"); + let slice = src.split_to(pos + 1); let slice = &slice[..slice.len() - 1]; @@ -81,6 +85,8 @@ where } } } else { + event!(Level::INFO, "Waiting for more data to decode JSON"); + Ok(None) } } |