Skip to content

Commit

Permalink
Merge branch 'main' into fixes_2446
Browse files Browse the repository at this point in the history
  • Loading branch information
marcalff authored Dec 22, 2023
2 parents c5f3ad5 + 0dd5eed commit 25a2d19
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class OtlpMetricUtils
{
public:
static opentelemetry::sdk::metrics::AggregationType GetAggregationType(
const opentelemetry::sdk::metrics::InstrumentType &instrument_type) noexcept;
const opentelemetry::sdk::metrics::MetricData &metric_data) noexcept;

static proto::metrics::v1::AggregationTemporality GetProtoAggregationTemporality(
const opentelemetry::sdk::metrics::AggregationTemporality &aggregation_temporality) noexcept;
Expand Down
21 changes: 12 additions & 9 deletions exporters/otlp/src/otlp_metric_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,24 @@ proto::metrics::v1::AggregationTemporality OtlpMetricUtils::GetProtoAggregationT
}

metric_sdk::AggregationType OtlpMetricUtils::GetAggregationType(
const opentelemetry::sdk::metrics::InstrumentType &instrument_type) noexcept
const opentelemetry::sdk::metrics::MetricData &metric_data) noexcept
{

if (instrument_type == metric_sdk::InstrumentType::kCounter ||
instrument_type == metric_sdk::InstrumentType::kUpDownCounter ||
instrument_type == metric_sdk::InstrumentType::kObservableCounter ||
instrument_type == metric_sdk::InstrumentType::kObservableUpDownCounter)
if (metric_data.point_data_attr_.size() == 0)
{
return metric_sdk::AggregationType::kDrop;
}
auto point_data_with_attributes = metric_data.point_data_attr_[0];
if (nostd::holds_alternative<sdk::metrics::SumPointData>(point_data_with_attributes.point_data))
{
return metric_sdk::AggregationType::kSum;
}
else if (instrument_type == metric_sdk::InstrumentType::kHistogram)
else if (nostd::holds_alternative<sdk::metrics::HistogramPointData>(
point_data_with_attributes.point_data))
{
return metric_sdk::AggregationType::kHistogram;
}
else if (instrument_type == metric_sdk::InstrumentType::kObservableGauge)
else if (nostd::holds_alternative<sdk::metrics::LastValuePointData>(
point_data_with_attributes.point_data))
{
return metric_sdk::AggregationType::kLastValue;
}
Expand Down Expand Up @@ -188,7 +191,7 @@ void OtlpMetricUtils::PopulateInstrumentInfoMetrics(
metric->set_name(metric_data.instrument_descriptor.name_);
metric->set_description(metric_data.instrument_descriptor.description_);
metric->set_unit(metric_data.instrument_descriptor.unit_);
auto kind = GetAggregationType(metric_data.instrument_descriptor.type_);
auto kind = GetAggregationType(metric_data);
switch (kind)
{
case metric_sdk::AggregationType::kSum: {
Expand Down

0 comments on commit 25a2d19

Please sign in to comment.