Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make instrumentation only on trace #4765

Merged
merged 1 commit into from
Oct 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/event/log_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@ pub struct LogEvent {
}

impl LogEvent {
#[instrument(skip(self, key), fields(key = %key.as_ref()))]
#[instrument(level = "trace", skip(self, key), fields(key = %key.as_ref()))]
pub fn get(&self, key: impl AsRef<str>) -> Option<&Value> {
util::log::get(&self.fields, key.as_ref())
}

#[instrument(skip(self, key), fields(key = %key.as_ref()))]
#[instrument(level = "trace", skip(self, key), fields(key = %key.as_ref()))]
pub fn get_flat(&self, key: impl AsRef<str>) -> Option<&Value> {
self.fields.get(key.as_ref())
}

#[instrument(skip(self, key), fields(key = %key.as_ref()))]
#[instrument(level = "trace", skip(self, key), fields(key = %key.as_ref()))]
pub fn get_mut(&mut self, key: impl AsRef<str>) -> Option<&mut Value> {
util::log::get_mut(&mut self.fields, key.as_ref())
}

#[instrument(skip(self, key), fields(key = %key.as_ref()))]
#[instrument(level = "trace", skip(self, key), fields(key = %key.as_ref()))]
pub fn contains(&self, key: impl AsRef<str>) -> bool {
util::log::contains(&self.fields, key.as_ref())
}

#[instrument(skip(self, key), fields(key = %key.as_ref()))]
#[instrument(level = "trace", skip(self, key), fields(key = %key.as_ref()))]
pub fn insert(
&mut self,
key: impl AsRef<str>,
Expand All @@ -42,15 +42,15 @@ impl LogEvent {
util::log::insert(&mut self.fields, key.as_ref(), value.into())
}

#[instrument(skip(self, key), fields(key = ?key))]
#[instrument(level = "trace", skip(self, key), fields(key = ?key))]
pub fn insert_path<V>(&mut self, key: Vec<PathComponent>, value: V) -> Option<Value>
where
V: Into<Value> + Debug,
{
util::log::insert_path(&mut self.fields, key, value.into())
}

#[instrument(skip(self, key), fields(key = %key))]
#[instrument(level = "trace", skip(self, key), fields(key = %key))]
pub fn insert_flat<K, V>(&mut self, key: K, value: V)
where
K: Into<String> + Display,
Expand All @@ -59,40 +59,40 @@ impl LogEvent {
self.fields.insert(key.into(), value.into());
}

#[instrument(skip(self, key), fields(key = %key.as_ref()))]
#[instrument(level = "trace", skip(self, key), fields(key = %key.as_ref()))]
pub fn try_insert(&mut self, key: impl AsRef<str>, value: impl Into<Value> + Debug) {
let key = key.as_ref();
if !self.contains(key) {
self.insert(key, value);
}
}

#[instrument(skip(self, key), fields(key = %key.as_ref()))]
#[instrument(level = "trace", skip(self, key), fields(key = %key.as_ref()))]
pub fn remove(&mut self, key: impl AsRef<str>) -> Option<Value> {
util::log::remove(&mut self.fields, key.as_ref(), false)
}

#[instrument(skip(self, key), fields(key = %key.as_ref()))]
#[instrument(level = "trace", skip(self, key), fields(key = %key.as_ref()))]
pub fn remove_prune(&mut self, key: impl AsRef<str>, prune: bool) -> Option<Value> {
util::log::remove(&mut self.fields, key.as_ref(), prune)
}

#[instrument(skip(self))]
#[instrument(level = "trace", skip(self))]
pub fn keys<'a>(&'a self) -> impl Iterator<Item = String> + 'a {
util::log::keys(&self.fields)
}

#[instrument(skip(self))]
#[instrument(level = "trace", skip(self))]
pub fn all_fields(&self) -> impl Iterator<Item = (String, &Value)> + Serialize {
util::log::all_fields(&self.fields)
}

#[instrument(skip(self))]
#[instrument(level = "trace", skip(self))]
pub fn is_empty(&self) -> bool {
self.fields.is_empty()
}

#[instrument(skip(self, lookup), fields(lookup = %lookup), err)]
#[instrument(level = "trace", skip(self, lookup), fields(lookup = %lookup), err)]
fn entry(&mut self, lookup: Lookup) -> crate::Result<Entry<String, Value>> {
trace!("Seeking to entry.");
let mut walker = lookup.into_iter().enumerate();
Expand Down
14 changes: 7 additions & 7 deletions src/event/lookup/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,24 +90,24 @@ impl Display for Lookup {

impl Lookup {
/// Push onto the internal list of segments.
#[instrument]
#[instrument(level = "trace")]
pub fn push(&mut self, segment: Segment) {
trace!(length = %self.segments.len(), "Pushing.");
self.segments.push(segment)
}

#[instrument]
#[instrument(level = "trace")]
pub fn pop(&mut self) -> Option<Segment> {
trace!(length = %self.segments.len(), "Popping.");
self.segments.pop()
}

#[instrument]
#[instrument(level = "trace")]
pub fn iter(&self) -> Iter<'_, Segment> {
self.segments.iter()
}

#[instrument]
#[instrument(level = "trace")]
pub fn from_indexmap(
values: IndexMap<String, TomlValue>,
) -> crate::Result<IndexMap<Lookup, Value>> {
Expand All @@ -118,7 +118,7 @@ impl Lookup {
Ok(discoveries)
}

#[instrument]
#[instrument(level = "trace")]
pub fn from_toml_table(value: TomlValue) -> crate::Result<IndexMap<Lookup, Value>> {
let mut discoveries = IndexMap::new();
match value {
Expand All @@ -136,7 +136,7 @@ impl Lookup {
}
}

#[instrument]
#[instrument(level = "trace")]
fn recursive_step(
lookup: Lookup,
value: TomlValue,
Expand Down Expand Up @@ -170,7 +170,7 @@ impl Lookup {
}

/// Raise any errors that might stem from the lookup being invalid.
#[instrument]
#[instrument(level = "trace")]
fn is_valid(&self) -> crate::Result<()> {
if self.segments.is_empty() {
return Err("Lookups must have at least 1 segment to be valid.".into());
Expand Down