Skip to content

Commit f8f96c0

Browse files
committed
imp(examples): add error example
1 parent 6feba17 commit f8f96c0

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

examples/error.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright 2021 Developers of Pyroscope.
2+
3+
// Licensed under the Apache License, Version 2.0 <LICENSE or
4+
// https://www.apache.org/licenses/LICENSE-2.0>. This file may not be copied, modified, or distributed
5+
// except according to those terms.
6+
7+
extern crate pyroscope;
8+
9+
use pyroscope::{PyroscopeAgent, Result};
10+
11+
fn fibonacci(n: u64) -> u64 {
12+
match n {
13+
0 | 1 => 1,
14+
n => fibonacci(n - 1) + fibonacci(n - 2),
15+
}
16+
}
17+
18+
fn main() -> Result<()> {
19+
// This example should fail and return an error.
20+
let mut agent = PyroscopeAgent::builder("http://invalid_url", "example.error")
21+
.build()?;
22+
// Start Agent
23+
agent.start()?;
24+
25+
let _result = fibonacci(47);
26+
27+
// Stop Agent
28+
agent.stop()?;
29+
30+
drop(agent);
31+
32+
Ok(())
33+
}

src/session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ impl SessionManager {
5454
}
5555
SessionSignal::Kill => {
5656
// Kill the session manager
57-
return Ok(());
5857
log::trace!("SessionManager - Kill signal received");
58+
return Ok(());
5959
}
6060
}
6161
}

0 commit comments

Comments
 (0)