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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! Rust integration for [Pyroscope](https://grafana.com/oss/pyroscope/).
//!
//! # Quick Start
//!
//! ## Add the Pyroscope Library and the pprof-rs backend to Cargo.toml
//!
//! ```toml
//! [dependencies]
//! pyroscope = { version = "2.0.0", features = ["backend-pprof-rs"] }
//! ```
//!
//! ## Configure a Pyroscope Agent
//!
//! ```no_run
//! use pyroscope::pyroscope::PyroscopeAgentBuilder;
//! use pyroscope::backend::{pprof_backend, PprofConfig, BackendConfig};
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let agent = PyroscopeAgentBuilder::new(
//! "http://localhost:4040",
//! "myapp",
//! 100, // sample rate
//! "pyroscope-rs",
//! env!("CARGO_PKG_VERSION"),
//! pprof_backend(PprofConfig::default(), BackendConfig::default()),
//! )
//! .build()?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Start/Stop profiling
//!
//! To start profiling code and sending data.
//!
//! ```ignore
//! let agent_running = agent.start()?;
//! ```
//!
//! To stop profiling code. You can restart the profiling at a later point.
//!
//! ```ignore
//! let agent_ready = agent_running.stop()?;
//! ```
//!
//! Before you drop the variable, make sure to shutdown the agent.
//!
//! ```ignore
//! agent_ready.shutdown();
//! ```
extern crate core;
// Re-exports structs
pub use cratePyroscopeAgent;
pub use ;
pub use ThreadId;