Skip to content

Commit

Permalink
fix review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lalitb committed May 2, 2022
1 parent 2dda99a commit 77d344a
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions sdk/src/metrics/state/temporal_metric_storage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,23 @@ bool TemporalMetricStorage::buildMetrics(CollectorHandle *collector,
std::unique_ptr<AttributesHashMap> merged_metrics(new AttributesHashMap);
for (auto &agg_hashmap : unreported_list)
{
agg_hashmap->GetAllEnteries([&merged_metrics, this](const MetricAttributes &attributes,
Aggregation &aggregation) {
auto agg = merged_metrics->Get(attributes);
if (agg)
{
merged_metrics->Set(attributes, std::move(agg->Merge(aggregation)));
}
else
{
merged_metrics->Set(
attributes,
std::move(
DefaultAggregation::CreateAggregation(instrument_descriptor_)->Merge(aggregation)));
merged_metrics->GetAllEnteries(
[](const MetricAttributes &attr, Aggregation &aggr) { return true; });
}
return true;
});
agg_hashmap->GetAllEnteries(
[&merged_metrics, this](const MetricAttributes &attributes, Aggregation &aggregation) {
auto agg = merged_metrics->Get(attributes);
if (agg)
{
merged_metrics->Set(attributes, std::move(agg->Merge(aggregation)));
}
else
{
merged_metrics->Set(
attributes,
DefaultAggregation::CreateAggregation(instrument_descriptor_)->Merge(aggregation));
merged_metrics->GetAllEnteries(
[](const MetricAttributes &attr, Aggregation &aggr) { return true; });
}
return true;
});
}
// Get the last reported metrics for the `collector` from `last reported metrics` stash
// - If the aggregation_temporarily for the collector is cumulative
Expand Down Expand Up @@ -123,8 +122,6 @@ bool TemporalMetricStorage::buildMetrics(CollectorHandle *collector,
return true;
});
return callback(metric_data);

return true;
}

} // namespace metrics
Expand Down

0 comments on commit 77d344a

Please sign in to comment.