Skip to content

Commit

Permalink
agents: don't use {} for class constructor
Browse files Browse the repository at this point in the history
Fix initialization of SumPointData and LastValuePointData by explicitly
setting value_ field after object creation.

The previous way of populating the class fields using {} caused a
compiler error. So instead explicitly assign the field after the class
has been created.
  • Loading branch information
trevnorris committed Sep 19, 2024
1 parent 0b5426c commit 6eb4e18
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions agents/otlp/src/otlp_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ static void add_counter(std::vector<MetricData>& metrics,
InstrumentValueType type,
ValueType value,
PointAttributes attrs = {}) {
SumPointData sum_point_data{ value };
SumPointData sum_point_data;
sum_point_data.value_ = value;
MetricData metric_data{
InstrumentDescriptor{ name, "", unit, InstrumentType::kCounter, type},
AggregationTemporality::kCumulative,
Expand All @@ -92,7 +93,8 @@ static void add_gauge(std::vector<MetricData>& metrics,
InstrumentValueType type,
ValueType value,
PointAttributes attrs = {}) {
opentelemetry::sdk::metrics::LastValuePointData lv_point_data{ value };
opentelemetry::sdk::metrics::LastValuePointData lv_point_data;
lv_point_data.value_ = value;
MetricData metric_data{
InstrumentDescriptor{
name, "", unit, InstrumentType::kObservableGauge, type },
Expand Down

0 comments on commit 6eb4e18

Please sign in to comment.