You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pegasus.apache.org by "empiredan (via GitHub)" <gi...@apache.org> on 2024/01/03 12:24:33 UTC

[PR] feat(new_metrics): add some basic fields to the response to metrics query [incubator-pegasus]

empiredan opened a new pull request, #1827:
URL: https://github.com/apache/incubator-pegasus/pull/1827

   https://github.com/apache/incubator-pegasus/issues/1820


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


Re: [PR] feat(new_metrics): add some basic fields to the response to metrics query [incubator-pegasus]

Posted by "acelyc111 (via GitHub)" <gi...@apache.org>.
acelyc111 commented on code in PR #1827:
URL: https://github.com/apache/incubator-pegasus/pull/1827#discussion_r1441391245


##########
src/utils/metrics.cpp:
##########
@@ -449,6 +444,89 @@ metric_entity_ptr metric_registry::find_or_create_entity(const metric_entity_pro
     return entity;
 }
 
+DSN_DECLARE_string(cluster_name);
+
+namespace {
+
+#define ENCODE_UNKNOWN_IF(expr)                                                                    \
+    do {                                                                                           \
+        if (dsn_unlikely(expr)) {                                                                  \
+            dsn::json::json_encode(writer, "unknown");                                             \
+            return;                                                                                \
+        }                                                                                          \
+    } while (0)
+
+void encode_cluster(dsn::metric_json_writer &writer)
+{
+    writer.Key(dsn::kMetricClusterField.c_str());
+
+    ENCODE_UNKNOWN_IF(utils::is_empty(dsn::FLAGS_cluster_name));
+
+    dsn::json::json_encode(writer, dsn::FLAGS_cluster_name);

Review Comment:
   How about encapsulate the 2 lines to a single line, the judgment can be put into the macro.
   
   The other places are the same.



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


Re: [PR] feat(new_metrics): add some basic fields to the response to metrics query [incubator-pegasus]

Posted by "empiredan (via GitHub)" <gi...@apache.org>.
empiredan merged PR #1827:
URL: https://github.com/apache/incubator-pegasus/pull/1827


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


Re: [PR] feat(new_metrics): add some basic fields to the response to metrics query [incubator-pegasus]

Posted by "empiredan (via GitHub)" <gi...@apache.org>.
empiredan commented on code in PR #1827:
URL: https://github.com/apache/incubator-pegasus/pull/1827#discussion_r1441522448


##########
src/utils/metrics.cpp:
##########
@@ -449,6 +444,89 @@ metric_entity_ptr metric_registry::find_or_create_entity(const metric_entity_pro
     return entity;
 }
 
+DSN_DECLARE_string(cluster_name);
+
+namespace {
+
+#define ENCODE_UNKNOWN_IF(expr)                                                                    \
+    do {                                                                                           \
+        if (dsn_unlikely(expr)) {                                                                  \
+            dsn::json::json_encode(writer, "unknown");                                             \
+            return;                                                                                \
+        }                                                                                          \
+    } while (0)
+
+void encode_cluster(dsn::metric_json_writer &writer)
+{
+    writer.Key(dsn::kMetricClusterField.c_str());
+
+    ENCODE_UNKNOWN_IF(utils::is_empty(dsn::FLAGS_cluster_name));
+
+    dsn::json::json_encode(writer, dsn::FLAGS_cluster_name);

Review Comment:
   OK.



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