Skip to content

Commit 7731a60

Browse files
authored
Fix observable updown counter aggregation temporality in Geneva exporter (open-telemetry#571)
1 parent cc80daf commit 7731a60

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

exporters/geneva/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build/

exporters/geneva/src/exporter.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ Exporter::Exporter(const ExporterOptions &options)
4747

4848
sdk::metrics::AggregationTemporality Exporter::GetAggregationTemporality(
4949
sdk::metrics::InstrumentType instrument_type) const noexcept {
50-
if (instrument_type == sdk::metrics::InstrumentType::kUpDownCounter)
51-
{
52-
return sdk::metrics::AggregationTemporality::kCumulative;
53-
}
50+
if (instrument_type == sdk::metrics::InstrumentType::kUpDownCounter ||
51+
instrument_type == sdk::metrics::InstrumentType::kObservableUpDownCounter) {
52+
return sdk::metrics::AggregationTemporality::kCumulative;
53+
}
5454
return sdk::metrics::AggregationTemporality::kDelta;
5555
}
5656

exporters/geneva/test/metrics_exporter_test.cc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,4 +379,24 @@ INSTANTIATE_TEST_SUITE_P(GenericMetricsExporterText,
379379
GenericMetricsExporterTextFixture,
380380
::testing::Values(kUnixDomainPathUDS, kUnixDomainPathAbstractSocket));
381381

382+
// Test for GetAggregationTemporality method
383+
TEST(GenevaExporterTest, GetAggregationTemporalityTest) {
384+
ExporterOptions options{"Endpoint=unix:///tmp/test;Account=test;Namespace=test"};
385+
Exporter exporter(options);
386+
387+
// Test that kUpDownCounter returns kCumulative
388+
EXPECT_EQ(exporter.GetAggregationTemporality(InstrumentType::kUpDownCounter),
389+
AggregationTemporality::kCumulative);
390+
391+
// Test that kObservableUpDownCounter returns kCumulative
392+
EXPECT_EQ(exporter.GetAggregationTemporality(InstrumentType::kObservableUpDownCounter),
393+
AggregationTemporality::kCumulative);
394+
395+
// Test that other instrument types return kDelta
396+
EXPECT_EQ(exporter.GetAggregationTemporality(InstrumentType::kCounter),
397+
AggregationTemporality::kDelta);
398+
EXPECT_EQ(exporter.GetAggregationTemporality(InstrumentType::kHistogram),
399+
AggregationTemporality::kDelta);
400+
}
401+
382402
#endif

0 commit comments

Comments
 (0)