Skip to content

Commit 402351a

Browse files
committed
revert simple nums
1 parent 10f4f8c commit 402351a

File tree

3 files changed

+37
-72
lines changed

3 files changed

+37
-72
lines changed

opentelemetry-proto/src/transform/metrics.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,10 @@ pub mod tonic {
215215
.data_points()
216216
.map(|dp| TonicHistogramDataPoint {
217217
attributes: dp.attributes().map(Into::into).collect(),
218-
start_time_unix_nano: to_nanos(hist.start_time),
219-
time_unix_nano: to_nanos(hist.time),
220-
count: dp.count,
221-
sum: Some(dp.sum.into_f64()),
218+
start_time_unix_nano: to_nanos(hist.start_time()),
219+
time_unix_nano: to_nanos(hist.time()),
220+
count: dp.count(),
221+
sum: Some(dp.sum().into_f64()),
222222
bucket_counts: dp.bucket_counts().collect(),
223223
explicit_bounds: dp.bounds().collect(),
224224
exemplars: dp.exemplars().map(Into::into).collect(),
@@ -227,7 +227,7 @@ pub mod tonic {
227227
max: dp.max.map(Numeric::into_f64),
228228
})
229229
.collect(),
230-
aggregation_temporality: TonicTemporality::from(hist.temporality).into(),
230+
aggregation_temporality: TonicTemporality::from(hist.temporality()).into(),
231231
}
232232
}
233233
}
@@ -242,28 +242,28 @@ pub mod tonic {
242242
.data_points()
243243
.map(|dp| TonicExponentialHistogramDataPoint {
244244
attributes: dp.attributes().map(Into::into).collect(),
245-
start_time_unix_nano: to_nanos(hist.start_time),
246-
time_unix_nano: to_nanos(hist.time),
247-
count: dp.count as u64,
248-
sum: Some(dp.sum.into_f64()),
249-
scale: dp.scale.into(),
250-
zero_count: dp.zero_count,
245+
start_time_unix_nano: to_nanos(hist.start_time()),
246+
time_unix_nano: to_nanos(hist.time()),
247+
count: dp.count() as u64,
248+
sum: Some(dp.sum().into_f64()),
249+
scale: dp.scale().into(),
250+
zero_count: dp.zero_count(),
251251
positive: Some(TonicBuckets {
252-
offset: dp.positive_bucket.offset,
253-
bucket_counts: dp.positive_bucket.counts.clone(),
252+
offset: dp.positive_bucket().offset(),
253+
bucket_counts: dp.positive_bucket().counts().iter().copied().collect(),
254254
}),
255255
negative: Some(TonicBuckets {
256-
offset: dp.negative_bucket.offset,
257-
bucket_counts: dp.negative_bucket.counts.clone(),
256+
offset: dp.negative_bucket().offset(),
257+
bucket_counts: dp.negative_bucket().counts().iter().copied().collect(),
258258
}),
259259
flags: TonicDataPointFlags::default() as u32,
260260
exemplars: dp.exemplars().map(Into::into).collect(),
261261
min: dp.min.map(Numeric::into_f64),
262262
max: dp.max.map(Numeric::into_f64),
263-
zero_threshold: dp.zero_threshold,
263+
zero_threshold: dp.zero_threshold(),
264264
})
265265
.collect(),
266-
aggregation_temporality: TonicTemporality::from(hist.temporality).into(),
266+
aggregation_temporality: TonicTemporality::from(hist.temporality()).into(),
267267
}
268268
}
269269
}
@@ -278,15 +278,15 @@ pub mod tonic {
278278
.data_points()
279279
.map(|dp| TonicNumberDataPoint {
280280
attributes: dp.attributes().map(Into::into).collect(),
281-
start_time_unix_nano: to_nanos(sum.start_time),
282-
time_unix_nano: to_nanos(sum.time),
281+
start_time_unix_nano: to_nanos(sum.start_time()),
282+
time_unix_nano: to_nanos(sum.time()),
283283
exemplars: dp.exemplars().map(Into::into).collect(),
284284
flags: TonicDataPointFlags::default() as u32,
285285
value: Some(dp.value.into()),
286286
})
287287
.collect(),
288-
aggregation_temporality: TonicTemporality::from(sum.temporality).into(),
289-
is_monotonic: sum.is_monotonic,
288+
aggregation_temporality: TonicTemporality::from(sum.temporality()).into(),
289+
is_monotonic: sum.is_monotonic(),
290290
}
291291
}
292292
}
@@ -301,8 +301,8 @@ pub mod tonic {
301301
.data_points()
302302
.map(|dp| TonicNumberDataPoint {
303303
attributes: dp.attributes().map(Into::into).collect(),
304-
start_time_unix_nano: gauge.start_time.map(to_nanos).unwrap_or_default(),
305-
time_unix_nano: to_nanos(gauge.time),
304+
start_time_unix_nano: gauge.start_time().map(to_nanos).unwrap_or_default(),
305+
time_unix_nano: to_nanos(gauge.time()),
306306
exemplars: dp.exemplars().map(Into::into).collect(),
307307
flags: TonicDataPointFlags::default() as u32,
308308
value: Some(dp.value.into()),
@@ -322,9 +322,9 @@ pub mod tonic {
322322
.filtered_attributes()
323323
.map(|kv| (&kv.key, &kv.value).into())
324324
.collect(),
325-
time_unix_nano: to_nanos(ex.time),
326-
span_id: ex.span_id.into(),
327-
trace_id: ex.trace_id.into(),
325+
time_unix_nano: to_nanos(ex.time()),
326+
span_id: ex.span_id().into(),
327+
trace_id: ex.trace_id().into(),
328328
value: Some(ex.value.into()),
329329
}
330330
}

opentelemetry-sdk/src/metrics/data/mod.rs

Lines changed: 7 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ pub struct GaugeDataPoint<T> {
169169
/// time series.
170170
pub(crate) attributes: Vec<KeyValue>,
171171
/// The value of this data point.
172-
pub(crate) value: T,
172+
pub value: T,
173173
/// The sampled [Exemplar]s collected during the time series.
174174
pub(crate) exemplars: Vec<Exemplar<T>>,
175175
}
@@ -184,11 +184,6 @@ 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-
}
192187
}
193188

194189
/// A measurement of the current value of an instrument.
@@ -226,7 +221,7 @@ pub struct SumDataPoint<T> {
226221
/// time series.
227222
pub(crate) attributes: Vec<KeyValue>,
228223
/// The value of this data point.
229-
pub(crate) value: T,
224+
pub value: T,
230225
/// The sampled [Exemplar]s collected during the time series.
231226
pub(crate) exemplars: Vec<Exemplar<T>>,
232227
}
@@ -241,11 +236,6 @@ impl<T> SumDataPoint<T> {
241236
pub fn exemplars(&self) -> impl Iterator<Item = &Exemplar<T>> {
242237
self.exemplars.iter()
243238
}
244-
245-
/// Returns the value of this data point.
246-
pub fn value(&self) -> &T {
247-
&self.value
248-
}
249239
}
250240

251241
/// Represents the sum of all measurements of values from an instrument.
@@ -344,9 +334,9 @@ pub struct HistogramDataPoint<T> {
344334
pub(crate) bucket_counts: Vec<u64>,
345335

346336
/// The minimum value recorded.
347-
pub(crate) min: Option<T>,
337+
pub min: Option<T>,
348338
/// The maximum value recorded.
349-
pub(crate) max: Option<T>,
339+
pub max: Option<T>,
350340
/// The sum of the values recorded.
351341
pub(crate) sum: T,
352342

@@ -380,16 +370,6 @@ impl<T> HistogramDataPoint<T> {
380370
self.count
381371
}
382372

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-
393373
/// Returns the sum of the values recorded.
394374
pub fn sum(&self) -> &T {
395375
&self.sum
@@ -442,9 +422,9 @@ pub struct ExponentialHistogramDataPoint<T> {
442422
/// The number of updates this histogram has been calculated with.
443423
pub(crate) count: usize,
444424
/// The minimum value recorded.
445-
pub(crate) min: Option<T>,
425+
pub min: Option<T>,
446426
/// The maximum value recorded.
447-
pub(crate) max: Option<T>,
427+
pub max: Option<T>,
448428
/// The sum of the values recorded.
449429
pub(crate) sum: T,
450430

@@ -494,16 +474,6 @@ impl<T> ExponentialHistogramDataPoint<T> {
494474
self.count
495475
}
496476

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-
507477
/// Returns the sum of the values recorded.
508478
pub fn sum(&self) -> &T {
509479
&self.sum
@@ -569,7 +539,7 @@ pub struct Exemplar<T> {
569539
/// The time when the measurement was recorded.
570540
pub(crate) time: SystemTime,
571541
/// The measured value.
572-
pub(crate) value: T,
542+
pub value: T,
573543
/// The ID of the span that was active during the measurement.
574544
///
575545
/// If no span was active or the span was not sampled this will be empty.
@@ -591,11 +561,6 @@ impl<T> Exemplar<T> {
591561
self.time
592562
}
593563

594-
/// Returns the measured value.
595-
pub fn value(&self) -> &T {
596-
&self.value
597-
}
598-
599564
/// Returns the ID of the span that was active during the measurement.
600565
pub fn span_id(&self) -> &[u8; 8] {
601566
&self.span_id

opentelemetry-stdout/src/metrics/exporter.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ fn print_sum_data_points<'a, T: Debug + 'a>(
198198
) {
199199
for (i, data_point) in data_points.enumerate() {
200200
println!("\t\tDataPoint #{}", i);
201-
println!("\t\t\tValue : {:#?}", data_point.value());
201+
println!("\t\t\tValue : {:#?}", data_point.value);
202202
println!("\t\t\tAttributes :");
203203
for kv in data_point.attributes() {
204204
println!("\t\t\t\t -> {}: {}", kv.key, kv.value.as_str());
@@ -211,7 +211,7 @@ fn print_gauge_data_points<'a, T: Debug + 'a>(
211211
) {
212212
for (i, data_point) in data_points.enumerate() {
213213
println!("\t\tDataPoint #{}", i);
214-
println!("\t\t\tValue : {:#?}", data_point.value());
214+
println!("\t\t\tValue : {:#?}", data_point.value);
215215
println!("\t\t\tAttributes :");
216216
for kv in data_point.attributes() {
217217
println!("\t\t\t\t -> {}: {}", kv.key, kv.value.as_str());
@@ -226,11 +226,11 @@ fn print_hist_data_points<'a, T: Debug + 'a>(
226226
println!("\t\tDataPoint #{}", i);
227227
println!("\t\t\tCount : {}", data_point.count());
228228
println!("\t\t\tSum : {:?}", data_point.sum());
229-
if let Some(min) = data_point.min() {
229+
if let Some(min) = &data_point.min {
230230
println!("\t\t\tMin : {:?}", min);
231231
}
232232

233-
if let Some(max) = data_point.max() {
233+
if let Some(max) = &data_point.max {
234234
println!("\t\t\tMax : {:?}", max);
235235
}
236236

0 commit comments

Comments
 (0)