You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@skywalking.apache.org by wu...@apache.org on 2018/01/07 14:15:23 UTC

[incubator-skywalking] branch collector/instrument updated: Change the instrument ways.

This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch collector/instrument
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking.git


The following commit(s) were added to refs/heads/collector/instrument by this push:
     new 93e1259  Change the instrument ways.
93e1259 is described below

commit 93e12595a7c6fdc1b6d967acf4237a54915a81fa
Author: wusheng <wu...@foxmail.com>
AuthorDate: Sun Jan 7 22:15:14 2018 +0800

    Change the instrument ways.
---
 ...aphComputingMetric.java => BatchParameter.java} |   9 +-
 .../annotations/trace/GraphComputingMetric.java    |   1 +
 .../annotations/trace/TracedGraphElement.java}     |  24 ++--
 .../instrument/CollectorInstrumentAgent.java       |  27 ++--
 .../apm/collector/instrument/MetricCollector.java  | 160 ---------------------
 .../{TracedService.java => MetricTree.java}        |   9 +-
 .../{TracedService.java => ReportWriter.java}      |  12 +-
 .../apm/collector/instrument/ServiceMetric.java    |  53 +++++++
 ...dService.java => ServiceMetricBatchRecord.java} |  32 ++++-
 .../collector/instrument/ServiceMetricRecord.java  |  62 ++++++++
 .../collector/instrument/ServiceMetricTracing.java |   7 +-
 11 files changed, 176 insertions(+), 220 deletions(-)

diff --git a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/annotations/trace/GraphComputingMetric.java b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/annotations/trace/BatchParameter.java
similarity index 80%
copy from apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/annotations/trace/GraphComputingMetric.java
copy to apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/annotations/trace/BatchParameter.java
index 477f510..e49570d 100644
--- a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/annotations/trace/GraphComputingMetric.java
+++ b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/annotations/trace/BatchParameter.java
@@ -24,14 +24,9 @@ import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
 /**
- * The method with this annotation should be traced,
- * and the metrics(avg response time, call count, success rate) could be collected by the instrument agent.
- *
- * This is an optional annotation.
- *
  * @author wusheng
  */
-@Target(ElementType.METHOD)
+@Target(ElementType.PARAMETER)
 @Retention(RetentionPolicy.RUNTIME)
-public @interface GraphComputingMetric {
+public @interface BatchParameter {
 }
diff --git a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/annotations/trace/GraphComputingMetric.java b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/annotations/trace/GraphComputingMetric.java
index 477f510..d5dec9a 100644
--- a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/annotations/trace/GraphComputingMetric.java
+++ b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/annotations/trace/GraphComputingMetric.java
@@ -34,4 +34,5 @@ import java.lang.annotation.Target;
 @Target(ElementType.METHOD)
 @Retention(RetentionPolicy.RUNTIME)
 public @interface GraphComputingMetric {
+    String name();
 }
diff --git a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/annotations/trace/GraphComputingMetric.java b/apm-collector/apm-collector-core/src/test/java/org/apache/skywalking/apm/collector/core/annotations/trace/TracedGraphElement.java
similarity index 66%
copy from apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/annotations/trace/GraphComputingMetric.java
copy to apm-collector/apm-collector-core/src/test/java/org/apache/skywalking/apm/collector/core/annotations/trace/TracedGraphElement.java
index 477f510..cf95fa3 100644
--- a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/annotations/trace/GraphComputingMetric.java
+++ b/apm-collector/apm-collector-core/src/test/java/org/apache/skywalking/apm/collector/core/annotations/trace/TracedGraphElement.java
@@ -18,20 +18,22 @@
 
 package org.apache.skywalking.apm.collector.core.annotations.trace;
 
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+import java.util.List;
 
 /**
- * The method with this annotation should be traced,
- * and the metrics(avg response time, call count, success rate) could be collected by the instrument agent.
- *
- * This is an optional annotation.
+ * This is an example about how to use the tracing annotation in collector.
+ * These annotations effect only in `-instrument` mode active.
  *
  * @author wusheng
  */
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface GraphComputingMetric {
+public class TracedGraphElement {
+    @GraphComputingMetric(name = "/traced/element/run")
+    public void run() {
+
+    }
+
+    @GraphComputingMetric(name = "/traced/element/runWithBatch")
+    public void runWithBatch(@BatchParameter List<Object> data) {
+
+    }
 }
diff --git a/apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/CollectorInstrumentAgent.java b/apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/CollectorInstrumentAgent.java
index dc7ccf2..ad37612 100644
--- a/apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/CollectorInstrumentAgent.java
+++ b/apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/CollectorInstrumentAgent.java
@@ -29,7 +29,9 @@ import net.bytebuddy.utility.JavaModule;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static net.bytebuddy.matcher.ElementMatchers.declaresMethod;
 import static net.bytebuddy.matcher.ElementMatchers.hasSuperType;
+import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith;
 import static net.bytebuddy.matcher.ElementMatchers.isStatic;
 import static net.bytebuddy.matcher.ElementMatchers.named;
 import static net.bytebuddy.matcher.ElementMatchers.not;
@@ -46,18 +48,15 @@ import static net.bytebuddy.matcher.ElementMatchers.not;
  */
 public class CollectorInstrumentAgent {
     private final static Logger logger = LoggerFactory.getLogger(CollectorInstrumentAgent.class);
-    private static ElementMatcher<? super MethodDescription> EXCLUDE_OBJECT_DEFAULT_METHODS;
 
     public static void premain(String agentArgs, Instrumentation instrumentation) {
-        new AgentBuilder.Default().type(hasSuperType(named("org.apache.skywalking.apm.collector.core.module.Service"))).transform(new AgentBuilder.Transformer() {
-            @Override
-            public DynamicType.Builder<?> transform(DynamicType.Builder<?> builder, TypeDescription typeDescription,
-                ClassLoader classLoader, JavaModule module) {
-                builder = builder.method(excludeDefaultMethodsMatcher())
-                    .intercept(MethodDelegation.withDefaultConfiguration()
-                        .to(new ServiceMetricTracing(typeDescription.getActualName())));
-                return builder;
-            }
+        new AgentBuilder.Default().type(
+            declaresMethod(isAnnotationedMatch())
+        ).transform((builder, typeDescription, classLoader, module) -> {
+            builder = builder.method(isAnnotationedMatch())
+                .intercept(MethodDelegation.withDefaultConfiguration()
+                    .to(new ServiceMetricTracing()));
+            return builder;
         }).with(new AgentBuilder.Listener() {
             @Override
             public void onDiscovery(String typeName, ClassLoader classLoader, JavaModule module, boolean loaded) {
@@ -88,11 +87,7 @@ public class CollectorInstrumentAgent {
         }).installOn(instrumentation);
     }
 
-    private static ElementMatcher<? super MethodDescription> excludeDefaultMethodsMatcher() {
-        if (EXCLUDE_OBJECT_DEFAULT_METHODS == null) {
-            EXCLUDE_OBJECT_DEFAULT_METHODS = not(isStatic().or(named("getClass")).or(named("hashCode")).or(named("equals")).or(named("clone"))
-                .or(named("toString")).or(named("notify")).or(named("notifyAll")).or(named("wait")).or(named("finalize")));
-        }
-        return EXCLUDE_OBJECT_DEFAULT_METHODS;
+    private static ElementMatcher<? super MethodDescription> isAnnotationedMatch() {
+        return isAnnotatedWith(named("org.apache.skywalking.apm.collector.core.annotations.trace.GraphComputingMetric"));
     }
 }
diff --git a/apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/MetricCollector.java b/apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/MetricCollector.java
deleted file mode 100644
index 5b8b62d..0000000
--- a/apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/MetricCollector.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * 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.skywalking.apm.collector.instrument;
-
-import java.lang.reflect.Method;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * The <code>MetricCollector</code> collects the service metrics by Module/Provider/Service structure.
- */
-public enum MetricCollector implements Runnable {
-    INSTANCE;
-
-    private final Logger logger = LoggerFactory.getLogger(MetricCollector.class);
-    private ConcurrentHashMap<String, ServiceMetric> serviceMetricsA = new ConcurrentHashMap<>();
-    private ConcurrentHashMap<String, ServiceMetric> serviceMetricsB = new ConcurrentHashMap<>();
-    private volatile boolean isA = true;
-
-    MetricCollector() {
-        ScheduledExecutorService service = Executors
-            .newSingleThreadScheduledExecutor();
-        service.scheduleAtFixedRate(this, 10, 60, TimeUnit.SECONDS);
-    }
-
-    @Override
-    public void run() {
-        ConcurrentHashMap<String, ServiceMetric> now;
-        if (isA) {
-            now = serviceMetricsA;
-            isA = false;
-        } else {
-            now = serviceMetricsB;
-            isA = true;
-        }
-        try {
-            // Wait the A/B switch completed.
-            Thread.sleep(1000L);
-        } catch (InterruptedException e) {
-
-        }
-
-        StringBuilder report = new StringBuilder();
-        report.append("\n");
-        report.append("##################################################################################################################\n");
-        report.append("#                                             Collector Service Report                                           #\n");
-        report.append("##################################################################################################################\n");
-        now.forEach((serviceName, serviceMetric) -> {
-            report.append(serviceName).append(":\n");
-            serviceMetric.methodMetrics.forEach((method, metric) -> {
-                if (metric.isExecuted()) {
-                    report.append(method).append(":\n");
-                    report.append("\t").append(metric).append("\n");
-                    metric.clear();
-                }
-            });
-            serviceMetric.reset();
-        });
-
-        /**
-         * The reason of outputing in warn info, is to make sure this logs aren't blocked in performance test.(debug/info log level off)
-         */
-        logger.warn(report.toString());
-
-    }
-
-    void registerService(String service) {
-        serviceMetricsA.put(service, new ServiceMetric(service));
-        serviceMetricsB.put(service, new ServiceMetric(service));
-    }
-
-    void trace(String service, Method method, long nano, boolean occurException) {
-        ConcurrentHashMap<String, ServiceMetric> now = isA ? serviceMetricsA : serviceMetricsB;
-        now.get(service).trace(method, nano, occurException);
-    }
-
-    class ServiceMetric {
-        private String serviceName;
-        private ConcurrentHashMap<Method, ServiceMethodMetric> methodMetrics = new ConcurrentHashMap<>();
-        private volatile boolean isExecuted = false;
-
-        public ServiceMetric(String serviceName) {
-            this.serviceName = serviceName;
-        }
-
-        private void reset() {
-            isExecuted = false;
-        }
-
-        void trace(Method method, long nano, boolean occurException) {
-            isExecuted = true;
-            ServiceMethodMetric metric = methodMetrics.get(method);
-            if (metric == null) {
-                ServiceMethodMetric methodMetric = new ServiceMethodMetric();
-                methodMetrics.putIfAbsent(method, methodMetric);
-                metric = methodMetrics.get(method);
-            }
-            metric.add(nano, occurException);
-        }
-    }
-
-    private class ServiceMethodMetric {
-        private AtomicLong totalTimeNano;
-        private AtomicLong counter;
-        private AtomicLong errorCounter;
-
-        public ServiceMethodMetric() {
-            totalTimeNano = new AtomicLong(0);
-            counter = new AtomicLong(0);
-            errorCounter = new AtomicLong(0);
-        }
-
-        private boolean isExecuted() {
-            return counter.get() > 0;
-        }
-
-        private void add(long nano, boolean occurException) {
-            totalTimeNano.addAndGet(nano);
-            counter.incrementAndGet();
-            if (occurException)
-                errorCounter.incrementAndGet();
-        }
-
-        private void clear() {
-            totalTimeNano.set(0);
-            counter.set(0);
-            errorCounter.set(0);
-        }
-
-        @Override public String toString() {
-            if (counter.longValue() == 0) {
-                return "Avg=N/A";
-            }
-            return "Avg=" + (totalTimeNano.longValue() / counter.longValue()) + " (nano)" +
-                ", Success Rate=" + (counter.longValue() - errorCounter.longValue()) * 100 / counter.longValue() +
-                "%, Calls=" + counter.longValue();
-        }
-    }
-}
diff --git a/apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/TracedService.java b/apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/MetricTree.java
similarity index 76%
copy from apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/TracedService.java
copy to apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/MetricTree.java
index ffcbda4..9dd1f2f 100644
--- a/apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/TracedService.java
+++ b/apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/MetricTree.java
@@ -16,15 +16,10 @@
  *
  */
 
-
 package org.apache.skywalking.apm.collector.instrument;
 
 /**
- * The <code>TracedService</code> implementation are dynamic class, generated by {@link ServiceInstrumentation}.
- *
- * By that, all the services metrics are collected, and report in the certain cycle through console.
- *
- * @author wu-sheng
+ * @author wusheng
  */
-public interface TracedService {
+public class MetricTree {
 }
diff --git a/apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/TracedService.java b/apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/ReportWriter.java
similarity index 76%
copy from apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/TracedService.java
copy to apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/ReportWriter.java
index ffcbda4..303bccc 100644
--- a/apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/TracedService.java
+++ b/apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/ReportWriter.java
@@ -16,15 +16,13 @@
  *
  */
 
-
 package org.apache.skywalking.apm.collector.instrument;
 
 /**
- * The <code>TracedService</code> implementation are dynamic class, generated by {@link ServiceInstrumentation}.
- *
- * By that, all the services metrics are collected, and report in the certain cycle through console.
- *
- * @author wu-sheng
+ * @author wusheng
  */
-public interface TracedService {
+public interface ReportWriter {
+    void writeMetricName(String name);
+
+    void writeMetric(String metrics);
 }
diff --git a/apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/ServiceMetric.java b/apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/ServiceMetric.java
new file mode 100644
index 0000000..e35b895
--- /dev/null
+++ b/apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/ServiceMetric.java
@@ -0,0 +1,53 @@
+/*
+ * 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.skywalking.apm.collector.instrument;
+
+/**
+ * @author wusheng
+ */
+public class ServiceMetric {
+    private String metricName;
+    private ServiceMetricRecord winA;
+    private ServiceMetricRecord winB;
+    private volatile boolean isUsingWinA;
+
+    ServiceMetric(String metricName, boolean isBatchDetected) {
+        this.metricName = metricName;
+        winA = isBatchDetected ? new ServiceMetricBatchRecord() : new ServiceMetricRecord();
+        winB = isBatchDetected ? new ServiceMetricBatchRecord() : new ServiceMetricRecord();
+        isUsingWinA = true;
+    }
+
+    public void trace(long nano, boolean occurException) {
+        ServiceMetricRecord usingRecord = isUsingWinA ? winA : winB;
+        usingRecord.add(nano, occurException);
+    }
+
+    void exchangeWindows() {
+        isUsingWinA = !isUsingWinA;
+    }
+
+    public void toOutput(ReportWriter writer) {
+        writer.writeMetricName(metricName);
+        /**
+         * If using A, then B is available and free to output.
+         */
+        writer.writeMetric(isUsingWinA ? winB.toString() : winA.toString());
+    }
+}
diff --git a/apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/TracedService.java b/apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/ServiceMetricBatchRecord.java
similarity index 56%
rename from apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/TracedService.java
rename to apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/ServiceMetricBatchRecord.java
index ffcbda4..7fb524c 100644
--- a/apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/TracedService.java
+++ b/apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/ServiceMetricBatchRecord.java
@@ -16,15 +16,33 @@
  *
  */
 
-
 package org.apache.skywalking.apm.collector.instrument;
 
+import java.util.concurrent.atomic.AtomicLong;
+
 /**
- * The <code>TracedService</code> implementation are dynamic class, generated by {@link ServiceInstrumentation}.
- *
- * By that, all the services metrics are collected, and report in the certain cycle through console.
- *
- * @author wu-sheng
+ * @author wusheng
  */
-public interface TracedService {
+public class ServiceMetricBatchRecord extends ServiceMetricRecord {
+    private AtomicLong batchRowSize;
+
+    public ServiceMetricBatchRecord(){
+        super();
+        batchRowSize = new AtomicLong(0);
+    }
+
+    void add(long nano, boolean occurException, int rowSize) {
+        super.add(nano, occurException);
+        batchRowSize.addAndGet(rowSize);
+    }
+
+    @Override void clear() {
+        super.clear();
+        batchRowSize.set(0);
+    }
+
+    @Override
+    public String toString() {
+        return super.toString() + " Rows per call = " + (batchRowSize.get() / counter.get());
+    }
 }
diff --git a/apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/ServiceMetricRecord.java b/apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/ServiceMetricRecord.java
new file mode 100644
index 0000000..3bd9b95
--- /dev/null
+++ b/apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/ServiceMetricRecord.java
@@ -0,0 +1,62 @@
+/*
+ * 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.skywalking.apm.collector.instrument;
+
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * @author wusheng
+ */
+public class ServiceMetricRecord {
+    private AtomicLong totalTimeNano;
+    protected AtomicLong counter;
+    private AtomicLong errorCounter;
+
+    public ServiceMetricRecord() {
+        totalTimeNano = new AtomicLong(0);
+        counter = new AtomicLong(0);
+        errorCounter = new AtomicLong(0);
+    }
+
+    private boolean isExecuted() {
+        return counter.get() > 0;
+    }
+
+    void add(long nano, boolean occurException) {
+        totalTimeNano.addAndGet(nano);
+        counter.incrementAndGet();
+        if (occurException)
+            errorCounter.incrementAndGet();
+    }
+
+    void clear() {
+        totalTimeNano.set(0);
+        counter.set(0);
+        errorCounter.set(0);
+    }
+
+    @Override public String toString() {
+        if (counter.longValue() == 0) {
+            return "Avg=N/A";
+        }
+        return "Avg=" + (totalTimeNano.longValue() / counter.longValue()) + " (nano)" +
+            ", Success Rate=" + (counter.longValue() - errorCounter.longValue()) * 100 / counter.longValue() +
+            "%, Calls=" + counter.longValue();
+    }
+}
diff --git a/apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/ServiceMetricTracing.java b/apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/ServiceMetricTracing.java
index 3c47e1d..978c4e5 100644
--- a/apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/ServiceMetricTracing.java
+++ b/apm-collector/apm-collector-instrument/src/main/java/org/apache/skywalking/apm/collector/instrument/ServiceMetricTracing.java
@@ -28,11 +28,8 @@ import net.bytebuddy.implementation.bind.annotation.SuperCall;
  * @author wu-sheng
  */
 public class ServiceMetricTracing {
-    private String serviceName;
 
-    public ServiceMetricTracing(String service) {
-        this.serviceName = service;
-        MetricCollector.INSTANCE.registerService(service);
+    public ServiceMetricTracing() {
     }
 
     @RuntimeType
@@ -50,7 +47,7 @@ public class ServiceMetricTracing {
             throw t;
         } finally {
             endNano = System.nanoTime();
-            MetricCollector.INSTANCE.trace(serviceName, method, endNano - startNano, occurError);
+            //MetricCollector.INSTANCE.trace(serviceName, method, endNano - startNano, occurError);
         }
     }
 }

-- 
To stop receiving notification emails like this one, please contact
['"commits@skywalking.apache.org" <co...@skywalking.apache.org>'].