提交 c8241e16 编写于 作者: Y yong.you

refactor cat api

上级 5cb523d9
...@@ -31,8 +31,10 @@ public class BussinessConfigManager implements Initializable { ...@@ -31,8 +31,10 @@ public class BussinessConfigManager implements Initializable {
for (String domain : domains) { for (String domain : domains) {
Map<Integer, Map<String, BusinessConfig>> value = m_configs.get(domain); Map<Integer, Map<String, BusinessConfig>> value = m_configs.get(domain);
for (Entry<Integer, Map<String, BusinessConfig>> internalEntry : value.entrySet()) { if(value!=null){
configs.addAll(internalEntry.getValue().values()); for (Entry<Integer, Map<String, BusinessConfig>> internalEntry : value.entrySet()) {
configs.addAll(internalEntry.getValue().values());
}
} }
} }
......
<metric-report product="TuanGou" startTime="2012-02-16 23:00:00" endTime="2012-02-16 23:59:00"> <metric-report product="TuanGou" startTime="2012-02-16 23:00:00" endTime="2012-02-16 23:59:00">
<metric-item id="addCount"> <metric-item id="addCount" type="S">
<domain>TuanGouWeb</domain> <domain>TuanGouWeb</domain>
<domain>TuanGouAPI</domain> <domain>TuanGouAPI</domain>
<abtest run-id="0" name="ALL"> <abtest run-id="0" name="ALL">
......
...@@ -168,7 +168,17 @@ public class Cat { ...@@ -168,7 +168,17 @@ public class Cat {
* the name of the metric * the name of the metric
*/ */
public static void logMetricForCount(String name) { public static void logMetricForCount(String name) {
logMetricInternal(name, "C", null); logMetricInternal(name, "C", "1");
}
/**
* Increase the counter specified by <code>name</code> by one.
*
* @param name
* the name of the metric
*/
public static void logMetricForCount(String name,int count) {
logMetricInternal(name, "C", String.valueOf(count));
} }
/** /**
...@@ -206,11 +216,11 @@ public class Cat { ...@@ -206,11 +216,11 @@ public class Cat {
* the quantity to be accumulated * the quantity to be accumulated
*/ */
public static void logMetricForSum(String name, double sum, int quantity) { public static void logMetricForSum(String name, double sum, int quantity) {
logMetricInternal(name, "S", String.format("%.2f,%s", sum, quantity)); logMetricInternal(name, "S,C", String.format("%.2f,%s", sum, quantity));
} }
static void logMetricInternal(String name, String type, String keyValuePairs) { static void logMetricInternal(String name, String status, String keyValuePairs) {
Cat.getProducer().logMetric(name, type, keyValuePairs); Cat.getProducer().logMetric(name, status, keyValuePairs);
} }
public static <T> T lookup(Class<T> role) throws ComponentLookupException { public static <T> T lookup(Class<T> role) throws ComponentLookupException {
......
...@@ -71,9 +71,9 @@ public class Handler implements PageHandler<Context> { ...@@ -71,9 +71,9 @@ public class Handler implements PageHandler<Context> {
event.setDate(new Date()); event.setDate(new Date());
try { try {
event.setDate(new Date(Integer.parseInt(time))); event.setDate(new Date(Integer.parseInt(time)));
} catch (Exception e1) { } catch (Exception ex) {
event.setDate(new Date()); event.setDate(new Date());
Cat.logError(e1); Cat.logError(ex);
} }
} }
m_errorCollectManager.addEvent(event); m_errorCollectManager.addEvent(event);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册