@@ -53,35 +53,42 @@ pub trait Aggregation: fmt::Debug + any::Any + Send + Sync {
5353 fn as_mut ( & mut self ) -> & mut dyn any:: Any ;
5454}
5555
56- /// A measurement of the current value of an instrument.
57- #[ derive( Debug ) ]
58- pub struct Gauge < T > {
59- /// Represents individual aggregated measurements with unique attributes.
60- pub data_points : Vec < DataPoint < T > > ,
56+ /// DataPoint is a single data point in a time series.
57+ #[ derive( Debug , PartialEq ) ]
58+ pub struct GaugeDataPoint < T > {
59+ /// Attributes is the set of key value pairs that uniquely identify the
60+ /// time series.
61+ pub attributes : Vec < KeyValue > ,
62+ /// The time when the time series was started.
63+ pub start_time : Option < SystemTime > ,
64+ /// The time when the time series was recorded.
65+ pub time : SystemTime ,
66+ /// The value of this data point.
67+ pub value : T ,
68+ /// The sampled [Exemplar]s collected during the time series.
69+ pub exemplars : Vec < Exemplar < T > > ,
6170}
6271
63- impl < T : fmt:: Debug + Send + Sync + ' static > Aggregation for Gauge < T > {
64- fn as_any ( & self ) -> & dyn any:: Any {
65- self
66- }
67- fn as_mut ( & mut self ) -> & mut dyn any:: Any {
68- self
72+ impl < T : Copy > Clone for GaugeDataPoint < T > {
73+ fn clone ( & self ) -> Self {
74+ Self {
75+ attributes : self . attributes . clone ( ) ,
76+ start_time : self . start_time ,
77+ time : self . time ,
78+ value : self . value ,
79+ exemplars : self . exemplars . clone ( ) ,
80+ }
6981 }
7082}
7183
72- /// Represents the sum of all measurements of values from an instrument.
84+ /// A measurement of the current value of an instrument.
7385#[ derive( Debug ) ]
74- pub struct Sum < T > {
86+ pub struct Gauge < T > {
7587 /// Represents individual aggregated measurements with unique attributes.
76- pub data_points : Vec < DataPoint < T > > ,
77- /// Describes if the aggregation is reported as the change from the last report
78- /// time, or the cumulative changes since a fixed start time.
79- pub temporality : Temporality ,
80- /// Whether this aggregation only increases or decreases.
81- pub is_monotonic : bool ,
88+ pub data_points : Vec < GaugeDataPoint < T > > ,
8289}
8390
84- impl < T : fmt:: Debug + Send + Sync + ' static > Aggregation for Sum < T > {
91+ impl < T : fmt:: Debug + Send + Sync + ' static > Aggregation for Gauge < T > {
8592 fn as_any ( & self ) -> & dyn any:: Any {
8693 self
8794 }
@@ -92,7 +99,7 @@ impl<T: fmt::Debug + Send + Sync + 'static> Aggregation for Sum<T> {
9299
93100/// DataPoint is a single data point in a time series.
94101#[ derive( Debug , PartialEq ) ]
95- pub struct DataPoint < T > {
102+ pub struct SumDataPoint < T > {
96103 /// Attributes is the set of key value pairs that uniquely identify the
97104 /// time series.
98105 pub attributes : Vec < KeyValue > ,
@@ -106,7 +113,7 @@ pub struct DataPoint<T> {
106113 pub exemplars : Vec < Exemplar < T > > ,
107114}
108115
109- impl < T : Copy > Clone for DataPoint < T > {
116+ impl < T : Copy > Clone for SumDataPoint < T > {
110117 fn clone ( & self ) -> Self {
111118 Self {
112119 attributes : self . attributes . clone ( ) ,
@@ -118,6 +125,27 @@ impl<T: Copy> Clone for DataPoint<T> {
118125 }
119126}
120127
128+ /// Represents the sum of all measurements of values from an instrument.
129+ #[ derive( Debug ) ]
130+ pub struct Sum < T > {
131+ /// Represents individual aggregated measurements with unique attributes.
132+ pub data_points : Vec < SumDataPoint < T > > ,
133+ /// Describes if the aggregation is reported as the change from the last report
134+ /// time, or the cumulative changes since a fixed start time.
135+ pub temporality : Temporality ,
136+ /// Whether this aggregation only increases or decreases.
137+ pub is_monotonic : bool ,
138+ }
139+
140+ impl < T : fmt:: Debug + Send + Sync + ' static > Aggregation for Sum < T > {
141+ fn as_any ( & self ) -> & dyn any:: Any {
142+ self
143+ }
144+ fn as_mut ( & mut self ) -> & mut dyn any:: Any {
145+ self
146+ }
147+ }
148+
121149/// Represents the histogram of all measurements of values from an instrument.
122150#[ derive( Debug ) ]
123151pub struct Histogram < T > {
@@ -330,13 +358,13 @@ impl<T: Copy> Clone for Exemplar<T> {
330358#[ cfg( test) ]
331359mod tests {
332360
333- use super :: { DataPoint , Exemplar , ExponentialHistogramDataPoint , HistogramDataPoint } ;
361+ use super :: { Exemplar , ExponentialHistogramDataPoint , HistogramDataPoint , SumDataPoint } ;
334362
335363 use opentelemetry:: KeyValue ;
336364
337365 #[ test]
338366 fn validate_cloning_data_points ( ) {
339- let data_type = DataPoint {
367+ let data_type = SumDataPoint {
340368 attributes : vec ! [ KeyValue :: new( "key" , "value" ) ] ,
341369 start_time : std:: time:: SystemTime :: now ( ) ,
342370 time : std:: time:: SystemTime :: now ( ) ,
0 commit comments