empiredan commented on code in PR #1219:
URL: 
https://github.com/apache/incubator-pegasus/pull/1219#discussion_r1011499800


##########
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`?
   
   The reason is that `value()` is not an abstract method of the base class. 
For example, the percentile type does not need a `value()` method, since each 
has multiple values.



-- 
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]

Reply via email to