File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
lib/vector-core/src/metrics Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -779,6 +779,8 @@ impl AgentDDSketch {
779779 /// ## Errors
780780 ///
781781 /// Returns an error if a bucket size is greater that `u32::MAX`.
782+ #[ allow( clippy:: cast_possible_truncation) ]
783+ #[ allow( clippy:: cast_precision_loss) ]
782784 pub fn transform_to_sketch ( mut metric : Metric ) -> Result < Metric , & ' static str > {
783785 let sketch = match metric. data_mut ( ) . value_mut ( ) {
784786 MetricValue :: Distribution { samples, .. } => {
@@ -788,10 +790,24 @@ impl AgentDDSketch {
788790 }
789791 Some ( sketch)
790792 }
791- MetricValue :: AggregatedHistogram { buckets, .. } => {
793+ MetricValue :: AggregatedHistogram {
794+ buckets,
795+ sum,
796+ count,
797+ ..
798+ } => {
792799 let delta_buckets = mem:: take ( buckets) ;
793800 let mut sketch = AgentDDSketch :: with_agent_defaults ( ) ;
794801 sketch. insert_interpolate_buckets ( delta_buckets) ?;
802+
803+ let orig_sum = * sum;
804+ let orig_count = * count;
805+ if orig_count > 0 {
806+ sketch. sum = orig_sum;
807+ sketch. count = orig_count as u32 ;
808+ sketch. avg = orig_sum / orig_count as f64 ;
809+ }
810+
795811 Some ( sketch)
796812 }
797813 // We can't convert from any other metric value.
You can’t perform that action at this time.
0 commit comments