mirror of https://github.com/fralalonde/dipstick
Merge branch 'master' of github.com:fralalonde/dipstick
This commit is contained in:
commit
490ba54908
|
@ -64,10 +64,12 @@ where
|
|||
fn publish(&self, snapshot: Vec<ScoreSnapshot>) {
|
||||
let publish_scope_fn = self.target_chain.open_scope(false);
|
||||
if snapshot.is_empty() {
|
||||
// no data was collected for this period
|
||||
debug!("No values were recorded for metrics in this period");
|
||||
// TODO repeat previous frame min/max ?
|
||||
// TODO update some canary metric ?
|
||||
|
||||
} else {
|
||||
debug!("Values were recorded for {} metrics in this period", snapshot.len());
|
||||
for metric in snapshot {
|
||||
for score in metric.2 {
|
||||
if let Some(ex) = (self.statistics)(metric.0, metric.1.as_ref(), score) {
|
||||
|
|
|
@ -39,6 +39,7 @@ where
|
|||
if inner_handle.is_cancelled() {
|
||||
break;
|
||||
}
|
||||
debug!("Running scheduled metrics operation");
|
||||
operation();
|
||||
});
|
||||
handle
|
||||
|
|
|
@ -101,21 +101,32 @@ impl Scoreboard {
|
|||
match self.kind {
|
||||
Marker => {
|
||||
snapshot.push(Count(scores[1] as u64));
|
||||
snapshot.push(Rate(average_rate(scores[1], duration_seconds, &scores, now)))
|
||||
snapshot.push(Rate(scores[1] as f64 / duration_seconds))
|
||||
}
|
||||
Gauge => {
|
||||
snapshot.push(Max(scores[3] as u64));
|
||||
snapshot.push(Min(scores[4] as u64));
|
||||
snapshot.push(Mean(scores[2] as f64 / scores[1] as f64));
|
||||
}
|
||||
Timer | Counter => {
|
||||
Timer => {
|
||||
snapshot.push(Count(scores[1] as u64));
|
||||
snapshot.push(Sum(scores[2] as u64));
|
||||
|
||||
snapshot.push(Max(scores[3] as u64));
|
||||
snapshot.push(Min(scores[4] as u64));
|
||||
snapshot.push(Mean(scores[2] as f64 / scores[1] as f64));
|
||||
snapshot.push(Rate(average_rate(scores[2], duration_seconds, &scores, now)))
|
||||
// timer rate uses the COUNT of timer calls per second (not SUM)
|
||||
snapshot.push(Rate(scores[1] as f64 / duration_seconds))
|
||||
}
|
||||
Counter => {
|
||||
snapshot.push(Count(scores[1] as u64));
|
||||
snapshot.push(Sum(scores[2] as u64));
|
||||
|
||||
snapshot.push(Max(scores[3] as u64));
|
||||
snapshot.push(Min(scores[4] as u64));
|
||||
snapshot.push(Mean(scores[2] as f64 / scores[1] as f64));
|
||||
// counter rate uses the SUM of values per second (e.g. to get bytes/s)
|
||||
snapshot.push(Rate(scores[2] as f64 / duration_seconds))
|
||||
}
|
||||
}
|
||||
Some((self.kind, self.name.clone(), snapshot))
|
||||
|
@ -125,10 +136,6 @@ impl Scoreboard {
|
|||
}
|
||||
}
|
||||
|
||||
fn average_rate(count: usize, time: f64, _scores: &[usize], _now: usize) -> f64 {
|
||||
count as f64 / time
|
||||
}
|
||||
|
||||
/// Spinlock until success or clear loss to concurrent update.
|
||||
#[inline]
|
||||
fn swap_if(counter: &AtomicUsize, new_value: usize, compare: fn(usize, usize) -> bool) {
|
||||
|
|
|
@ -79,17 +79,18 @@ impl RetrySocket {
|
|||
return Err(self.backoff(e));
|
||||
}
|
||||
|
||||
let opres = if let Some(ref mut socket) = self.socket {
|
||||
let op_result = if let Some(ref mut socket) = self.socket {
|
||||
operation(socket)
|
||||
} else {
|
||||
// still none, quiescent
|
||||
return Err(io::Error::from(io::ErrorKind::NotConnected));
|
||||
};
|
||||
|
||||
match opres {
|
||||
Ok(r) => Ok(r),
|
||||
Err(e) => Err(self.backoff(e)),
|
||||
if let Err(e) = op_result {
|
||||
return Err(self.backoff(e))
|
||||
}
|
||||
|
||||
op_result
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue