Skip to content

Commit

Permalink
put back poll duration histograms
Browse files Browse the repository at this point in the history
Signed-off-by: Eliza Weisman <[email protected]>
  • Loading branch information
hawkw committed Jan 7, 2022
1 parent 17037f5 commit b4549ed
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
15 changes: 1 addition & 14 deletions console-subscriber/src/aggregator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ use std::{
};
use tracing_core::{span::Id, Metadata};

use hdrhistogram::{
serialization::{Serializer, V2SerializeError, V2Serializer},
Histogram,
};

mod id_data;
mod shrink;
use self::id_data::{IdData, Include};
Expand Down Expand Up @@ -329,8 +324,7 @@ impl Aggregator {
&& subscription.update(&proto::tasks::TaskDetails {
task_id: Some(id.clone().into()),
now: Some(now.into()),
poll_times_histogram: None, // TODO(eliza): put back
// poll_times_histogram: serialize_histogram(&stats.poll_times_histogram).ok(),
poll_times_histogram: stats.serialize_histogram(),
})
{
self.details_watchers
Expand Down Expand Up @@ -720,13 +714,6 @@ impl From<AttributeUpdate> for Attribute {
}
}

fn serialize_histogram(histogram: &Histogram<u64>) -> Result<Vec<u8>, V2SerializeError> {
let mut serializer = V2Serializer::new();
let mut buf = Vec::new();
serializer.serialize(histogram, &mut buf)?;
Ok(buf)
}

fn update_attribute(attribute: &mut Attribute, update: &AttributeUpdate) {
use proto::field::Value::*;
let attribute_val = attribute.field.as_mut().and_then(|a| a.value.as_mut());
Expand Down
20 changes: 18 additions & 2 deletions console-subscriber/src/stats.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
use crate::{attribute, sync::Mutex, ToProto};
use hdrhistogram::Histogram;
use crate::{
attribute,
sync::{Mutex, MutexGuard},
ToProto,
};
use hdrhistogram::{
serialization::{Serializer, V2Serializer},
Histogram,
};
use std::cmp;
use std::collections::HashMap;
use std::sync::{
Expand Down Expand Up @@ -218,6 +225,15 @@ impl TaskStats {
fn make_dirty(&self) {
self.is_dirty.swap(true, AcqRel);
}

pub(crate) fn serialize_histogram(&self) -> Option<Vec<u8>> {
let poll_timestamps = self.poll_stats.timestamps.lock();
let histogram = poll_timestamps.histogram.as_ref()?;
let mut serializer = V2Serializer::new();
let mut buf = Vec::new();
serializer.serialize(histogram, &mut buf).ok()?;
Some(buf)
}
}

impl ToProto for TaskStats {
Expand Down

0 comments on commit b4549ed

Please sign in to comment.