1- use crate :: PyroscopeAgent ;
2- use pyroscope_backends:: pyspy:: Pyspy ;
1+ use pyroscope :: PyroscopeAgent ;
2+ use pyroscope_backends:: pyspy:: PyspyConfig ;
33use pyroscope_backends:: rbspy:: Rbspy ;
4+ use pyroscope_backends:: { pyspy:: Pyspy , rbspy:: RbspyConfig } ;
45
56use std:: sync:: { Arc , Mutex } ;
67
@@ -16,12 +17,14 @@ pub fn add(x: i32, y: i32) -> i32 {
1617#[ no_mangle]
1718pub fn initialize_agent ( pid : i32 ) -> bool {
1819 std:: thread:: spawn ( move || {
20+ let config = RbspyConfig :: new ( pid, 100 , false , None , true ) ;
21+
1922 let mut agent = PyroscopeAgent :: builder ( "http://localhost:4040" , "rbspy.basic" )
20- . backend ( Rbspy :: new ( pid ) )
23+ . backend ( Rbspy :: new ( config ) )
2124 . build ( )
2225 . unwrap ( ) ;
2326
24- agent. start ( ) ;
27+ agent. start ( ) . unwrap ( ) ;
2528
2629 // should instead block here until a stop signal is received
2730 loop {
@@ -36,13 +39,21 @@ pub fn initialize_agent(pid: i32) -> bool {
3639#[ no_mangle]
3740pub fn initialize_python ( pid : i32 ) -> bool {
3841 std:: thread:: spawn ( move || {
42+ let config = PyspyConfig :: new ( pid)
43+ . sample_rate ( 100 )
44+ . lock_process ( true )
45+ . time_limit ( None )
46+ . with_subprocesses ( true )
47+ . include_idle ( false )
48+ . native ( false ) ;
49+
3950 let mut agent = PyroscopeAgent :: builder ( "http://localhost:4040" , "python.basic" )
40- . backend ( Pyspy :: new ( pid ) )
51+ . backend ( Pyspy :: new ( config ) )
4152 . build ( )
4253 . unwrap ( ) ;
4354 std:: thread:: sleep ( std:: time:: Duration :: from_millis ( 5000 ) ) ;
4455
45- agent. start ( ) ;
56+ agent. start ( ) . unwrap ( ) ;
4657
4758 // should instead block here until a stop signal is received
4859 loop {
0 commit comments