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