Skip to content

Rust

The pyroscope crate is Grafana’s official Rust SDK for continuous profiling, paired with the pyroscope_pprofrs backend for CPU sampling.

  • The ingest endpoint: https://otel.kloudmate.com/v1/profiles/pyroscope
  • An API key — go to Settings → API Keys, click Add New, and create an Ingest Key – Backend. Copy it immediately; KloudMate shows it only once.

Add both crates to Cargo.toml:

[dependencies]
pyroscope = "0.5"
pyroscope_pprofrs = "0.2"

Build and start the agent as early as possible in main():

use pyroscope::PyroscopeAgent;
use pyroscope_pprofrs::{pprof_backend, PprofConfig};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let pprof_config = PprofConfig::new().sample_rate(100);
    let backend_impl = pprof_backend(pprof_config);

    let agent = PyroscopeAgent::builder("https://otel.kloudmate.com/v1/profiles/pyroscope", "my-service")
        .backend(backend_impl)
        .basic_auth("KloudMate", "YOUR_API_KEY")
        .build()?;

    let agent_running = agent.start()?;

    // the rest of your application

    agent_running.stop()?;
    Ok(())
}

Swap my-service for a name that identifies this deployment, and YOUR_API_KEY for the key you copied above.

Open Profiling → All Services, select cpu from the profile type dropdown, and give it a minute. Your service’s card appears with a live chart as soon as the first samples land.

If nothing shows up, check that the first basic_auth argument is the literal string KloudMate — a missing username is the most common cause of a silent 401.