Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant generic argument from Aggregator #2269

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions opentelemetry-sdk/src/metrics/internal/histogram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct HistogramTracker<T> {
buckets: Mutex<Buckets<T>>,
}

impl<T> Aggregator<T> for HistogramTracker<T>
impl<T> Aggregator for HistogramTracker<T>
where
T: Number,
{
Expand Down Expand Up @@ -88,7 +88,7 @@ impl<T: Number> Buckets<T> {
/// Summarizes a set of measurements as a histogram with explicitly defined
/// buckets.
pub(crate) struct Histogram<T: Number> {
value_map: ValueMap<T, HistogramTracker<T>>,
value_map: ValueMap<HistogramTracker<T>>,
bounds: Vec<f64>,
record_min_max: bool,
record_sum: bool,
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-sdk/src/metrics/internal/last_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ where
pub(crate) value: T::AtomicTracker,
}

impl<T> Aggregator<T> for Assign<T>
impl<T> Aggregator for Assign<T>
where
T: Number,
{
Expand All @@ -37,7 +37,7 @@ where

/// Summarizes a set of measurements as the last one made.
pub(crate) struct LastValue<T: Number> {
value_map: ValueMap<T, Assign<T>>,
value_map: ValueMap<Assign<T>>,
start: Mutex<SystemTime>,
}

Expand Down
15 changes: 5 additions & 10 deletions opentelemetry-sdk/src/metrics/internal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ use crate::metrics::AttributeSet;
pub(crate) static STREAM_OVERFLOW_ATTRIBUTES: Lazy<Vec<KeyValue>> =
Lazy::new(|| vec![KeyValue::new("otel.metric.overflow", "true")]);

pub(crate) trait Aggregator<T>
where
T: Number,
{
pub(crate) trait Aggregator {
/// A static configuration that is needed in order to initialize aggregator.
/// E.g. bucket_size at creation time .
type InitConfig;
Expand All @@ -46,10 +43,9 @@ where
///
/// This structure is parametrized by an `Operation` that indicates how
/// updates to the underlying value trackers should be performed.
pub(crate) struct ValueMap<T, A>
pub(crate) struct ValueMap<A>
where
T: Number,
A: Aggregator<T>,
A: Aggregator,
{
/// Trackers store the values associated with different attribute sets.
trackers: RwLock<HashMap<Vec<KeyValue>, Arc<A>>>,
Expand All @@ -63,10 +59,9 @@ where
config: A::InitConfig,
}

impl<T, A> ValueMap<T, A>
impl<A> ValueMap<A>
where
T: Number,
A: Aggregator<T>,
A: Aggregator,
{
fn new(config: A::InitConfig) -> Self {
ValueMap {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::{

/// Summarizes a set of pre-computed sums as their arithmetic sum.
pub(crate) struct PrecomputedSum<T: Number> {
value_map: ValueMap<T, Assign<T>>,
value_map: ValueMap<Assign<T>>,
monotonic: bool,
start: Mutex<SystemTime>,
reported: Mutex<HashMap<Vec<KeyValue>, T>>,
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-sdk/src/metrics/internal/sum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ where
value: T::AtomicTracker,
}

impl<T> Aggregator<T> for Increment<T>
impl<T> Aggregator for Increment<T>
where
T: Number,
{
Expand All @@ -37,7 +37,7 @@ where

/// Summarizes a set of measurements made as their arithmetic sum.
pub(crate) struct Sum<T: Number> {
value_map: ValueMap<T, Increment<T>>,
value_map: ValueMap<Increment<T>>,
monotonic: bool,
start: Mutex<SystemTime>,
}
Expand Down
Loading