@@ -184,6 +184,11 @@ impl<T> GaugeDataPoint<T> {
184184 pub fn exemplars ( & self ) -> impl Iterator < Item = & Exemplar < T > > {
185185 self . exemplars . iter ( )
186186 }
187+
188+ /// Returns the value of this data point.
189+ pub fn value ( & self ) -> & T {
190+ & self . value
191+ }
187192}
188193
189194/// A measurement of the current value of an instrument.
@@ -202,6 +207,16 @@ impl<T> Gauge<T> {
202207 pub fn data_points ( & self ) -> impl Iterator < Item = & GaugeDataPoint < T > > {
203208 self . data_points . iter ( )
204209 }
210+
211+ /// Returns the time when the time series was started.
212+ pub fn start_time ( & self ) -> Option < SystemTime > {
213+ self . start_time
214+ }
215+
216+ /// Returns the time when the time series was recorded.
217+ pub fn time ( & self ) -> SystemTime {
218+ self . time
219+ }
205220}
206221
207222/// DataPoint is a single data point in a time series.
@@ -226,6 +241,11 @@ impl<T> SumDataPoint<T> {
226241 pub fn exemplars ( & self ) -> impl Iterator < Item = & Exemplar < T > > {
227242 self . exemplars . iter ( )
228243 }
244+
245+ /// Returns the value of this data point.
246+ pub fn value ( & self ) -> & T {
247+ & self . value
248+ }
229249}
230250
231251/// Represents the sum of all measurements of values from an instrument.
@@ -234,21 +254,42 @@ pub struct Sum<T> {
234254 /// Represents individual aggregated measurements with unique attributes.
235255 pub ( crate ) data_points : Vec < SumDataPoint < T > > ,
236256 /// The time when the time series was started.
237- pub start_time : SystemTime ,
257+ pub ( crate ) start_time : SystemTime ,
238258 /// The time when the time series was recorded.
239- pub time : SystemTime ,
259+ pub ( crate ) time : SystemTime ,
240260 /// Describes if the aggregation is reported as the change from the last report
241261 /// time, or the cumulative changes since a fixed start time.
242- pub temporality : Temporality ,
262+ pub ( crate ) temporality : Temporality ,
243263 /// Whether this aggregation only increases or decreases.
244- pub is_monotonic : bool ,
264+ pub ( crate ) is_monotonic : bool ,
245265}
246266
247267impl < T > Sum < T > {
248268 /// Returns an iterator over the [SumDataPoint]s in [Sum].
249269 pub fn data_points ( & self ) -> impl Iterator < Item = & SumDataPoint < T > > {
250270 self . data_points . iter ( )
251271 }
272+
273+ /// Returns the time when the time series was started.
274+ pub fn start_time ( & self ) -> SystemTime {
275+ self . start_time
276+ }
277+
278+ /// Returns the time when the time series was recorded.
279+ pub fn time ( & self ) -> SystemTime {
280+ self . time
281+ }
282+
283+ /// Returns the temporality describing if the aggregation is reported as the change
284+ /// from the last report time, or the cumulative changes since a fixed start time.
285+ pub fn temporality ( & self ) -> Temporality {
286+ self . temporality
287+ }
288+
289+ /// Returns whether this aggregation only increases or decreases.
290+ pub fn is_monotonic ( & self ) -> bool {
291+ self . is_monotonic
292+ }
252293}
253294
254295/// Represents the histogram of all measurements of values from an instrument.
@@ -257,19 +298,35 @@ pub struct Histogram<T> {
257298 /// Individual aggregated measurements with unique attributes.
258299 pub ( crate ) data_points : Vec < HistogramDataPoint < T > > ,
259300 /// The time when the time series was started.
260- pub start_time : SystemTime ,
301+ pub ( crate ) start_time : SystemTime ,
261302 /// The time when the time series was recorded.
262- pub time : SystemTime ,
303+ pub ( crate ) time : SystemTime ,
263304 /// Describes if the aggregation is reported as the change from the last report
264305 /// time, or the cumulative changes since a fixed start time.
265- pub temporality : Temporality ,
306+ pub ( crate ) temporality : Temporality ,
266307}
267308
268309impl < T > Histogram < T > {
269310 /// Returns an iterator over the [HistogramDataPoint]s in [Histogram].
270311 pub fn data_points ( & self ) -> impl Iterator < Item = & HistogramDataPoint < T > > {
271312 self . data_points . iter ( )
272313 }
314+
315+ /// Returns the time when the time series was started.
316+ pub fn start_time ( & self ) -> SystemTime {
317+ self . start_time
318+ }
319+
320+ /// Returns the time when the time series was recorded.
321+ pub fn time ( & self ) -> SystemTime {
322+ self . time
323+ }
324+
325+ /// Returns the temporality describing if the aggregation is reported as the change
326+ /// from the last report time, or the cumulative changes since a fixed start time.
327+ pub fn temporality ( & self ) -> Temporality {
328+ self . temporality
329+ }
273330}
274331
275332/// A single histogram data point in a time series.
@@ -278,7 +335,7 @@ pub struct HistogramDataPoint<T> {
278335 /// The set of key value pairs that uniquely identify the time series.
279336 pub ( crate ) attributes : Vec < KeyValue > ,
280337 /// The number of updates this histogram has been calculated with.
281- pub count : u64 ,
338+ pub ( crate ) count : u64 ,
282339 /// The upper bounds of the buckets of the histogram.
283340 ///
284341 /// Because the last boundary is +infinity this one is implied.
@@ -287,11 +344,11 @@ pub struct HistogramDataPoint<T> {
287344 pub ( crate ) bucket_counts : Vec < u64 > ,
288345
289346 /// The minimum value recorded.
290- pub min : Option < T > ,
347+ pub ( crate ) min : Option < T > ,
291348 /// The maximum value recorded.
292- pub max : Option < T > ,
349+ pub ( crate ) max : Option < T > ,
293350 /// The sum of the values recorded.
294- pub sum : T ,
351+ pub ( crate ) sum : T ,
295352
296353 /// The sampled [Exemplar]s collected during the time series.
297354 pub ( crate ) exemplars : Vec < Exemplar < T > > ,
@@ -317,6 +374,26 @@ impl<T> HistogramDataPoint<T> {
317374 pub fn bucket_counts ( & self ) -> impl Iterator < Item = u64 > + ' _ {
318375 self . bucket_counts . iter ( ) . copied ( )
319376 }
377+
378+ /// Returns the number of updates this histogram has been calculated with.
379+ pub fn count ( & self ) -> u64 {
380+ self . count
381+ }
382+
383+ /// Returns the minimum value recorded.
384+ pub fn min ( & self ) -> Option < & T > {
385+ self . min . as_ref ( )
386+ }
387+
388+ /// Returns the maximum value recorded.
389+ pub fn max ( & self ) -> Option < & T > {
390+ self . max . as_ref ( )
391+ }
392+
393+ /// Returns the sum of the values recorded.
394+ pub fn sum ( & self ) -> & T {
395+ & self . sum
396+ }
320397}
321398
322399/// The histogram of all measurements of values from an instrument.
@@ -325,19 +402,35 @@ pub struct ExponentialHistogram<T> {
325402 /// The individual aggregated measurements with unique attributes.
326403 pub ( crate ) data_points : Vec < ExponentialHistogramDataPoint < T > > ,
327404 /// When the time series was started.
328- pub start_time : SystemTime ,
405+ pub ( crate ) start_time : SystemTime ,
329406 /// The time when the time series was recorded.
330- pub time : SystemTime ,
407+ pub ( crate ) time : SystemTime ,
331408 /// Describes if the aggregation is reported as the change from the last report
332409 /// time, or the cumulative changes since a fixed start time.
333- pub temporality : Temporality ,
410+ pub ( crate ) temporality : Temporality ,
334411}
335412
336413impl < T > ExponentialHistogram < T > {
337414 /// Returns an iterator over the [ExponentialHistogramDataPoint]s in [ExponentialHistogram].
338415 pub fn data_points ( & self ) -> impl Iterator < Item = & ExponentialHistogramDataPoint < T > > {
339416 self . data_points . iter ( )
340417 }
418+
419+ /// Returns the time when the time series was started.
420+ pub fn start_time ( & self ) -> SystemTime {
421+ self . start_time
422+ }
423+
424+ /// Returns the time when the time series was recorded.
425+ pub fn time ( & self ) -> SystemTime {
426+ self . time
427+ }
428+
429+ /// Returns the temporality describing if the aggregation is reported as the change
430+ /// from the last report time, or the cumulative changes since a fixed start time.
431+ pub fn temporality ( & self ) -> Temporality {
432+ self . temporality
433+ }
341434}
342435
343436/// A single exponential histogram data point in a time series.
@@ -347,39 +440,39 @@ pub struct ExponentialHistogramDataPoint<T> {
347440 pub ( crate ) attributes : Vec < KeyValue > ,
348441
349442 /// The number of updates this histogram has been calculated with.
350- pub count : usize ,
443+ pub ( crate ) count : usize ,
351444 /// The minimum value recorded.
352- pub min : Option < T > ,
445+ pub ( crate ) min : Option < T > ,
353446 /// The maximum value recorded.
354- pub max : Option < T > ,
447+ pub ( crate ) max : Option < T > ,
355448 /// The sum of the values recorded.
356- pub sum : T ,
449+ pub ( crate ) sum : T ,
357450
358451 /// Describes the resolution of the histogram.
359452 ///
360453 /// Boundaries are located at powers of the base, where:
361454 ///
362455 /// base = 2 ^ (2 ^ -scale)
363- pub scale : i8 ,
456+ pub ( crate ) scale : i8 ,
364457
365458 /// The number of values whose absolute value is less than or equal to
366459 /// `zero_threshold`.
367460 ///
368461 /// When `zero_threshold` is `0`, this is the number of values that cannot be
369462 /// expressed using the standard exponential formula as well as values that have
370463 /// been rounded to zero.
371- pub zero_count : u64 ,
464+ pub ( crate ) zero_count : u64 ,
372465
373466 /// The range of positive value bucket counts.
374- pub positive_bucket : ExponentialBucket ,
467+ pub ( crate ) positive_bucket : ExponentialBucket ,
375468 /// The range of negative value bucket counts.
376- pub negative_bucket : ExponentialBucket ,
469+ pub ( crate ) negative_bucket : ExponentialBucket ,
377470
378471 /// The width of the zero region.
379472 ///
380473 /// Where the zero region is defined as the closed interval
381474 /// [-zero_threshold, zero_threshold].
382- pub zero_threshold : f64 ,
475+ pub ( crate ) zero_threshold : f64 ,
383476
384477 /// The sampled exemplars collected during the time series.
385478 pub ( crate ) exemplars : Vec < Exemplar < T > > ,
@@ -395,19 +488,76 @@ impl<T> ExponentialHistogramDataPoint<T> {
395488 pub fn exemplars ( & self ) -> impl Iterator < Item = & Exemplar < T > > {
396489 self . exemplars . iter ( )
397490 }
491+
492+ /// Returns the number of updates this histogram has been calculated with.
493+ pub fn count ( & self ) -> usize {
494+ self . count
495+ }
496+
497+ /// Returns the minimum value recorded.
498+ pub fn min ( & self ) -> Option < & T > {
499+ self . min . as_ref ( )
500+ }
501+
502+ /// Returns the maximum value recorded.
503+ pub fn max ( & self ) -> Option < & T > {
504+ self . max . as_ref ( )
505+ }
506+
507+ /// Returns the sum of the values recorded.
508+ pub fn sum ( & self ) -> & T {
509+ & self . sum
510+ }
511+
512+ /// Returns the resolution of the histogram.
513+ pub fn scale ( & self ) -> i8 {
514+ self . scale
515+ }
516+
517+ /// Returns the number of values whose absolute value is less than or equal to zero_threshold.
518+ pub fn zero_count ( & self ) -> u64 {
519+ self . zero_count
520+ }
521+
522+ /// Returns the range of positive value bucket counts.
523+ pub fn positive_bucket ( & self ) -> & ExponentialBucket {
524+ & self . positive_bucket
525+ }
526+
527+ /// Returns the range of negative value bucket counts.
528+ pub fn negative_bucket ( & self ) -> & ExponentialBucket {
529+ & self . negative_bucket
530+ }
531+
532+ /// Returns the width of the zero region.
533+ pub fn zero_threshold ( & self ) -> f64 {
534+ self . zero_threshold
535+ }
398536}
399537
400538/// A set of bucket counts, encoded in a contiguous array of counts.
401539#[ derive( Debug , Clone , PartialEq ) ]
402540pub struct ExponentialBucket {
403541 /// The bucket index of the first entry in the `counts` vec.
404- pub offset : i32 ,
542+ pub ( crate ) offset : i32 ,
405543
406544 /// A vec where `counts[i]` carries the count of the bucket at index `offset + i`.
407545 ///
408546 /// `counts[i]` is the count of values greater than base^(offset+i) and less than
409547 /// or equal to base^(offset+i+1).
410- pub counts : Vec < u64 > ,
548+ pub ( crate ) counts : Vec < u64 > ,
549+ }
550+
551+ impl ExponentialBucket {
552+ /// Returns the bucket index of the first entry in the counts vec.
553+ pub fn offset ( & self ) -> i32 {
554+ self . offset
555+ }
556+
557+ /// Returns a reference to the counts vec.
558+ pub fn counts ( & self ) -> & [ u64 ] {
559+ & self . counts
560+ }
411561}
412562
413563/// A measurement sampled from a time series providing a typical example.
@@ -435,6 +585,26 @@ impl<T> Exemplar<T> {
435585 pub fn filtered_attributes ( & self ) -> impl Iterator < Item = & KeyValue > {
436586 self . filtered_attributes . iter ( )
437587 }
588+
589+ /// Returns the time when the measurement was recorded.
590+ pub fn time ( & self ) -> SystemTime {
591+ self . time
592+ }
593+
594+ /// Returns the measured value.
595+ pub fn value ( & self ) -> & T {
596+ & self . value
597+ }
598+
599+ /// Returns the ID of the span that was active during the measurement.
600+ pub fn span_id ( & self ) -> & [ u8 ; 8 ] {
601+ & self . span_id
602+ }
603+
604+ /// Returns the ID of the trace the active span belonged to during the measurement.
605+ pub fn trace_id ( & self ) -> & [ u8 ; 16 ] {
606+ & self . trace_id
607+ }
438608}
439609
440610#[ cfg( test) ]
0 commit comments