empiredan commented on code in PR #1258:
URL:
https://github.com/apache/incubator-pegasus/pull/1258#discussion_r1037066643
##########
src/utils/metrics.cpp:
##########
@@ -81,19 +83,115 @@ metric_entity::metric_map metric_entity::metrics() const
return _metrics;
}
-void metric_entity::set_attributes(attr_map &&attrs)
+void metric_entity::set_attributes(const attr_map &attrs)
{
utils::auto_write_lock l(_lock);
- _attrs = std::move(attrs);
+ _attrs = attrs;
}
-metric_entity_ptr metric_entity_prototype::instantiate(const std::string &id,
- metric_entity::attr_map
attrs) const
+void metric_entity::encode_type(metric_json_writer &writer) const
+{
+ writer.Key(kMetricEntityTypeField.c_str());
+ json::json_encode(writer, _prototype->name());
+}
+
+void metric_entity::encode_id(metric_json_writer &writer) const
+{
+ writer.Key(kMetricEntityIdField.c_str());
+ json::json_encode(writer, _id);
+}
+
+/*static*/ void metric_entity::encode_attrs(metric_json_writer &writer, const
attr_map &attrs)
+{
+ // Empty attributes are allowed and will just be encoded as {}.
Review Comment:
This is learned from Kudu metrics. For entity type of `server`, its
attributes are always empty; it will be returned in json format as `{}`:
<img width="656" alt="image"
src="https://user-images.githubusercontent.com/743379/205056320-ea5b0e18-0da4-4957-815f-44ea3f85c335.png">
--
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]