[ 
https://issues.apache.org/jira/browse/SCB-150?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16328184#comment-16328184
 ] 

ASF GitHub Bot commented on SCB-150:
------------------------------------

zhengyangyong commented on a change in pull request #508: [SCB-150] Add 
Status(success/failed) dimension to operation call count and tps
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/508#discussion_r161941800
 
 

 ##########
 File path: 
metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/utils/MonitorUtils.java
 ##########
 @@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.metrics.core.utils;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+import com.netflix.servo.monitor.Monitor;
+import com.netflix.servo.tag.Tag;
+import com.netflix.servo.tag.TagList;
+
+public class MonitorUtils {
+
+  //for time-related monitor type, if stop poll value over one window time,
+  //the value may return -1 or NaN because servo can't known precise value of 
previous step
+  //so must change to return 0
+  public static double adjustValue(double value) {
+    return Double.isNaN(value) || value < 0 ? 0 : value;
+  }
+
+  //for time-related monitor type, if stop poll value over one window time,
+  //the value may return -1 because servo can't known precise value of 
previous step
+  //so must change to return 0
+  public static long adjustValue(long value) {
+    return value < 0 ? 0 : value;
+  }
+
+  public static boolean containsTagValue(Monitor monitor, String tagKey, 
String tagValue) {
+    TagList tags = monitor.getConfig().getTags();
+    return tags.containsKey(tagKey) && 
tagValue.equals(tags.getTag(tagKey).getValue());
+  }
+
+  public static Map<String, String> convertTags(Monitor monitor) {
+    TagList tags = monitor.getConfig().getTags();
+    if (tags.size() != 0) {
+      Map<String, String> tagMap = new HashMap<>();
+      for (Tag tag : tags) {
+        //we don't need servo internal type tag for metrics
+        if (!"type".equals(tag.getKey())) {
+          tagMap.put(tag.getKey(), tag.getValue());
+        }
+      }
+      return tagMap;
+    }
+    return null;
 
 Review comment:
   Done

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Add Success / Fail Dimension for Invocation
> -------------------------------------------
>
>                 Key: SCB-150
>                 URL: https://issues.apache.org/jira/browse/SCB-150
>             Project: Apache ServiceComb
>          Issue Type: Sub-task
>          Components: Java-Chassis
>            Reporter: yangyongzheng
>            Assignee: yangyongzheng
>            Priority: Major
>             Fix For: java-chassis-1.0.0-m1
>
>         Attachments: screenshot-1.png
>
>
> Add Success / Fail Dimension for Invocation,new metric available :
> !screenshot-1.png!



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to