Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor metrics handling optimizations #1890

Merged
merged 2 commits into from
Jan 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions sdk/src/metrics/state/metric_collector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@ bool MetricCollector::Collect(
ResourceMetrics resource_metrics;
meter_context_->ForEachMeter([&](std::shared_ptr<Meter> meter) noexcept {
auto collection_ts = std::chrono::system_clock::now();
ScopeMetrics scope_metrics;
scope_metrics.metric_data_ = meter->Collect(this, collection_ts);
scope_metrics.scope_ = meter->GetInstrumentationScope();
resource_metrics.scope_metric_data_.push_back(scope_metrics);
auto metric_data = meter->Collect(this, collection_ts);
if (!metric_data.empty())
{
ScopeMetrics scope_metrics;
scope_metrics.metric_data_ = std::move(metric_data);
scope_metrics.scope_ = meter->GetInstrumentationScope();
resource_metrics.scope_metric_data_.emplace_back(std::move(scope_metrics));
}
return true;
});
resource_metrics.resource_ = &meter_context_->GetResource();
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/metrics/state/temporal_metric_storage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ bool TemporalMetricStorage::buildMetrics(CollectorHandle *collector,
PointDataAttributes point_data_attr;
point_data_attr.point_data = aggregation.ToPoint();
point_data_attr.attributes = attributes;
metric_data.point_data_attr_.push_back(point_data_attr);
metric_data.point_data_attr_.emplace_back(std::move(point_data_attr));
return true;
});
return callback(metric_data);
Expand Down