tikv / pprof-rs

A Rust CPU profiler implemented with the help of backtrace-rs
Apache License 2.0
1.3k stars 99 forks source link

examples profile_proto.rs Can't work #149

Closed Doslin closed 1 year ago

Doslin commented 2 years ago

error[E0599]: no method named pprof found for struct pprof::Report in the current scope --> examples/profile_proto.rs:103:30 | 103 | let profile = report.pprof().unwrap(); | ^^^^^ method not found in pprof::Report

error[E0599]: no method named pprof found for struct pprof::Report in the current scope --> examples/profile_proto.rs:104:30 | 104 | let profile = report.pprof().unwrap(); | ^^^^^ method not found in pprof::Report

For more information about this error, try rustc --explain E0599. error: could not compile pprof due to 2 previous errors

padinsky commented 1 year ago

I have exactly the same problem, does anyone know how to solve it?

padinsky commented 1 year ago

Fix this issue by adding the protobuf-codec option to the features, like this:

pprof = { version = "0.11.1", features = ["flamegraph", "protobuf-codec"] }

But now it's telling me that the encode method does not exist in the profile object, does anyone know how to solve it?

Rustin170506 commented 1 year ago

I think this issue has already been fixed by https://github.com/tikv/pprof-rs/pull/208

In cargo projects, if you want to run an example, you can try cargo run --example exmaple_name.

Then you will get the tips about how to enable features for this example.

➜  pprof-rs git:(master) ✗ cargo run --example profile_proto_with_prost                         
error: target `profile_proto_with_prost` in package `pprof` requires the features: `prost-codec`
Consider enabling them by passing, e.g., `--features="prost-codec"`

Then:

➜  pprof-rs git:(master) ✗ cargo run --example profile_proto_with_protobuf_codec --features="protobuf-codec"
   Compiling memchr v2.5.0
   Compiling io-lifetimes v1.0.9
   Compiling rustix v0.36.11
   Compiling pprof v0.11.1 (/Users/hi-rustin/vsc/pprof-rs)
   Compiling once_cell v1.17.1
   Compiling object v0.30.3