Skip to content

Commit ea151e4

Browse files
committed
Address review comments #1
1 parent ec61467 commit ea151e4

File tree

4 files changed

+31
-18
lines changed

4 files changed

+31
-18
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ pub trait Aggregation: fmt::Debug + any::Any + Send + Sync {
5454
}
5555

5656
/// Allow to access data points of an [Aggregation].
57-
pub trait AggregationDataPoints {
57+
pub(crate) trait AggregationDataPoints {
5858
/// The type of data point in the aggregation.
59-
type Point;
59+
type DataPoint;
6060
/// The data points of the aggregation.
61-
fn points(&mut self) -> &mut Vec<Self::Point>;
61+
fn points(&mut self) -> &mut Vec<Self::DataPoint>;
6262
}
6363

6464
/// DataPoint is a single data point in a time series.
@@ -237,9 +237,9 @@ impl<T: fmt::Debug + Send + Sync + 'static> Aggregation for ExponentialHistogram
237237
}
238238

239239
impl<T> AggregationDataPoints for ExponentialHistogram<T> {
240-
type Point = ExponentialHistogramDataPoint<T>;
240+
type DataPoint = ExponentialHistogramDataPoint<T>;
241241

242-
fn points(&mut self) -> &mut Vec<Self::Point> {
242+
fn points(&mut self) -> &mut Vec<Self::DataPoint> {
243243
&mut self.data_points
244244
}
245245
}

opentelemetry-sdk/src/metrics/internal/aggregate.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,29 +198,29 @@ impl<T: Number> AggregateBuilder<T> {
198198
record_sum: bool,
199199
) -> AggregateFns<T> {
200200
match self.temporality {
201-
Temporality::Delta => ExpoHistogram {
202-
aggregate_collector: Collector::new(
201+
Temporality::Delta => ExpoHistogram::new(
202+
Collector::new(
203203
self.filter.clone(),
204204
DeltaValueMap::new(ExpoHistogramBucketConfig {
205205
max_size: max_size as i32,
206206
max_scale,
207207
}),
208208
),
209-
record_min_max,
210209
record_sum,
211-
}
210+
record_min_max,
211+
)
212212
.into(),
213-
_ => ExpoHistogram {
214-
aggregate_collector: Collector::new(
213+
_ => ExpoHistogram::new(
214+
Collector::new(
215215
self.filter.clone(),
216216
CumulativeValueMap::new(ExpoHistogramBucketConfig {
217217
max_size: max_size as i32,
218218
max_scale,
219219
}),
220220
),
221-
record_min_max,
222221
record_sum,
223-
}
222+
record_min_max,
223+
)
224224
.into(),
225225
}
226226
}

opentelemetry-sdk/src/metrics/internal/collector.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub(crate) trait AggregateCollector: Send + Sync + 'static {
4040
F: FnMut(
4141
Vec<KeyValue>,
4242
&Self::Aggr,
43-
) -> <InitAggregate::Aggr as AggregationDataPoints>::Point;
43+
) -> <InitAggregate::Aggr as AggregationDataPoints>::DataPoint;
4444
}
4545

4646
pub(crate) struct Collector<AM> {
@@ -92,7 +92,10 @@ where
9292
) -> (usize, Option<Box<dyn Aggregation>>)
9393
where
9494
InitAggregate: InitAggregationData,
95-
F: FnMut(Vec<KeyValue>, &AM::Aggr) -> <InitAggregate::Aggr as AggregationDataPoints>::Point,
95+
F: FnMut(
96+
Vec<KeyValue>,
97+
&AM::Aggr,
98+
) -> <InitAggregate::Aggr as AggregationDataPoints>::DataPoint,
9699
{
97100
let time = self.init_time();
98101
let s_data = dest.and_then(|d| d.as_mut().downcast_mut::<InitAggregate::Aggr>());

opentelemetry-sdk/src/metrics/internal/exponential_histogram.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,19 @@ pub(crate) struct ExpoHistogramBucketConfig {
349349
/// Each histogram is scoped by attributes and the aggregation cycle the
350350
/// measurements were made in.
351351
pub(crate) struct ExpoHistogram<AC> {
352-
pub(crate) aggregate_collector: AC,
353-
pub(crate) record_sum: bool,
354-
pub(crate) record_min_max: bool,
352+
aggregate_collector: AC,
353+
record_sum: bool,
354+
record_min_max: bool,
355+
}
356+
357+
impl<AC> ExpoHistogram<AC> {
358+
pub(crate) fn new(aggregate_collector: AC, record_sum: bool, record_min_max: bool) -> Self {
359+
Self {
360+
aggregate_collector,
361+
record_sum,
362+
record_min_max,
363+
}
364+
}
355365
}
356366

357367
impl<AC, T> Measure<T> for ExpoHistogram<AC>

0 commit comments

Comments
 (0)