empiredan commented on code in PR #1304:
URL:
https://github.com/apache/incubator-pegasus/pull/1304#discussion_r1066560021
##########
src/utils/metrics.cpp:
##########
@@ -383,15 +547,134 @@ metric_entity_ptr
metric_registry::find_or_create_entity(const metric_entity_pro
return entity;
}
+metric_registry::collected_old_entities_info
metric_registry::collect_old_metrics() const
+{
+ collected_old_entities_info entities_info;
+
+ utils::auto_read_lock l(_lock);
+
+ for (const auto &entity : _entities) {
+ const auto &metrics_info = entity.second->collect_old_metrics();
+
+ entities_info.num_all_metrics += metrics_info.num_all_metrics;
+ entities_info.num_scheduled_metrics +=
metrics_info.num_scheduled_metrics;
+ if (!metrics_info.old_metrics.empty()) {
+ // Those entities which have metrics that should be retired will
be collected.
+ entities_info.old_entities.emplace(entity.first,
std::move(metrics_info.old_metrics));
+ continue;
+ }
+
+ if (!entity.second->is_stale()) {
+ continue;
+ }
+
+ // Since this entity itself should be retired, it will be collected
without any
+ // metric. Actually it has already not had any metric itself.
+ (void)entities_info.old_entities[entity.first];
+ }
+
+ entities_info.num_all_entities = _entities.size();
+ return entities_info;
+}
+
+metric_registry::retired_entities_stat
+metric_registry::retire_old_metrics(const old_entity_map &old_entities)
+{
+ if (old_entities.empty()) {
Review Comment:
Actually the variable that `old_entities` references is a local constant in
`process_old_metrics()`, which cannot be mutated and is also not shared by
other threads.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]