From e9b3f7c5a4270b6ea1c143b409b50bed38c36eee Mon Sep 17 00:00:00 2001 From: Bernhard Schuster Date: Wed, 9 Feb 2022 17:14:14 +0100 Subject: [PATCH 1/5] reafactor: introduce LOG_TAG --- src/lib.rs | 2 ++ src/pyroscope.rs | 55 +++++++++++++++++++++++++----------------------- 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 0064ad62..4bb1db57 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,6 +24,8 @@ //! agent.stop(); //! ``` +pub(crate) static LOG_TAG: &str = "pyroscope"; + // Re-exports structs pub use crate::pyroscope::PyroscopeAgent; pub use error::{PyroscopeError, Result}; diff --git a/src/pyroscope.rs b/src/pyroscope.rs index 26787ba1..6d756614 100644 --- a/src/pyroscope.rs +++ b/src/pyroscope.rs @@ -7,6 +7,9 @@ use std::{ thread::JoinHandle, }; +// Licensed under the Apache License, Version 2.0 . This file may not be copied, modified, or distributed +// except according to those terms. use crate::{ backends::{pprof::Pprof, Backend}, error::Result, @@ -175,15 +178,15 @@ impl PyroscopeAgentBuilder { // Initiliaze the backend let backend = Arc::clone(&self.backend); backend.lock()?.initialize(self.config.sample_rate)?; - log::trace!("PyroscopeAgent - Backend initialized"); + log::trace!(target: LOG_TAG, "Backend initialized"); // Start Timer let timer = Timer::default().initialize()?; - log::trace!("PyroscopeAgent - Timer initialized"); + log::trace!(target: LOG_TAG, "Timer initialized"); // Start the SessionManager let session_manager = SessionManager::new()?; - log::trace!("PyroscopeAgent - SessionManager initialized"); + log::trace!(target: LOG_TAG, "SessionManager initialized"); // Return PyroscopeAgent Ok(PyroscopeAgent { @@ -217,44 +220,44 @@ pub struct PyroscopeAgent { impl Drop for PyroscopeAgent { /// Properly shutdown the agent. fn drop(&mut self) { - log::debug!("PyroscopeAgent - Dropping Agent"); + log::debug!(target: LOG_TAG, "Dropping Agent"); // Drop Timer listeners match self.timer.drop_listeners() { - Ok(_) => log::trace!("PyroscopeAgent - Dropped timer listeners"), - Err(_) => log::error!("PyroscopeAgent - Error Dropping timer listeners"), + Ok(_) => log::trace!(target: LOG_TAG, "Dropped timer listeners"), + Err(_) => log::error!(target: LOG_TAG, "Error Dropping timer listeners"), } // Wait for the Timer thread to finish if let Some(handle) = self.timer.handle.take() { match handle.join() { - Ok(_) => log::trace!("PyroscopeAgent - Dropped timer thread"), - Err(_) => log::error!("PyroscopeAgent - Error Dropping timer thread"), + Ok(_) => log::trace!(target: LOG_TAG, "Dropped timer thread"), + Err(_) => log::error!(target: LOG_TAG, "Error Dropping timer thread"), } } // Stop the SessionManager match self.session_manager.push(SessionSignal::Kill) { - Ok(_) => log::trace!("PyroscopeAgent - Sent kill signal to SessionManager"), - Err(_) => log::error!("PyroscopeAgent - Error sending kill signal to SessionManager"), + Ok(_) => log::trace!(target: LOG_TAG, "Sent kill signal to SessionManager"), + Err(_) => log::error!(target: LOG_TAG, "Error sending kill signal to SessionManager"), } if let Some(handle) = self.session_manager.handle.take() { match handle.join() { - Ok(_) => log::trace!("PyroscopeAgent - Dropped SessionManager thread"), - Err(_) => log::error!("PyroscopeAgent - Error Dropping SessionManager thread"), + Ok(_) => log::trace!(target: LOG_TAG, "Dropped SessionManager thread"), + Err(_) => log::error!(target: LOG_TAG, "Error Dropping SessionManager thread"), } } // Wait for main thread to finish if let Some(handle) = self.handle.take() { match handle.join() { - Ok(_) => log::trace!("PyroscopeAgent - Dropped main thread"), - Err(_) => log::error!("PyroscopeAgent - Error Dropping main thread"), + Ok(_) => log::trace!(target: LOG_TAG, "Dropped main thread"), + Err(_) => log::error!(target: LOG_TAG, "Error Dropping main thread"), } } - log::debug!("PyroscopeAgent - Agent Dropped"); + log::debug!(target: LOG_TAG, "Agent Dropped"); } } @@ -271,7 +274,7 @@ impl PyroscopeAgent { } fn _start(&mut self) -> Result<()> { - log::debug!("PyroscopeAgent - Starting"); + log::debug!(target: LOG_TAG, "Starting"); // Create a clone of Backend let backend = Arc::clone(&self.backend); @@ -294,10 +297,10 @@ impl PyroscopeAgent { let stx = self.session_manager.tx.clone(); self.handle = Some(std::thread::spawn(move || { - log::trace!("PyroscopeAgent - Main Thread started"); + log::trace!(target: LOG_TAG, "Main Thread started"); while let Ok(until) = rx.recv() { - log::trace!("PyroscopeAgent - Sending session {}", until); + log::trace!(target: LOG_TAG, "Sending session {}", until); // Generate report from backend let report = backend.lock()?.report()?; @@ -310,7 +313,7 @@ impl PyroscopeAgent { )?))?; if until == 0 { - log::trace!("PyroscopeAgent - Session Killed"); + log::trace!(target: LOG_TAG, "Session Killed"); let (lock, cvar) = &*pair; let mut running = lock.lock()?; @@ -334,13 +337,13 @@ impl PyroscopeAgent { /// ``` pub fn start(&mut self) { match self._start() { - Ok(_) => log::trace!("PyroscopeAgent - Agent started"), - Err(_) => log::error!("PyroscopeAgent - Error starting agent"), + Ok(_) => log::trace!(target: LOG_TAG, "Agent started"), + Err(_) => log::error!(target: LOG_TAG, "Error starting agent"), } } fn _stop(&mut self) -> Result<()> { - log::debug!("PyroscopeAgent - Stopping"); + log::debug!(target: LOG_TAG, "Stopping"); // get tx and send termination signal if let Some(sender) = self.tx.take() { sender.send(0)?; @@ -371,8 +374,8 @@ impl PyroscopeAgent { /// ``` pub fn stop(&mut self) { match self._stop() { - Ok(_) => log::trace!("PyroscopeAgent - Agent stopped"), - Err(_) => log::error!("PyroscopeAgent - Error stopping agent"), + Ok(_) => log::trace!(target: LOG_TAG, "Agent stopped"), + Err(_) => log::error!(target: LOG_TAG, "Error stopping agent"), } } @@ -387,7 +390,7 @@ impl PyroscopeAgent { /// agent.stop()?; /// ``` pub fn add_tags(&mut self, tags: &[(&str, &str)]) -> Result<()> { - log::debug!("PyroscopeAgent - Adding tags"); + log::debug!(target: LOG_TAG, "Adding tags"); // Check that tags are not empty if tags.is_empty() { return Ok(()); @@ -430,7 +433,7 @@ impl PyroscopeAgent { /// # } /// ``` pub fn remove_tags(&mut self, tags: &[&str]) -> Result<()> { - log::debug!("PyroscopeAgent - Removing tags"); + log::debug!(target: LOG_TAG, "Removing tags"); // Check that tags are not empty if tags.is_empty() { From 90b09ede84880ee78ac4938958ed14a780f0c73c Mon Sep 17 00:00:00 2001 From: Bernhard Schuster Date: Wed, 23 Feb 2022 15:32:37 +0100 Subject: [PATCH 2/5] split log tags --- src/lib.rs | 2 -- src/pyroscope.rs | 71 +++++++++++++++++++++++------------------------- src/session.rs | 26 ++++++++++++------ 3 files changed, 52 insertions(+), 47 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 4bb1db57..0064ad62 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,8 +24,6 @@ //! agent.stop(); //! ``` -pub(crate) static LOG_TAG: &str = "pyroscope"; - // Re-exports structs pub use crate::pyroscope::PyroscopeAgent; pub use error::{PyroscopeError, Result}; diff --git a/src/pyroscope.rs b/src/pyroscope.rs index 6d756614..6c5cf3aa 100644 --- a/src/pyroscope.rs +++ b/src/pyroscope.rs @@ -17,6 +17,8 @@ use crate::{ timer::Timer, }; +const LOG_TAG: &str = "Pyroscope::Agent"; + /// Pyroscope Agent Configuration. This is the configuration that is passed to the agent. /// # Example /// ``` @@ -178,15 +180,15 @@ impl PyroscopeAgentBuilder { // Initiliaze the backend let backend = Arc::clone(&self.backend); backend.lock()?.initialize(self.config.sample_rate)?; - log::trace!(target: LOG_TAG, "Backend initialized"); + log::trace!(target: LOG_TAG, "Backend initialized"); // Start Timer let timer = Timer::default().initialize()?; - log::trace!(target: LOG_TAG, "Timer initialized"); + log::trace!(target: LOG_TAG, "Timer initialized"); // Start the SessionManager let session_manager = SessionManager::new()?; - log::trace!(target: LOG_TAG, "SessionManager initialized"); + log::trace!(target: LOG_TAG, "SessionManager initialized"); // Return PyroscopeAgent Ok(PyroscopeAgent { @@ -220,41 +222,36 @@ pub struct PyroscopeAgent { impl Drop for PyroscopeAgent { /// Properly shutdown the agent. fn drop(&mut self) { - log::debug!(target: LOG_TAG, "Dropping Agent"); + log::debug!(target: LOG_TAG, "PyroscopeAgent::drop()"); // Drop Timer listeners match self.timer.drop_listeners() { - Ok(_) => log::trace!(target: LOG_TAG, "Dropped timer listeners"), - Err(_) => log::error!(target: LOG_TAG, "Error Dropping timer listeners"), + Ok(_) => log::trace!(target: LOG_TAG, "Dropped timer listeners"), + Err(_) => log::error!(target: LOG_TAG, "Error Dropping timer listeners"), } // Wait for the Timer thread to finish - if let Some(handle) = self.timer.handle.take() { - match handle.join() { - Ok(_) => log::trace!(target: LOG_TAG, "Dropped timer thread"), - Err(_) => log::error!(target: LOG_TAG, "Error Dropping timer thread"), - } + match self.timer.handle.take().unwrap().join() { + Ok(_) => log::trace!(target: LOG_TAG, "Dropped timer thread"), + Err(_) => log::error!(target: LOG_TAG, "Error Dropping timer thread"), } // Stop the SessionManager match self.session_manager.push(SessionSignal::Kill) { - Ok(_) => log::trace!(target: LOG_TAG, "Sent kill signal to SessionManager"), - Err(_) => log::error!(target: LOG_TAG, "Error sending kill signal to SessionManager"), + Ok(_) => log::trace!(target: LOG_TAG, "Sent kill signal to SessionManager"), + Err(_) => log::error!(target: LOG_TAG, "Error sending kill signal to SessionManager"), } - if let Some(handle) = self.session_manager.handle.take() { - match handle.join() { - Ok(_) => log::trace!(target: LOG_TAG, "Dropped SessionManager thread"), - Err(_) => log::error!(target: LOG_TAG, "Error Dropping SessionManager thread"), - } + // Stop SessionManager + match self.session_manager.handle.take().unwrap().join() { + Ok(_) => log::trace!(target: LOG_TAG, "Dropped SessionManager thread"), + Err(_) => log::error!(target: LOG_TAG, "Error Dropping SessionManager thread"), } // Wait for main thread to finish - if let Some(handle) = self.handle.take() { - match handle.join() { - Ok(_) => log::trace!(target: LOG_TAG, "Dropped main thread"), - Err(_) => log::error!(target: LOG_TAG, "Error Dropping main thread"), - } + match self.handle.take().unwrap().join() { + Ok(_) => log::trace!(target: LOG_TAG, "Dropped main thread"), + Err(_) => log::error!(target: LOG_TAG, "Error Dropping main thread"), } log::debug!(target: LOG_TAG, "Agent Dropped"); @@ -274,7 +271,7 @@ impl PyroscopeAgent { } fn _start(&mut self) -> Result<()> { - log::debug!(target: LOG_TAG, "Starting"); + log::debug!(target: LOG_TAG, "Starting"); // Create a clone of Backend let backend = Arc::clone(&self.backend); @@ -297,23 +294,23 @@ impl PyroscopeAgent { let stx = self.session_manager.tx.clone(); self.handle = Some(std::thread::spawn(move || { - log::trace!(target: LOG_TAG, "Main Thread started"); + log::trace!(target: LOG_TAG, "Main Thread started"); - while let Ok(until) = rx.recv() { - log::trace!(target: LOG_TAG, "Sending session {}", until); + while let Ok(time) = rx.recv() { + log::trace!(target: LOG_TAG, "Sending session {}", time); // Generate report from backend let report = backend.lock()?.report()?; // Send new Session to SessionManager stx.send(SessionSignal::Session(Session::new( - until, + time, config.clone(), report, )?))?; - if until == 0 { - log::trace!(target: LOG_TAG, "Session Killed"); + if time == 0 { + log::trace!(target: LOG_TAG, "Session Killed"); let (lock, cvar) = &*pair; let mut running = lock.lock()?; @@ -337,13 +334,13 @@ impl PyroscopeAgent { /// ``` pub fn start(&mut self) { match self._start() { - Ok(_) => log::trace!(target: LOG_TAG, "Agent started"), - Err(_) => log::error!(target: LOG_TAG, "Error starting agent"), + Ok(_) => log::trace!(target: LOG_TAG, "Agent started"), + Err(_) => log::error!(target: LOG_TAG, "Error starting agent"), } } fn _stop(&mut self) -> Result<()> { - log::debug!(target: LOG_TAG, "Stopping"); + log::debug!(target: LOG_TAG, "Stopping"); // get tx and send termination signal if let Some(sender) = self.tx.take() { sender.send(0)?; @@ -374,8 +371,8 @@ impl PyroscopeAgent { /// ``` pub fn stop(&mut self) { match self._stop() { - Ok(_) => log::trace!(target: LOG_TAG, "Agent stopped"), - Err(_) => log::error!(target: LOG_TAG, "Error stopping agent"), + Ok(_) => log::trace!(target: LOG_TAG, "Agent stopped"), + Err(_) => log::error!(target: LOG_TAG, "Error stopping agent"), } } @@ -390,7 +387,7 @@ impl PyroscopeAgent { /// agent.stop()?; /// ``` pub fn add_tags(&mut self, tags: &[(&str, &str)]) -> Result<()> { - log::debug!(target: LOG_TAG, "Adding tags"); + log::debug!(target: LOG_TAG, "Adding tags"); // Check that tags are not empty if tags.is_empty() { return Ok(()); @@ -433,7 +430,7 @@ impl PyroscopeAgent { /// # } /// ``` pub fn remove_tags(&mut self, tags: &[&str]) -> Result<()> { - log::debug!(target: LOG_TAG, "Removing tags"); + log::debug!(target: LOG_TAG, "Removing tags"); // Check that tags are not empty if tags.is_empty() { diff --git a/src/session.rs b/src/session.rs index 9204c8f5..61f961ef 100644 --- a/src/session.rs +++ b/src/session.rs @@ -9,6 +9,8 @@ use crate::utils::get_time_range; use crate::utils::merge_tags_with_app_name; use crate::Result; +const LOG_TAG: &str = "Pyroscope::Session"; + /// Session Signal /// /// This enum is used to send data to the session thread. It can also kill the session thread. @@ -32,15 +34,14 @@ pub struct SessionManager { impl SessionManager { /// Create a new SessionManager pub fn new() -> Result { - log::info!("SessionManager - Creating SessionManager"); + log::info!(target: LOG_TAG, "Creating SessionManager"); // Create a channel for sending and receiving sessions let (tx, rx): (SyncSender, Receiver) = sync_channel(10); // Create a thread for the SessionManager let handle = Some(thread::spawn(move || { - log::trace!("SessionManager - SessionManager thread started"); - // This thread should only return if a kill signal is received. + log::trace!(target: LOG_TAG, "Started"); while let Ok(signal) = rx.recv() { match signal { SessionSignal::Session(session) => { @@ -54,7 +55,7 @@ impl SessionManager { } SessionSignal::Kill => { // Kill the session manager - log::trace!("SessionManager - Kill signal received"); + log::trace!(target: LOG_TAG, "Kill signal received"); return Ok(()); } } @@ -70,7 +71,7 @@ impl SessionManager { // Push the session into the SessionManager self.tx.send(session)?; - log::trace!("SessionManager - SessionSignal pushed"); + log::trace!(target: LOG_TAG, "SessionSignal pushed"); Ok(()) } @@ -96,8 +97,17 @@ impl Session { /// let until = 154065120; /// let session = Session::new(until, config, report)?; /// ``` - pub fn new(until: u64, config: PyroscopeConfig, report: Vec) -> Result { - log::info!("Session - Creating Session"); + pub fn new(mut until: u64, config: PyroscopeConfig, report: Vec) -> Result { + log::info!(target: LOG_TAG, "Creating Session"); + // Session interrupted (0 signal), determine the time + if until == 0 { + let now = std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH)? + .as_secs(); + until = now + .checked_add(10u64.checked_sub(now.checked_rem(10).unwrap()).unwrap()) + .unwrap(); + } // get_time_range should be used with "from". We balance this by reducing // 10s from the returned range. @@ -121,7 +131,7 @@ impl Session { /// session.send()?; /// ``` pub fn send(self) -> Result<()> { - log::info!("Session - Sending Session {} - {}", self.from, self.until); + log::info!(target: LOG_TAG, "Sending Session: {} - {}", self.from, self.until); // Check if the report is empty if self.report.is_empty() { From 19af650708e76fdaf0610b52ffeddf4b0dd8ed0c Mon Sep 17 00:00:00 2001 From: Bernhard Schuster Date: Mon, 28 Feb 2022 13:16:40 +0100 Subject: [PATCH 3/5] undo re-introduced `unwrap()`s --- src/pyroscope.rs | 51 ++++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/src/pyroscope.rs b/src/pyroscope.rs index 6c5cf3aa..db0815db 100644 --- a/src/pyroscope.rs +++ b/src/pyroscope.rs @@ -63,7 +63,7 @@ impl PyroscopeConfig { /// ```ignore /// let mut config = PyroscopeConfig::new("http://localhost:8080", "my-app"); /// config.set_sample_rate(10) - /// .unwrap(); + /// ?; /// ``` pub fn sample_rate(self, sample_rate: i32) -> Self { Self { @@ -77,8 +77,7 @@ impl PyroscopeConfig { /// ```ignore /// use pyroscope::pyroscope::PyroscopeConfig; /// let config = PyroscopeConfig::new("http://localhost:8080", "my-app") - /// .tags(vec![("env", "dev")]) - /// .unwrap(); + /// .tags(vec![("env", "dev")])?; /// ``` pub fn tags(self, tags: &[(&str, &str)]) -> Self { // Convert &[(&str, &str)] to HashMap(String, String) @@ -105,7 +104,7 @@ impl PyroscopeConfig { /// ```ignore /// use pyroscope::pyroscope::PyroscopeAgentBuilder; /// let builder = PyroscopeAgentBuilder::new("http://localhost:8080", "my-app"); -/// let agent = builder.build().unwrap(); +/// let agent = builder.build()?; /// ``` pub struct PyroscopeAgentBuilder { /// Profiler backend @@ -135,7 +134,7 @@ impl PyroscopeAgentBuilder { /// let builder = PyroscopeAgentBuilder::new("http://localhost:8080", "my-app") /// .backend(Pprof::default()) /// .build() - /// .unwrap(); + /// ?; /// ``` pub fn backend(self, backend: T) -> Self where T: 'static + Backend { @@ -151,7 +150,7 @@ impl PyroscopeAgentBuilder { /// let builder = PyroscopeAgentBuilder::new("http://localhost:8080", "my-app") /// .sample_rate(99) /// .build() - /// .unwrap(); + /// ?; /// ``` pub fn sample_rate(self, sample_rate: i32) -> Self { Self { @@ -166,7 +165,7 @@ impl PyroscopeAgentBuilder { /// let builder = PyroscopeAgentBuilder::new("http://localhost:8080", "my-app") /// .tags(vec![("env", "dev")]) /// .build() - /// .unwrap(); + /// ?; /// ``` pub fn tags(self, tags: &[(&str, &str)]) -> Self { Self { @@ -231,9 +230,11 @@ impl Drop for PyroscopeAgent { } // Wait for the Timer thread to finish - match self.timer.handle.take().unwrap().join() { - Ok(_) => log::trace!(target: LOG_TAG, "Dropped timer thread"), - Err(_) => log::error!(target: LOG_TAG, "Error Dropping timer thread"), + if let Some(handle) = self.timer.handle.take() { + match handle.join() { + Ok(_) => log::trace!(target: LOG_TAG, "Dropped timer thread"), + Err(_) => log::error!(target: LOG_TAG, "Error Dropping timer thread"), + } } // Stop the SessionManager @@ -242,16 +243,20 @@ impl Drop for PyroscopeAgent { Err(_) => log::error!(target: LOG_TAG, "Error sending kill signal to SessionManager"), } - // Stop SessionManager - match self.session_manager.handle.take().unwrap().join() { - Ok(_) => log::trace!(target: LOG_TAG, "Dropped SessionManager thread"), - Err(_) => log::error!(target: LOG_TAG, "Error Dropping SessionManager thread"), + if let Some(handle) = self.session_manager.handle.take() { + match handle.join() { + Ok(_) => log::trace!(target: LOG_TAG, "Dropped SessionManager thread"), + Err(_) => log::error!(target: LOG_TAG, "Error Dropping SessionManager thread"), + } } // Wait for main thread to finish - match self.handle.take().unwrap().join() { - Ok(_) => log::trace!(target: LOG_TAG, "Dropped main thread"), - Err(_) => log::error!(target: LOG_TAG, "Error Dropping main thread"), + + if let Some(handle) = self.handle.take() { + match handle.join() { + Ok(_) => log::trace!(target: LOG_TAG, "Dropped main thread"), + Err(_) => log::error!(target: LOG_TAG, "Error Dropping main thread"), + } } log::debug!(target: LOG_TAG, "Agent Dropped"); @@ -263,7 +268,7 @@ impl PyroscopeAgent { /// /// # Example /// ```ignore - /// let agent = PyroscopeAgent::builder("http://localhost:8080", "my-app").build().unwrap(); + /// let agent = PyroscopeAgent::builder("http://localhost:8080", "my-app").build()?; /// ``` pub fn builder>(url: S, application_name: S) -> PyroscopeAgentBuilder { // Build PyroscopeAgent @@ -296,20 +301,20 @@ impl PyroscopeAgent { self.handle = Some(std::thread::spawn(move || { log::trace!(target: LOG_TAG, "Main Thread started"); - while let Ok(time) = rx.recv() { - log::trace!(target: LOG_TAG, "Sending session {}", time); + while let Ok(until) = rx.recv() { + log::trace!(target: LOG_TAG, "Sending session {}", until); // Generate report from backend let report = backend.lock()?.report()?; // Send new Session to SessionManager stx.send(SessionSignal::Session(Session::new( - time, + until, config.clone(), report, )?))?; - if time == 0 { + if until == 0 { log::trace!(target: LOG_TAG, "Session Killed"); let (lock, cvar) = &*pair; @@ -329,7 +334,7 @@ impl PyroscopeAgent { /// Start profiling and sending data. The agent will keep running until stopped. The agent will send data to the server every 10s secondy. /// # Example /// ```ignore - /// let agent = PyroscopeAgent::builder("http://localhost:8080", "my-app").build().unwrap(); + /// let agent = PyroscopeAgent::builder("http://localhost:8080", "my-app").build()?; /// agent.start(); /// ``` pub fn start(&mut self) { From 24287a24d6eef3dbf1b29c71e31c797309063ae1 Mon Sep 17 00:00:00 2001 From: Bernhard Schuster Date: Mon, 28 Feb 2022 13:22:43 +0100 Subject: [PATCH 4/5] cleanup rebase fallout --- src/session.rs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/session.rs b/src/session.rs index 61f961ef..458c3fb7 100644 --- a/src/session.rs +++ b/src/session.rs @@ -97,17 +97,8 @@ impl Session { /// let until = 154065120; /// let session = Session::new(until, config, report)?; /// ``` - pub fn new(mut until: u64, config: PyroscopeConfig, report: Vec) -> Result { + pub fn new(until: u64, config: PyroscopeConfig, report: Vec) -> Result { log::info!(target: LOG_TAG, "Creating Session"); - // Session interrupted (0 signal), determine the time - if until == 0 { - let now = std::time::SystemTime::now() - .duration_since(std::time::UNIX_EPOCH)? - .as_secs(); - until = now - .checked_add(10u64.checked_sub(now.checked_rem(10).unwrap()).unwrap()) - .unwrap(); - } // get_time_range should be used with "from". We balance this by reducing // 10s from the returned range. From c0a64b7b3d3b9a166bf3648ff3c53534a24d68b1 Mon Sep 17 00:00:00 2001 From: Bernhard Schuster Date: Mon, 28 Feb 2022 13:23:59 +0100 Subject: [PATCH 5/5] remove another stray license comment --- src/pyroscope.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/pyroscope.rs b/src/pyroscope.rs index db0815db..bad41c80 100644 --- a/src/pyroscope.rs +++ b/src/pyroscope.rs @@ -7,9 +7,6 @@ use std::{ thread::JoinHandle, }; -// Licensed under the Apache License, Version 2.0 . This file may not be copied, modified, or distributed -// except according to those terms. use crate::{ backends::{pprof::Pprof, Backend}, error::Result,