Skip to content
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
6 changes: 2 additions & 4 deletions src/backends/pprof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,15 @@ where
}

for (index, frame) in key.frames.iter().rev().enumerate() {
let last_frame = key.frames.len().saturating_sub(1);
for (index, symbol) in frame.iter().rev().enumerate() {
let last_symbol = frame.len().saturating_sub(1);
if index == last_symbol {
if index + 1 == frame.len() {
write!(writer, "{}", symbol)?;
} else {
write!(writer, "{};", symbol)?;
}
}

if index != last_frame {
if index + 1 != key.frames.len() {
write!(writer, ";")?;
}
}
Expand Down
34 changes: 22 additions & 12 deletions src/pyroscope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,11 @@ impl PyroscopeAgent {
fn _stop(&mut self) -> Result<()> {
log::debug!("PyroscopeAgent - Stopping");
// get tx and send termination signal
self.tx.take().unwrap().send(0)?;
if let Some(sender) = self.tx.take() {
sender.send(0)?;
} else {
log::error!("PyroscopeAgent - Missing sender")
}

// Wait for the Thread to finish
let pair = Arc::clone(&self.running);
Expand All @@ -362,11 +366,11 @@ impl PyroscopeAgent {
/// Stop the agent. The agent will stop profiling and send a last report to the server.
/// # Example
/// ```ignore
/// let agent = PyroscopeAgent::builder("http://localhost:8080", "my-app").build().unwrap();
/// agent.start();
/// let agent = PyroscopeAgent::builder("http://localhost:8080", "my-app").build()?;
/// agent.start()?;
/// // Expensive operation
/// agent.stop();
/// ```
/// ```
pub fn stop(&mut self) {
match self._stop() {
Ok(_) => log::trace!("PyroscopeAgent - Agent stopped"),
Expand All @@ -377,12 +381,12 @@ impl PyroscopeAgent {
/// Add tags. This will restart the agent.
/// # Example
/// ```ignore
/// let agent = PyroscopeAgent::builder("http://localhost:8080", "my-app").build().unwrap();
/// agent.start();
/// let agent = PyroscopeAgent::builder("http://localhost:8080", "my-app").build()?;
/// agent.start()?;
/// // Expensive operation
/// agent.add_tags(vec![("tag", "value")]).unwrap();
/// agent.add_tags(vec!["tag", "value"])?;
/// // Tagged operation
/// agent.stop();
/// agent.stop()?;
/// ```
pub fn add_tags(&mut self, tags: &[(&str, &str)]) -> Result<()> {
log::debug!("PyroscopeAgent - Adding tags");
Expand Down Expand Up @@ -413,14 +417,20 @@ impl PyroscopeAgent {
/// Remove tags. This will restart the agent.
/// # Example
/// ```ignore
/// # use pyroscope::*;
/// # use std::result;
/// # fn main() -> result::Result<(), error::PyroscopeError> {
/// let agent = PyroscopeAgent::builder("http://localhost:8080", "my-app")
/// .tags(vec![("tag", "value")])
/// .build().unwrap();
/// agent.start();
/// .build()?;
/// agent.start()?;
/// // Expensive operation
/// agent.remove_tags(vec!["tag"]).unwrap();
/// agent.remove_tags(vec!["tag"])?;
/// // Un-Tagged operation
/// agent.stop();
/// agent.stop()?;
/// # Ok(())
/// # }
/// ```
pub fn remove_tags(&mut self, tags: &[&str]) -> Result<()> {
log::debug!("PyroscopeAgent - Removing tags");

Expand Down
6 changes: 3 additions & 3 deletions src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl Session {
/// let config = PyroscopeConfig::new("https://localhost:8080", "my-app");
/// let report = vec![1, 2, 3];
/// let until = 154065120;
/// let session = Session::new(until, config, report).unwrap();
/// let session = Session::new(until, config, report)?;
/// ```
pub fn new(until: u64, config: PyroscopeConfig, report: Vec<u8>) -> Result<Self> {
log::info!("Session - Creating Session");
Expand All @@ -117,8 +117,8 @@ impl Session {
/// let config = PyroscopeConfig::new("https://localhost:8080", "my-app");
/// let report = vec![1, 2, 3];
/// let until = 154065120;
/// let session = Session::new(until, config, report).unwrap();
/// session.send().unwrap();
/// let session = Session::new(until, config, report)?;
/// session.send()?;
/// ```
pub fn send(self) -> Result<()> {
log::info!("Session - Sending Session {} - {}", self.from, self.until);
Expand Down
5 changes: 1 addition & 4 deletions src/timer/sleep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ impl Timer {
// Iterate through Senders
txs.lock()?.iter().for_each(|tx| {
// Send event to attached Sender
match tx.send(current) {
Ok(_) => {}
Err(_) => {}
}
let _res = tx.send(current);
});

// Sleep for 10s
Expand Down