You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pegasus.apache.org by GitBox <gi...@apache.org> on 2022/11/02 09:36:39 UTC
[GitHub] [incubator-pegasus] foreverneverer commented on a diff in pull request #1219: feat(new_metrics): take snapshot of each metric as json format
foreverneverer commented on code in PR #1219:
URL: https://github.com/apache/incubator-pegasus/pull/1219#discussion_r1011470353
##########
src/utils/metrics.h:
##########
@@ -493,6 +518,26 @@ class counter : public metric
return _adder.fetch_and_reset();
}
+ // The snapshot collected has following json format:
+ // {
+ // "name": "<metric_name>",
+ // "value": ...
+ // }
+ // where "name" is the name of the counter in string type, and "value" is just current value
+ // of the counter fetched by `value()`, in integral type (namely int64_t).
+ void take_snapshot(json::JsonWriter &writer) override
+ {
+ writer.StartObject();
+
+ writer.Key("name");
+ json::json_encode(writer, prototype()->name().data());
+
+ writer.Key("value");
+ json::json_encode(writer, value());
+
+ writer.EndObject();
Review Comment:
it's same with `guage`, why not put the `base class`?
--
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: dev-unsubscribe@pegasus.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org