forked from grafana/pyroscope-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.rs
35 lines (26 loc) · 829 Bytes
/
error.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
extern crate pyroscope;
use pyroscope::{PyroscopeAgent, Result};
use pyroscope_pprofrs::{pprof_backend, PprofConfig};
fn fibonacci(n: u64) -> u64 {
match n {
0 | 1 => 1,
n => fibonacci(n - 1) + fibonacci(n - 2),
}
}
fn main() -> Result<()> {
// Force rustc to display the log messages in the console.
std::env::set_var("RUST_LOG", "trace");
// Initialize the logger.
pretty_env_logger::init_timed();
let agent = PyroscopeAgent::builder("http://invalid_url", "example.error")
.backend(pprof_backend(PprofConfig::new().sample_rate(100)))
.build()
.unwrap();
// Start Agent
let agent_running = agent.start()?;
let _result = fibonacci(47);
// Stop Agent
let agent_ready = agent_running.stop()?;
agent_ready.shutdown();
Ok(())
}