Skip to content

Commit cf79e43

Browse files
committed
refactor(agent): remove accumulation_cycle
1 parent 0d7fab0 commit cf79e43

File tree

2 files changed

+7
-55
lines changed

2 files changed

+7
-55
lines changed

src/pyroscope.rs

Lines changed: 6 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use crate::{
1616

1717
const LOG_TAG: &str = "Pyroscope::Agent";
1818

19-
2019
/// A signal sent from the agent to the timer.
2120
///
2221
/// Either schedules another wake-up, or asks
@@ -54,8 +53,6 @@ pub struct PyroscopeConfig {
5453
pub tags: HashMap<String, String>,
5554
/// Sample rate used in Hz
5655
pub sample_rate: i32,
57-
/// How long to accumulate data for before sending it upstream
58-
pub accumulation_cycle: std::time::Duration,
5956
// TODO
6057
// log_level
6158
// auth_token
@@ -76,7 +73,6 @@ impl PyroscopeConfig {
7673
application_name: application_name.as_ref().to_owned(),
7774
tags: HashMap::new(),
7875
sample_rate: 100i32,
79-
accumulation_cycle: std::time::Duration::from_secs(10),
8076
}
8177
}
8278

@@ -94,26 +90,6 @@ impl PyroscopeConfig {
9490
}
9591
}
9692

97-
/// Override the accumulation cycle.
98-
///
99-
/// # Example
100-
///
101-
/// ```
102-
/// # fn main() -> Result<(), PyroscopeError> {
103-
/// use std::time::Duration;
104-
/// use pyroscope::pyroscope::PyroscopeConfig;
105-
/// let config = PyroscopeConfig::new("http://localhost:8080", "my-app")
106-
/// .accumulation_cycle(Duration::from_millis(4587))?;
107-
/// # Ok(())
108-
/// # }
109-
/// ```
110-
pub fn accumulation_cycle(self, accumulation_cycle: std::time::Duration) -> Self {
111-
Self {
112-
accumulation_cycle,
113-
..self
114-
}
115-
}
116-
11793
/// Set the tags
11894
/// # Example
11995
/// ```ignore
@@ -203,28 +179,6 @@ impl PyroscopeAgentBuilder {
203179
}
204180
}
205181

206-
/// Set the accumulation cycle. Default value is 10 seconds.
207-
///
208-
/// # Example
209-
///
210-
/// ```
211-
/// # fn main() -> Result<(), PyroscopeError> {
212-
/// use std::time::Duration;
213-
///
214-
/// let builder = PyroscopeAgentBuilder::new("http://localhost:8080", "my-app")
215-
/// .accumulation_cycle(Duration::from_secs(3))
216-
/// .build()
217-
/// ?;
218-
/// # Ok(())
219-
/// # }
220-
/// ```
221-
pub fn accumulation_cycle(self, acc_cycle: impl Into<std::time::Duration>) -> Self {
222-
Self {
223-
config: self.config.accumulation_cycle(acc_cycle.into()),
224-
..self
225-
}
226-
}
227-
228182
/// Set tags. Default is empty.
229183
/// # Example
230184
/// ```ignore
@@ -248,7 +202,7 @@ impl PyroscopeAgentBuilder {
248202
log::trace!(target: LOG_TAG, "Backend initialized");
249203

250204
// Start Timer
251-
let timer = Timer::initialize(self.config.accumulation_cycle.clone())?;
205+
let timer = Timer::initialize(std::time::Duration::from_secs(10))?;
252206
log::trace!(target: LOG_TAG, "Timer initialized");
253207

254208
// Start the SessionManager
@@ -306,7 +260,10 @@ impl Drop for PyroscopeAgent {
306260
// Stop the SessionManager
307261
match self.session_manager.push(SessionSignal::Kill) {
308262
Ok(_) => log::trace!(target: LOG_TAG, "Sent kill signal to SessionManager"),
309-
Err(_) => log::error!(target: LOG_TAG, "Error sending kill signal to SessionManager"),
263+
Err(_) => log::error!(
264+
target: LOG_TAG,
265+
"Error sending kill signal to SessionManager"
266+
),
310267
}
311268

312269
if let Some(handle) = self.session_manager.handle.take() {
@@ -325,7 +282,7 @@ impl Drop for PyroscopeAgent {
325282
}
326283
}
327284

328-
log::debug!(target: LOG_TAG, "Agent Dropped");
285+
log::debug!(target: LOG_TAG, "Agent Dropped");
329286
}
330287
}
331288

tests/session.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ use pyroscope::{
22
pyroscope::PyroscopeConfig,
33
session::{Session, SessionManager, SessionSignal},
44
};
5-
use std::{
6-
collections::HashMap,
7-
time::Duration,
8-
};
5+
use std::{collections::HashMap, time::Duration};
96

107
#[test]
118
fn test_session_manager_new() {
@@ -27,7 +24,6 @@ fn test_session_new() {
2724
application_name: "test".to_string(),
2825
tags: HashMap::new(),
2926
sample_rate: 100,
30-
accumulation_cycle: Duration::from_secs(10),
3127
};
3228

3329
let report = vec![1, 2, 3];
@@ -45,7 +41,6 @@ fn test_session_send_error() {
4541
application_name: "test".to_string(),
4642
tags: HashMap::new(),
4743
sample_rate: 100,
48-
accumulation_cycle: Duration::from_secs(10),
4944
};
5045

5146
let report = vec![1, 2, 3];

0 commit comments

Comments
 (0)