Skip to content

Commit

Permalink
imp(ruby): add on_cpu parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
omarabid committed Jun 30, 2022
1 parent 03a442f commit 5da0c7b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
18 changes: 13 additions & 5 deletions pyroscope_backends/pyroscope_rbspy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ pub struct RbspyConfig {
time_limit: Option<core::time::Duration>,
/// Include subprocesses
with_subprocesses: bool,
/// Include Oncpu Time
on_cpu: bool,
}

impl Default for RbspyConfig {
Expand All @@ -50,6 +52,7 @@ impl Default for RbspyConfig {
lock_process: false,
time_limit: None,
with_subprocesses: false,
on_cpu: false,
}
}
}
Expand All @@ -72,9 +75,9 @@ impl RbspyConfig {
}

/// Tag thread id in report
pub fn report_pid(self) -> Self {
pub fn report_pid(self, report_pid: bool) -> Self {
let backend_config = BackendConfig {
report_pid: true,
report_pid,
..self.backend_config
};

Expand All @@ -85,9 +88,9 @@ impl RbspyConfig {
}

/// Tag thread id in report
pub fn report_thread_id(self) -> Self {
pub fn report_thread_id(self, report_thread_id: bool) -> Self {
let backend_config = BackendConfig {
report_thread_id: true,
report_thread_id,
..self.backend_config
};

Expand Down Expand Up @@ -117,6 +120,11 @@ impl RbspyConfig {
..self
}
}

/// Include idle time
pub fn on_cpu(self, on_cpu: bool) -> Self {
RbspyConfig { on_cpu, ..self }
}
}

/// Rbspy Backend
Expand Down Expand Up @@ -211,7 +219,7 @@ impl Backend for Rbspy {
self.config.time_limit,
self.config.with_subprocesses,
None,
true,
self.config.on_cpu,
));

// Channel for Errors generated by the RubySpy Sampler
Expand Down
2 changes: 1 addition & 1 deletion pyroscope_ffi/ruby/lib/pyroscope.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Rust
extend FFI::Library
ffi_lib File.expand_path(File.dirname(__FILE__)) + "/rbspy/rbspy.#{RbConfig::CONFIG["DLEXT"]}"
attach_function :initialize_agent, [:string, :string, :string, :int, :bool, :string], :bool
attach_function :initialize_agent, [:string, :string, :string, :int, :bool, :bool, :bool, :bool, :string], :bool
attach_function :add_tag, [:uint64, :string, :string], :bool
attach_function :remove_tag, [:uint64, :string, :string], :bool
attach_function :drop_agent, [], :bool
Expand Down

0 comments on commit 5da0c7b

Please sign in to comment.