diff --git a/opentelemetry-proto/src/transform/metrics.rs b/opentelemetry-proto/src/transform/metrics.rs index 15d97a2db..04a1fe18f 100644 --- a/opentelemetry-proto/src/transform/metrics.rs +++ b/opentelemetry-proto/src/transform/metrics.rs @@ -295,8 +295,8 @@ pub mod tonic { .iter() .map(|dp| TonicNumberDataPoint { attributes: dp.attributes.iter().map(Into::into).collect(), - start_time_unix_nano: to_nanos(dp.start_time), - time_unix_nano: to_nanos(dp.time), + start_time_unix_nano: to_nanos(sum.start_time), + time_unix_nano: to_nanos(sum.time), exemplars: dp.exemplars.iter().map(Into::into).collect(), flags: TonicDataPointFlags::default() as u32, value: Some(dp.value.into()), @@ -319,8 +319,8 @@ pub mod tonic { .iter() .map(|dp| TonicNumberDataPoint { attributes: dp.attributes.iter().map(Into::into).collect(), - start_time_unix_nano: dp.start_time.map(to_nanos).unwrap_or_default(), - time_unix_nano: to_nanos(dp.time), + start_time_unix_nano: gauge.start_time.map(to_nanos).unwrap_or_default(), + time_unix_nano: to_nanos(gauge.time), exemplars: dp.exemplars.iter().map(Into::into).collect(), flags: TonicDataPointFlags::default() as u32, value: Some(dp.value.into()), diff --git a/opentelemetry-sdk/src/metrics/data/mod.rs b/opentelemetry-sdk/src/metrics/data/mod.rs index 759049393..9c1516d8b 100644 --- a/opentelemetry-sdk/src/metrics/data/mod.rs +++ b/opentelemetry-sdk/src/metrics/data/mod.rs @@ -59,10 +59,6 @@ pub struct GaugeDataPoint { /// Attributes is the set of key value pairs that uniquely identify the /// time series. pub attributes: Vec, - /// The time when the time series was started. - pub start_time: Option, - /// The time when the time series was recorded. - pub time: SystemTime, /// The value of this data point. pub value: T, /// The sampled [Exemplar]s collected during the time series. @@ -73,8 +69,6 @@ impl Clone for GaugeDataPoint { fn clone(&self) -> Self { Self { attributes: self.attributes.clone(), - start_time: self.start_time, - time: self.time, value: self.value, exemplars: self.exemplars.clone(), } @@ -86,6 +80,10 @@ impl Clone for GaugeDataPoint { pub struct Gauge { /// Represents individual aggregated measurements with unique attributes. pub data_points: Vec>, + /// The time when the time series was started. + pub start_time: Option, + /// The time when the time series was recorded. + pub time: SystemTime, } impl Aggregation for Gauge { @@ -103,10 +101,6 @@ pub struct SumDataPoint { /// Attributes is the set of key value pairs that uniquely identify the /// time series. pub attributes: Vec, - /// The time when the time series was started. - pub start_time: SystemTime, - /// The time when the time series was recorded. - pub time: SystemTime, /// The value of this data point. pub value: T, /// The sampled [Exemplar]s collected during the time series. @@ -117,8 +111,6 @@ impl Clone for SumDataPoint { fn clone(&self) -> Self { Self { attributes: self.attributes.clone(), - start_time: self.start_time, - time: self.time, value: self.value, exemplars: self.exemplars.clone(), } @@ -130,6 +122,10 @@ impl Clone for SumDataPoint { pub struct Sum { /// Represents individual aggregated measurements with unique attributes. pub data_points: Vec>, + /// The time when the time series was started. + pub start_time: SystemTime, + /// The time when the time series was recorded. + pub time: SystemTime, /// Describes if the aggregation is reported as the change from the last report /// time, or the cumulative changes since a fixed start time. pub temporality: Temporality, @@ -366,8 +362,6 @@ mod tests { fn validate_cloning_data_points() { let data_type = SumDataPoint { attributes: vec![KeyValue::new("key", "value")], - start_time: std::time::SystemTime::now(), - time: std::time::SystemTime::now(), value: 0u32, exemplars: vec![Exemplar { filtered_attributes: vec![], diff --git a/opentelemetry-sdk/src/metrics/internal/aggregate.rs b/opentelemetry-sdk/src/metrics/internal/aggregate.rs index 3c78682dc..71befc8d6 100644 --- a/opentelemetry-sdk/src/metrics/internal/aggregate.rs +++ b/opentelemetry-sdk/src/metrics/internal/aggregate.rs @@ -2,10 +2,7 @@ use std::{marker, sync::Arc}; use opentelemetry::KeyValue; -use crate::metrics::{ - data::{Aggregation, Gauge}, - Temporality, -}; +use crate::metrics::{data::Aggregation, Temporality}; use super::{ exponential_histogram::ExpoHistogram, histogram::Histogram, last_value::LastValue, @@ -99,31 +96,15 @@ impl AggregateBuilder { /// Builds a last-value aggregate function input and output. pub(crate) fn last_value(&self) -> (impl Measure, impl ComputeAggregation) { - let lv_filter = Arc::new(LastValue::new()); - let lv_agg = Arc::clone(&lv_filter); + let lv = Arc::new(LastValue::new()); + let agg_lv = Arc::clone(&lv); let t = self.temporality; ( - self.filter(move |n, a: &[KeyValue]| lv_filter.measure(n, a)), - move |dest: Option<&mut dyn Aggregation>| { - let g = dest.and_then(|d| d.as_mut().downcast_mut::>()); - let mut new_agg = if g.is_none() { - Some(Gauge { - data_points: vec![], - }) - } else { - None - }; - let g = g.unwrap_or_else(|| new_agg.as_mut().expect("present if g is none")); - - match t { - Some(Temporality::Delta) => { - lv_agg.compute_aggregation_delta(&mut g.data_points) - } - _ => lv_agg.compute_aggregation_cumulative(&mut g.data_points), - } - - (g.data_points.len(), new_agg.map(|a| Box::new(a) as Box<_>)) + self.filter(move |n, a: &[KeyValue]| lv.measure(n, a)), + move |dest: Option<&mut dyn Aggregation>| match t { + Some(Temporality::Delta) => agg_lv.delta(dest), + _ => agg_lv.cumulative(dest), }, ) } @@ -211,8 +192,8 @@ impl AggregateBuilder { #[cfg(test)] mod tests { use crate::metrics::data::{ - ExponentialBucket, ExponentialHistogram, ExponentialHistogramDataPoint, GaugeDataPoint, - Histogram, HistogramDataPoint, Sum, SumDataPoint, + ExponentialBucket, ExponentialHistogram, ExponentialHistogramDataPoint, Gauge, + GaugeDataPoint, Histogram, HistogramDataPoint, Sum, SumDataPoint, }; use std::{time::SystemTime, vec}; @@ -224,11 +205,11 @@ mod tests { let mut a = Gauge { data_points: vec![GaugeDataPoint { attributes: vec![KeyValue::new("a", 1)], - start_time: Some(SystemTime::now()), - time: SystemTime::now(), value: 1u64, exemplars: vec![], }], + start_time: Some(SystemTime::now()), + time: SystemTime::now(), }; let new_attributes = [KeyValue::new("b", 2)]; measure.call(2, &new_attributes[..]); @@ -251,19 +232,17 @@ mod tests { data_points: vec![ SumDataPoint { attributes: vec![KeyValue::new("a1", 1)], - start_time: SystemTime::now(), - time: SystemTime::now(), value: 1u64, exemplars: vec![], }, SumDataPoint { attributes: vec![KeyValue::new("a2", 1)], - start_time: SystemTime::now(), - time: SystemTime::now(), value: 2u64, exemplars: vec![], }, ], + start_time: SystemTime::now(), + time: SystemTime::now(), temporality: if temporality == Temporality::Delta { Temporality::Cumulative } else { @@ -294,19 +273,17 @@ mod tests { data_points: vec![ SumDataPoint { attributes: vec![KeyValue::new("a1", 1)], - start_time: SystemTime::now(), - time: SystemTime::now(), value: 1u64, exemplars: vec![], }, SumDataPoint { attributes: vec![KeyValue::new("a2", 1)], - start_time: SystemTime::now(), - time: SystemTime::now(), value: 2u64, exemplars: vec![], }, ], + start_time: SystemTime::now(), + time: SystemTime::now(), temporality: if temporality == Temporality::Delta { Temporality::Cumulative } else { diff --git a/opentelemetry-sdk/src/metrics/internal/exponential_histogram.rs b/opentelemetry-sdk/src/metrics/internal/exponential_histogram.rs index 4760a8a55..af89dc227 100644 --- a/opentelemetry-sdk/src/metrics/internal/exponential_histogram.rs +++ b/opentelemetry-sdk/src/metrics/internal/exponential_histogram.rs @@ -1440,7 +1440,7 @@ mod tests { count = out_fn.call(Some(got.as_mut())).0 } - assert_aggregation_eq::(Box::new(test.want), got, true, test.name); + assert_aggregation_eq::(Box::new(test.want), got, test.name); assert_eq!(test.want_count, count, "{}", test.name); } } @@ -1448,7 +1448,6 @@ mod tests { fn assert_aggregation_eq( a: Box, b: Box, - ignore_timestamp: bool, test_name: &'static str, ) { assert_eq!( @@ -1467,13 +1466,7 @@ mod tests { test_name ); for (a, b) in a.data_points.iter().zip(b.data_points.iter()) { - assert_gauge_data_points_eq( - a, - b, - ignore_timestamp, - "mismatching gauge data points", - test_name, - ); + assert_gauge_data_points_eq(a, b, "mismatching gauge data points", test_name); } } else if let Some(a) = a.as_any().downcast_ref::>() { let b = b.as_any().downcast_ref::>().unwrap(); @@ -1494,13 +1487,7 @@ mod tests { test_name ); for (a, b) in a.data_points.iter().zip(b.data_points.iter()) { - assert_sum_data_points_eq( - a, - b, - ignore_timestamp, - "mismatching sum data points", - test_name, - ); + assert_sum_data_points_eq(a, b, "mismatching sum data points", test_name); } } else if let Some(a) = a.as_any().downcast_ref::>() { let b = b.as_any().downcast_ref::>().unwrap(); @@ -1516,13 +1503,7 @@ mod tests { test_name ); for (a, b) in a.data_points.iter().zip(b.data_points.iter()) { - assert_hist_data_points_eq( - a, - b, - ignore_timestamp, - "mismatching hist data points", - test_name, - ); + assert_hist_data_points_eq(a, b, "mismatching hist data points", test_name); } } else if let Some(a) = a.as_any().downcast_ref::>() { let b = b @@ -1544,7 +1525,6 @@ mod tests { assert_exponential_hist_data_points_eq( a, b, - ignore_timestamp, "mismatching hist data points", test_name, ); @@ -1557,7 +1537,6 @@ mod tests { fn assert_sum_data_points_eq( a: &data::SumDataPoint, b: &data::SumDataPoint, - ignore_timestamp: bool, message: &'static str, test_name: &'static str, ) { @@ -1567,21 +1546,11 @@ mod tests { test_name, message ); assert_eq!(a.value, b.value, "{}: {} value", test_name, message); - - if !ignore_timestamp { - assert_eq!( - a.start_time, b.start_time, - "{}: {} start time", - test_name, message - ); - assert_eq!(a.time, b.time, "{}: {} time", test_name, message); - } } fn assert_gauge_data_points_eq( a: &data::GaugeDataPoint, b: &data::GaugeDataPoint, - ignore_timestamp: bool, message: &'static str, test_name: &'static str, ) { @@ -1591,21 +1560,11 @@ mod tests { test_name, message ); assert_eq!(a.value, b.value, "{}: {} value", test_name, message); - - if !ignore_timestamp { - assert_eq!( - a.start_time, b.start_time, - "{}: {} start time", - test_name, message - ); - assert_eq!(a.time, b.time, "{}: {} time", test_name, message); - } } fn assert_hist_data_points_eq( a: &data::HistogramDataPoint, b: &data::HistogramDataPoint, - ignore_timestamp: bool, message: &'static str, test_name: &'static str, ) { @@ -1624,21 +1583,11 @@ mod tests { assert_eq!(a.min, b.min, "{}: {} min", test_name, message); assert_eq!(a.max, b.max, "{}: {} max", test_name, message); assert_eq!(a.sum, b.sum, "{}: {} sum", test_name, message); - - if !ignore_timestamp { - assert_eq!( - a.start_time, b.start_time, - "{}: {} start time", - test_name, message - ); - assert_eq!(a.time, b.time, "{}: {} time", test_name, message); - } } fn assert_exponential_hist_data_points_eq( a: &data::ExponentialHistogramDataPoint, b: &data::ExponentialHistogramDataPoint, - ignore_timestamp: bool, message: &'static str, test_name: &'static str, ) { @@ -1669,14 +1618,5 @@ mod tests { "{}: {} neg", test_name, message ); - - if !ignore_timestamp { - assert_eq!( - a.start_time, b.start_time, - "{}: {} start time", - test_name, message - ); - assert_eq!(a.time, b.time, "{}: {} time", test_name, message); - } } } diff --git a/opentelemetry-sdk/src/metrics/internal/last_value.rs b/opentelemetry-sdk/src/metrics/internal/last_value.rs index b611be71f..44b7b2339 100644 --- a/opentelemetry-sdk/src/metrics/internal/last_value.rs +++ b/opentelemetry-sdk/src/metrics/internal/last_value.rs @@ -1,6 +1,6 @@ use std::{mem::replace, ops::DerefMut, sync::Mutex, time::SystemTime}; -use crate::metrics::data::GaugeDataPoint; +use crate::metrics::data::{self, Aggregation, GaugeDataPoint}; use opentelemetry::KeyValue; use super::{Aggregator, AtomicTracker, AtomicallyUpdate, Number, ValueMap}; @@ -56,33 +56,75 @@ impl LastValue { self.value_map.measure(measurement, attrs); } - pub(crate) fn compute_aggregation_delta(&self, dest: &mut Vec>) { - let t = SystemTime::now(); - let prev_start = self + pub(crate) fn delta( + &self, + dest: Option<&mut dyn Aggregation>, + ) -> (usize, Option>) { + let time = SystemTime::now(); + let start_time = self .start .lock() - .map(|mut start| replace(start.deref_mut(), t)) - .unwrap_or(t); + .map(|mut start| replace(start.deref_mut(), time)) + .unwrap_or(time); + + let s_data = dest.and_then(|d| d.as_mut().downcast_mut::>()); + let mut new_agg = if s_data.is_none() { + Some(data::Gauge { + data_points: vec![], + start_time: Some(start_time), + time, + }) + } else { + None + }; + let s_data = s_data.unwrap_or_else(|| new_agg.as_mut().expect("present if s_data is none")); + s_data.start_time = Some(start_time); + s_data.time = time; + self.value_map - .collect_and_reset(dest, |attributes, aggr| GaugeDataPoint { + .collect_and_reset(&mut s_data.data_points, |attributes, aggr| GaugeDataPoint { attributes, - start_time: Some(prev_start), - time: t, value: aggr.value.get_value(), exemplars: vec![], }); + + ( + s_data.data_points.len(), + new_agg.map(|a| Box::new(a) as Box<_>), + ) } - pub(crate) fn compute_aggregation_cumulative(&self, dest: &mut Vec>) { - let t = SystemTime::now(); - let prev_start = self.start.lock().map(|start| *start).unwrap_or(t); + pub(crate) fn cumulative( + &self, + dest: Option<&mut dyn Aggregation>, + ) -> (usize, Option>) { + let time = SystemTime::now(); + let start_time = self.start.lock().map(|start| *start).unwrap_or(time); + let s_data = dest.and_then(|d| d.as_mut().downcast_mut::>()); + let mut new_agg = if s_data.is_none() { + Some(data::Gauge { + data_points: vec![], + start_time: Some(start_time), + time, + }) + } else { + None + }; + let s_data = s_data.unwrap_or_else(|| new_agg.as_mut().expect("present if s_data is none")); + + s_data.start_time = Some(start_time); + s_data.time = time; + self.value_map - .collect_readonly(dest, |attributes, aggr| GaugeDataPoint { + .collect_readonly(&mut s_data.data_points, |attributes, aggr| GaugeDataPoint { attributes, - start_time: Some(prev_start), - time: t, value: aggr.value.get_value(), exemplars: vec![], }); + + ( + s_data.data_points.len(), + new_agg.map(|a| Box::new(a) as Box<_>), + ) } } diff --git a/opentelemetry-sdk/src/metrics/internal/precomputed_sum.rs b/opentelemetry-sdk/src/metrics/internal/precomputed_sum.rs index a8b04b85c..a37bfdd25 100644 --- a/opentelemetry-sdk/src/metrics/internal/precomputed_sum.rs +++ b/opentelemetry-sdk/src/metrics/internal/precomputed_sum.rs @@ -33,12 +33,19 @@ impl PrecomputedSum { &self, dest: Option<&mut dyn Aggregation>, ) -> (usize, Option>) { - let t = SystemTime::now(); + let time = SystemTime::now(); + let start_time = self + .start + .lock() + .map(|mut start| replace(start.deref_mut(), time)) + .unwrap_or(time); let s_data = dest.and_then(|d| d.as_mut().downcast_mut::>()); let mut new_agg = if s_data.is_none() { Some(data::Sum { data_points: vec![], + start_time, + time, temporality: Temporality::Delta, is_monotonic: self.monotonic, }) @@ -46,15 +53,11 @@ impl PrecomputedSum { None }; let s_data = s_data.unwrap_or_else(|| new_agg.as_mut().expect("present if s_data is none")); + s_data.start_time = start_time; + s_data.time = time; s_data.temporality = Temporality::Delta; s_data.is_monotonic = self.monotonic; - let prev_start = self - .start - .lock() - .map(|mut start| replace(start.deref_mut(), t)) - .unwrap_or(t); - let mut reported = match self.reported.lock() { Ok(r) => r, Err(_) => return (0, None), @@ -68,8 +71,6 @@ impl PrecomputedSum { let delta = value - *reported.get(&attributes).unwrap_or(&T::default()); SumDataPoint { attributes, - start_time: prev_start, - time: t, value: delta, exemplars: vec![], } @@ -88,12 +89,15 @@ impl PrecomputedSum { &self, dest: Option<&mut dyn Aggregation>, ) -> (usize, Option>) { - let t = SystemTime::now(); + let time = SystemTime::now(); + let start_time = self.start.lock().map(|start| *start).unwrap_or(time); let s_data = dest.and_then(|d| d.as_mut().downcast_mut::>()); let mut new_agg = if s_data.is_none() { Some(data::Sum { data_points: vec![], + start_time, + time, temporality: Temporality::Cumulative, is_monotonic: self.monotonic, }) @@ -101,16 +105,14 @@ impl PrecomputedSum { None }; let s_data = s_data.unwrap_or_else(|| new_agg.as_mut().expect("present if s_data is none")); + s_data.start_time = start_time; + s_data.time = time; s_data.temporality = Temporality::Cumulative; s_data.is_monotonic = self.monotonic; - let prev_start = self.start.lock().map(|start| *start).unwrap_or(t); - self.value_map .collect_readonly(&mut s_data.data_points, |attributes, aggr| SumDataPoint { attributes, - start_time: prev_start, - time: t, value: aggr.value.get_value(), exemplars: vec![], }); diff --git a/opentelemetry-sdk/src/metrics/internal/sum.rs b/opentelemetry-sdk/src/metrics/internal/sum.rs index eec8f746b..7666b6e44 100644 --- a/opentelemetry-sdk/src/metrics/internal/sum.rs +++ b/opentelemetry-sdk/src/metrics/internal/sum.rs @@ -71,12 +71,19 @@ impl Sum { &self, dest: Option<&mut dyn Aggregation>, ) -> (usize, Option>) { - let t = SystemTime::now(); + let time = SystemTime::now(); + let start_time = self + .start + .lock() + .map(|mut start| replace(start.deref_mut(), time)) + .unwrap_or(time); let s_data = dest.and_then(|d| d.as_mut().downcast_mut::>()); let mut new_agg = if s_data.is_none() { Some(data::Sum { data_points: vec![], + start_time, + time, temporality: Temporality::Delta, is_monotonic: self.monotonic, }) @@ -84,19 +91,14 @@ impl Sum { None }; let s_data = s_data.unwrap_or_else(|| new_agg.as_mut().expect("present if s_data is none")); + s_data.start_time = start_time; + s_data.time = time; s_data.temporality = Temporality::Delta; s_data.is_monotonic = self.monotonic; - let prev_start = self - .start - .lock() - .map(|mut start| replace(start.deref_mut(), t)) - .unwrap_or(t); self.value_map .collect_and_reset(&mut s_data.data_points, |attributes, aggr| SumDataPoint { attributes, - start_time: prev_start, - time: t, value: aggr.value.get_value(), exemplars: vec![], }); @@ -111,12 +113,14 @@ impl Sum { &self, dest: Option<&mut dyn Aggregation>, ) -> (usize, Option>) { - let t = SystemTime::now(); - + let time = SystemTime::now(); + let start_time = self.start.lock().map(|start| *start).unwrap_or(time); let s_data = dest.and_then(|d| d.as_mut().downcast_mut::>()); let mut new_agg = if s_data.is_none() { Some(data::Sum { data_points: vec![], + start_time, + time, temporality: Temporality::Cumulative, is_monotonic: self.monotonic, }) @@ -124,16 +128,15 @@ impl Sum { None }; let s_data = s_data.unwrap_or_else(|| new_agg.as_mut().expect("present if s_data is none")); + + s_data.start_time = start_time; + s_data.time = time; s_data.temporality = Temporality::Cumulative; s_data.is_monotonic = self.monotonic; - let prev_start = self.start.lock().map(|start| *start).unwrap_or(t); - self.value_map .collect_readonly(&mut s_data.data_points, |attributes, aggr| SumDataPoint { attributes, - start_time: prev_start, - time: t, value: aggr.value.get_value(), exemplars: vec![], }); diff --git a/opentelemetry-sdk/src/testing/metrics/in_memory_exporter.rs b/opentelemetry-sdk/src/testing/metrics/in_memory_exporter.rs index 8f7ab2183..631e44418 100644 --- a/opentelemetry-sdk/src/testing/metrics/in_memory_exporter.rs +++ b/opentelemetry-sdk/src/testing/metrics/in_memory_exporter.rs @@ -210,32 +210,44 @@ impl InMemoryMetricExporter { } else if let Some(sum) = data.as_any().downcast_ref::>() { Some(Box::new(data::Sum { data_points: sum.data_points.clone(), + start_time: sum.start_time, + time: sum.time, temporality: sum.temporality, is_monotonic: sum.is_monotonic, })) } else if let Some(sum) = data.as_any().downcast_ref::>() { Some(Box::new(data::Sum { data_points: sum.data_points.clone(), + start_time: sum.start_time, + time: sum.time, temporality: sum.temporality, is_monotonic: sum.is_monotonic, })) } else if let Some(sum) = data.as_any().downcast_ref::>() { Some(Box::new(data::Sum { data_points: sum.data_points.clone(), + start_time: sum.start_time, + time: sum.time, temporality: sum.temporality, is_monotonic: sum.is_monotonic, })) } else if let Some(gauge) = data.as_any().downcast_ref::>() { Some(Box::new(data::Gauge { data_points: gauge.data_points.clone(), + start_time: gauge.start_time, + time: gauge.time, })) } else if let Some(gauge) = data.as_any().downcast_ref::>() { Some(Box::new(data::Gauge { data_points: gauge.data_points.clone(), + start_time: gauge.start_time, + time: gauge.time, })) } else if let Some(gauge) = data.as_any().downcast_ref::>() { Some(Box::new(data::Gauge { data_points: gauge.data_points.clone(), + start_time: gauge.start_time, + time: gauge.time, })) } else { // unknown data type diff --git a/opentelemetry-stdout/src/metrics/exporter.rs b/opentelemetry-stdout/src/metrics/exporter.rs index 67dbbf4e9..43fbda016 100644 --- a/opentelemetry-stdout/src/metrics/exporter.rs +++ b/opentelemetry-stdout/src/metrics/exporter.rs @@ -142,11 +142,33 @@ fn print_sum(sum: &data::Sum) { } else { println!("\t\tTemporality : Delta"); } + let datetime: DateTime = sum.start_time.into(); + println!( + "\t\tStartTime : {}", + datetime.format("%Y-%m-%d %H:%M:%S%.6f") + ); + let datetime: DateTime = sum.time.into(); + println!( + "\t\tEndTime : {}", + datetime.format("%Y-%m-%d %H:%M:%S%.6f") + ); print_sum_data_points(&sum.data_points); } fn print_gauge(gauge: &data::Gauge) { println!("\t\tGauge DataPoints"); + if let Some(start_time) = gauge.start_time { + let datetime: DateTime = start_time.into(); + println!( + "\t\t\tStartTime : {}", + datetime.format("%Y-%m-%d %H:%M:%S%.6f") + ); + } + let datetime: DateTime = gauge.time.into(); + println!( + "\t\t\tEndTime : {}", + datetime.format("%Y-%m-%d %H:%M:%S%.6f") + ); print_gauge_data_points(&gauge.data_points); } @@ -163,16 +185,6 @@ fn print_histogram(histogram: &data::Histogram) { fn print_sum_data_points(data_points: &[data::SumDataPoint]) { for (i, data_point) in data_points.iter().enumerate() { println!("\t\tDataPoint #{}", i); - let datetime: DateTime = data_point.start_time.into(); - println!( - "\t\t\tStartTime : {}", - datetime.format("%Y-%m-%d %H:%M:%S%.6f") - ); - let datetime: DateTime = data_point.time.into(); - println!( - "\t\t\tEndTime : {}", - datetime.format("%Y-%m-%d %H:%M:%S%.6f") - ); println!("\t\t\tValue : {:#?}", data_point.value); println!("\t\t\tAttributes :"); for kv in data_point.attributes.iter() { @@ -184,18 +196,6 @@ fn print_sum_data_points(data_points: &[data::SumDataPoint]) { fn print_gauge_data_points(data_points: &[data::GaugeDataPoint]) { for (i, data_point) in data_points.iter().enumerate() { println!("\t\tDataPoint #{}", i); - if let Some(start_time) = data_point.start_time { - let datetime: DateTime = start_time.into(); - println!( - "\t\t\tStartTime : {}", - datetime.format("%Y-%m-%d %H:%M:%S%.6f") - ); - } - let datetime: DateTime = data_point.time.into(); - println!( - "\t\t\tEndTime : {}", - datetime.format("%Y-%m-%d %H:%M:%S%.6f") - ); println!("\t\t\tValue : {:#?}", data_point.value); println!("\t\t\tAttributes :"); for kv in data_point.attributes.iter() {