Skip to main content

Crate pyroscope

Crate pyroscope 

Source
Expand description

Rust integration for Pyroscope.

§Quick Start

§Add the Pyroscope Library and the pprof-rs backend to Cargo.toml

[dependencies]
pyroscope = { version = "2.0.0", features = ["backend-pprof-rs"] }

§Configure a Pyroscope Agent

use pyroscope::pyroscope::PyroscopeAgentBuilder;
use pyroscope::backend::{pprof_backend, PprofConfig, BackendConfig};

let agent = PyroscopeAgentBuilder::new(
    "http://localhost:4040",
    "myapp",
    100, // sample rate
    "pyroscope-rs",
    env!("CARGO_PKG_VERSION"),
    pprof_backend(PprofConfig::default(), BackendConfig::default()),
)
.build()?;

§Start/Stop profiling

To start profiling code and sending data.

let agent_running = agent.start()?;

To stop profiling code. You can restart the profiling at a later point.

let agent_ready = agent_running.stop()?;

Before you drop the variable, make sure to shutdown the agent.

agent_ready.shutdown();

Re-exports§

pub use crate::pyroscope::PyroscopeAgent;
pub use error::PyroscopeError;
pub use error::Result;

Modules§

backend
encode
error
ffikit
pyroscope
session
timer

Structs§

ThreadId