From 2accc77af1a7482db2a5246b12a44ca4f799782e Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Thu, 1 Dec 2022 15:32:41 -0800 Subject: [PATCH] Change default temporality as "Cumulative" for OTLP metrics exporters (#1828) --- .../otlp/otlp_grpc_metric_exporter_options.h | 2 +- .../otlp/otlp_http_metric_exporter_options.h | 2 +- .../test/otlp_http_metric_exporter_test.cc | 22 +++++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_options.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_options.h index 3d677c1a08..61828fd49e 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_options.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_options.h @@ -22,7 +22,7 @@ struct OtlpGrpcMetricExporterOptions : public OtlpGrpcExporterOptions // Preferred Aggregation Temporality sdk::metrics::AggregationTemporality aggregation_temporality = - sdk::metrics::AggregationTemporality::kDelta; + sdk::metrics::AggregationTemporality::kCumulative; }; } // namespace otlp diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h index 7fbb000a34..140b5b886b 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h @@ -51,7 +51,7 @@ struct OtlpHttpMetricExporterOptions // Preferred Aggregation Temporality sdk::metrics::AggregationTemporality aggregation_temporality = - sdk::metrics::AggregationTemporality::kDelta; + sdk::metrics::AggregationTemporality::kCumulative; #ifdef ENABLE_ASYNC_EXPORT // Concurrent requests diff --git a/exporters/otlp/test/otlp_http_metric_exporter_test.cc b/exporters/otlp/test/otlp_http_metric_exporter_test.cc index 5dbb4cc2a7..54abb88511 100644 --- a/exporters/otlp/test/otlp_http_metric_exporter_test.cc +++ b/exporters/otlp/test/otlp_http_metric_exporter_test.cc @@ -936,6 +936,28 @@ TEST_F(OtlpHttpMetricExporterTestPeer, DefaultEndpoint) EXPECT_EQ("http://localhost:4318/v1/metrics", GetOtlpDefaultMetricsEndpoint()); } +TEST_F(OtlpHttpMetricExporterTestPeer, CheckDefaultTemporality) +{ + std::unique_ptr exporter(new OtlpHttpMetricExporter()); + EXPECT_EQ( + opentelemetry::sdk::metrics::AggregationTemporality::kCumulative, + exporter->GetAggregationTemporality(opentelemetry::sdk::metrics::InstrumentType::kCounter)); + EXPECT_EQ( + opentelemetry::sdk::metrics::AggregationTemporality::kCumulative, + exporter->GetAggregationTemporality(opentelemetry::sdk::metrics::InstrumentType::kHistogram)); + EXPECT_EQ(opentelemetry::sdk::metrics::AggregationTemporality::kCumulative, + exporter->GetAggregationTemporality( + opentelemetry::sdk::metrics::InstrumentType::kUpDownCounter)); + EXPECT_EQ(opentelemetry::sdk::metrics::AggregationTemporality::kCumulative, + exporter->GetAggregationTemporality( + opentelemetry::sdk::metrics::InstrumentType::kObservableCounter)); + EXPECT_EQ(opentelemetry::sdk::metrics::AggregationTemporality::kCumulative, + exporter->GetAggregationTemporality( + opentelemetry::sdk::metrics::InstrumentType::kObservableGauge)); + EXPECT_EQ(opentelemetry::sdk::metrics::AggregationTemporality::kCumulative, + exporter->GetAggregationTemporality( + opentelemetry::sdk::metrics::InstrumentType::kObservableUpDownCounter)); +} #endif } // namespace otlp