Skip to content

Commit d87fc75

Browse files
cijothomaslzchen
andauthored
Fix temporarlity and aggregation for usereventexporter (#1287)
Co-authored-by: Leighton Chen <[email protected]>
1 parent df2551b commit d87fc75

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

opentelemetry-user-events-metrics/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
- Fix aggregation selector and temporality so every instruments are aggregated
6+
correctly with expected delta temporality.
7+
[#1287](https://github.com/open-telemetry/opentelemetry-rust/pull/1287).
8+
59
### Changed
610

711
- Include error diagnosing messages for registering tracepoint

opentelemetry-user-events-metrics/src/exporter/mod.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use opentelemetry::metrics::{MetricsError, Result};
44
use opentelemetry_sdk::metrics::{
55
data::{ResourceMetrics, Temporality},
66
exporter::PushMetricsExporter,
7-
reader::{AggregationSelector, TemporalitySelector},
7+
reader::{AggregationSelector, DefaultAggregationSelector, TemporalitySelector},
88
Aggregation, InstrumentKind,
99
};
1010

@@ -37,8 +37,8 @@ impl Default for MetricsExporter {
3737
}
3838

3939
impl TemporalitySelector for MetricsExporter {
40+
// This is matching OTLP exporters delta.
4041
fn temporality(&self, kind: InstrumentKind) -> Temporality {
41-
// TODO: Implement temporality selection feature
4242
match kind {
4343
InstrumentKind::Counter
4444
| InstrumentKind::ObservableCounter
@@ -52,9 +52,10 @@ impl TemporalitySelector for MetricsExporter {
5252
}
5353

5454
impl AggregationSelector for MetricsExporter {
55-
fn aggregation(&self, _kind: InstrumentKind) -> Aggregation {
56-
// TODO: Implement aggregation selection feature
57-
Aggregation::Sum
55+
// TODO: this should ideally be done at SDK level by default
56+
// without exporters having to do it.
57+
fn aggregation(&self, kind: InstrumentKind) -> Aggregation {
58+
DefaultAggregationSelector::new().aggregation(kind)
5859
}
5960
}
6061

0 commit comments

Comments
 (0)