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/11 08:55:43 UTC

[GitHub] [incubator-pegasus] acelyc111 commented on a diff in pull request #1237: feat(new_metrics): support filters for selected metric fields in response

acelyc111 commented on code in PR #1237:
URL: https://github.com/apache/incubator-pegasus/pull/1237#discussion_r1019997370


##########
src/utils/metrics.h:
##########
@@ -131,6 +132,61 @@
 
 namespace dsn {
 
+using metric_fields_type = std::unordered_set<std::string>;
+
+// This struct includes a set of filters for both entities and metrics requested by client.
+struct metric_filters
+{
+    using fields_filter_fn = std::function<bool(const std::string &)>;
+
+    // According to the parameters requested by client, this function will filter metric
+    // fields that will be put in the response. `with_metric_fields` includes all the metric
+    // fields that are wanted by client; on the contrary, once client wants all except some
+    // metric fields, it could specify them in `without_metric_fields`.

Review Comment:
   Since there are dozens of metrics, what's the use case of specify 'without_metric_fields'?



##########
src/utils/metrics.h:
##########
@@ -736,20 +826,18 @@ class percentile : public closeable_metric
     // where "name" is the name of the percentile in string type, with each configured kth
     // percentile followed, such as "p50", "p90", "p95", etc. All of them are in numeric types
     // (i.e. integral or floating-point type, determined by `value_type`).
-    void take_snapshot(json::JsonWriter &writer) override
+    void take_snapshot(json::JsonWriter &writer, const metric_filters &filters) override
     {
         writer.StartObject();
 
-        writer.Key("name");
-        json::json_encode(writer, prototype()->name().data());
+        encode_name(writer, filters);
 
         for (size_t i = 0; i < static_cast<size_t>(kth_percentile_type::COUNT); ++i) {

Review Comment:
   can it skip the loop?



##########
src/utils/metrics.h:
##########
@@ -405,15 +498,12 @@ class gauge : public metric
     // where "name" is the name of the gauge in string type, and "value" is just current value
     // of the gauge fetched by `value()`, in numeric types (i.e. integral or floating-point type,
     // determined by `value_type`).
-    void take_snapshot(json::JsonWriter &writer) override
+    void take_snapshot(json::JsonWriter &writer, const metric_filters &filters) override
     {
         writer.StartObject();
 
-        writer.Key("name");
-        json::json_encode(writer, prototype()->name().data());
-
-        writer.Key("value");
-        json::json_encode(writer, value());
+        encode_name(writer, filters);

Review Comment:
   if the result has been filtered, is the output like:
   ```
   {
   }
   ```
   rather than:
   ```
   ```



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