Skip to content

Commit

Permalink
Cosmetic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelff committed Jan 27, 2023
1 parent 74f255a commit cbae551
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
4 changes: 2 additions & 2 deletions query-engine/core/src/telemetry/capturing/capturer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl Processor {
}
}

pub(self) async fn start_capturing(&self, trace_id: TraceId, settings: Settings) {
async fn start_capturing(&self, trace_id: TraceId, settings: Settings) {
let mut locked_storage = self.storage.lock().unwrap();
locked_storage.insert(trace_id, settings.clone().into());
drop(locked_storage);
Expand All @@ -81,7 +81,7 @@ impl Processor {
});
}

pub(self) async fn fetch_captures(&self, trace_id: TraceId) -> Option<Storage> {
async fn fetch_captures(&self, trace_id: TraceId) -> Option<Storage> {
let mut traces = self.storage.lock().unwrap();

traces.remove(&trace_id)
Expand Down
29 changes: 13 additions & 16 deletions query-engine/core/src/telemetry/capturing/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ static DEFAULT_TTL: time::Duration = time::Duration::from_secs(1800); // 30 minu

#[derive(Debug, Clone, Default)]
pub struct Settings {
// only capture log events from the specified log levels, the special level "query", which does not
// exist in the engine logging infrastructure, is shimed from any event describing a query, regardless
// of its level.
/// only capture log events from the specified log levels, the special level "query", which does not
/// exist in the engine logging infrastructure, is shimed from any event describing a query, regardless
/// of its level.
pub(super) included_log_levels: HashSet<String>,
// whether to include trace spans when capturing
/// whether to include trace spans when capturing
pub(super) include_traces: bool,
// how long to keep captured traces in memory, if by any chance the capturing breaks, a tokio task
// will clean captured traces after this duration. Defaults to [`DEFAULT_TTL`].
/// how long to keep captured traces in memory, if by any chance the capturing breaks, a tokio task
/// will clean captured traces after this duration. Defaults to [`DEFAULT_TTL`].
pub(super) ttl: time::Duration,
}

Expand All @@ -26,13 +26,13 @@ impl Settings {
}
}

// As the test below shows, settings can be constructed froma comma separated string.
// Examples: valid: `"error, warn, query, tracing"` invalid: "foo, bar baz". strings corresponding
// passed in are trimmed and converted to lowercase. chunks corresponding to levels different from
// those in VALID_LEVELS are ignored.
//
// The ttl is always the same (DEFAULT_TTL) but is there to allow for easier unit-testing of c
// apturing logic
/// As the test below shows, settings can be constructed from a comma separated string.
/// Examples: valid: `"error, warn, query, tracing"` invalid: "foo, bar baz". strings corresponding
/// passed in are trimmed and converted to lowercase. chunks corresponding to levels different from
/// those in VALID_LEVELS are ignored.
///
/// The ttl is always the same (DEFAULT_TTL) but is there to allow for easier unit-testing of c
/// apturing logic
impl From<&str> for Settings {
fn from(s: &str) -> Self {
let chunks = s.split(',');
Expand All @@ -52,17 +52,14 @@ impl From<&str> for Settings {
}

impl Settings {
#[inline(always)]
pub fn is_enabled(&self) -> bool {
self.traces_enabled() || self.logs_enabled()
}

#[inline(always)]
pub fn traces_enabled(&self) -> bool {
self.include_traces
}

#[inline(always)]
pub fn logs_enabled(&self) -> bool {
!self.included_log_levels.is_empty()
}
Expand Down

0 comments on commit cbae551

Please sign in to comment.