Skip to content

Commit 5d1a049

Browse files
committed
fix(warning): fix various compiler warnings
1 parent 3d34ce4 commit 5d1a049

File tree

7 files changed

+16
-41
lines changed

7 files changed

+16
-41
lines changed

examples/internal/rbspy-connect.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ fn main() -> Result<()> {
1616

1717
let pid = args[1].parse::<i32>().unwrap();
1818

19-
let config = RbspyConfig::new(pid, 100, true, None, true);
19+
let config = RbspyConfig::new(pid)
20+
.sample_rate(100)
21+
.lock_process(true)
22+
.with_subprocesses(true);
2023

2124
let mut agent = PyroscopeAgent::builder("http://localhost:4040", "rbspy.basic")
2225
.backend(Rbspy::new(config))

pyroscope_backends/src/pprof.rs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -137,40 +137,6 @@ impl Backend for Pprof<'_> {
137137
}
138138
}
139139

140-
// Copyright: https://github.com/YangKeao
141-
fn fold<W>(report: &pprof::Report, with_thread_name: bool, mut writer: W) -> Result<()>
142-
where
143-
W: std::io::Write,
144-
{
145-
for (key, value) in report.data.iter() {
146-
if with_thread_name {
147-
if !key.thread_name.is_empty() {
148-
write!(writer, "{};", key.thread_name)?;
149-
} else {
150-
write!(writer, "{:?};", key.thread_id)?;
151-
}
152-
}
153-
154-
for (index, frame) in key.frames.iter().rev().enumerate() {
155-
for (index, symbol) in frame.iter().rev().enumerate() {
156-
if index + 1 == frame.len() {
157-
write!(writer, "{}", symbol)?;
158-
} else {
159-
write!(writer, "{};", symbol)?;
160-
}
161-
}
162-
163-
if index + 1 != key.frames.len() {
164-
write!(writer, ";")?;
165-
}
166-
}
167-
168-
writeln!(writer, " {}", value)?;
169-
}
170-
171-
Ok(())
172-
}
173-
174140
impl From<pprof::Report> for Report {
175141
fn from(report: pprof::Report) -> Self {
176142
//convert report to Report

pyroscope_backends/src/pyspy.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ impl Backend for Pyspy {
169169
return Err(BackendError::new("Rbspy: No Process ID Specified"));
170170
}
171171

172+
// Set duration for py-spy
173+
let duration = match self.config.time_limit {
174+
Some(duration) => py_spy::config::RecordDuration::Seconds(duration.as_secs()),
175+
None => py_spy::config::RecordDuration::Unlimited,
176+
};
177+
172178
// Create a new py-spy configuration
173179
self.sampler_config = Some(Config {
174180
blocking: self.config.lock_process.clone(),
@@ -179,6 +185,7 @@ impl Backend for Pyspy {
179185
include_thread_ids: true,
180186
subprocesses: self.config.with_subprocesses,
181187
gil_only: self.config.gil_only,
188+
duration,
182189
..Config::default()
183190
});
184191

pyroscope_backends/src/rbspy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use super::error::{BackendError, Result};
22
use super::types::{Backend, State};
33

4-
use rbspy::{sampler::Sampler, ui::output::Outputter, OutputFormat, StackFrame, StackTrace};
4+
use rbspy::{sampler::Sampler, ui::output::Outputter, StackFrame, StackTrace};
55

66
use std::collections::HashMap;
77
use std::io::Write;

pyroscope_backends/src/types.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ mod tests {
345345

346346
#[test]
347347
fn test_report_record() {
348-
let mut report = Report::new();
348+
let mut report = Report::new(HashMap::new());
349349

350350
let stack_trace = StackTrace::new(None, None, None, vec![]);
351351

@@ -355,7 +355,7 @@ mod tests {
355355

356356
#[test]
357357
fn test_report_clear() {
358-
let mut report = Report::new();
358+
let mut report = Report::new(HashMap::new());
359359

360360
let stack_trace = StackTrace::new(None, None, None, vec![]);
361361

@@ -388,7 +388,7 @@ mod tests {
388388
));
389389
let stack_trace = StackTrace::new(None, None, None, frames);
390390

391-
let mut report = Report::new();
391+
let mut report = Report::new(HashMap::new());
392392

393393
report.record(stack_trace.clone()).unwrap();
394394
report.record(stack_trace).unwrap();

pyroscope_backends/src/void.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl Backend for VoidBackend {
6161
let stack_trace = generate_stack_trace()?;
6262

6363
// Add the StackTrace to the buffer
64-
self.buffer.record(stack_trace);
64+
self.buffer.record(stack_trace)?;
6565

6666
Ok(())
6767
}

src/pyroscope.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use std::{
55
Arc, Condvar, Mutex,
66
},
77
thread::JoinHandle,
8-
time::Duration,
98
};
109

1110
use crate::{

0 commit comments

Comments
 (0)