You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicecomb.apache.org by GitBox <gi...@apache.org> on 2018/01/09 06:27:15 UTC

[GitHub] liubao68 closed pull request #476: [SCB-85] Upgrade Metrics File Output from 0.5.0 to 1.0.0-m1

liubao68 closed pull request #476: [SCB-85] Upgrade Metrics File Output from 0.5.0 to 1.0.0-m1
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/476
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/foundations/foundation-metrics/src/main/java/io/servicecomb/foundation/metrics/MetricsServoRegistry.java b/foundations/foundation-metrics/src/main/java/io/servicecomb/foundation/metrics/MetricsServoRegistry.java
index 2e5326556..b00ff32eb 100644
--- a/foundations/foundation-metrics/src/main/java/io/servicecomb/foundation/metrics/MetricsServoRegistry.java
+++ b/foundations/foundation-metrics/src/main/java/io/servicecomb/foundation/metrics/MetricsServoRegistry.java
@@ -75,7 +75,7 @@ public MetricsServoRegistry() {
 
   /*
    * Added getter for unit test of local metrics.
-   * 
+   *
    * @return Local metric reference
    */
   public MetricsDataMonitor getLocalMetrics() {
@@ -563,11 +563,10 @@ public String getValue() {
   }
 
   private double round(double value, int places) {
-    if (!Double.isNaN(value) && !Double.isInfinite(value)) {
+    if (!Double.isNaN(value)) {
       BigDecimal decimal = new BigDecimal(value);
       return decimal.setScale(places, RoundingMode.HALF_UP).doubleValue();
-    } else {
-      return 0;
     }
+    return 0;
   }
 }
diff --git a/java-chassis-dependencies/pom.xml b/java-chassis-dependencies/pom.xml
index 70f1c0237..36adaa392 100644
--- a/java-chassis-dependencies/pom.xml
+++ b/java-chassis-dependencies/pom.xml
@@ -36,6 +36,7 @@
     <spring.version>4.3.5.RELEASE</spring.version>
     <slf4j.version>1.7.7</slf4j.version>
     <log4j.version>1.2.17</log4j.version>
+    <log4j2.version>2.8.2</log4j2.version>
     <commons.io.version>2.4</commons.io.version>
     <javassist.version>3.18.1-GA</javassist.version>
     <javax.ws.rs.version>2.0.1</javax.ws.rs.version>
@@ -519,6 +520,16 @@
         <artifactId>log4j</artifactId>
         <version>${log4j.version}</version>
       </dependency>
+      <dependency>
+        <groupId>org.apache.logging.log4j</groupId>
+        <artifactId>log4j-api</artifactId>
+        <version>${log4j2.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.logging.log4j</groupId>
+        <artifactId>log4j-core</artifactId>
+        <version>${log4j2.version}</version>
+      </dependency>
       <dependency>
         <groupId>commons-io</groupId>
         <artifactId>commons-io</artifactId>
diff --git a/metrics/metrics-core/src/main/java/io/servicecomb/metrics/core/MetricsConfig.java b/metrics/metrics-core/src/main/java/io/servicecomb/metrics/core/MetricsConfig.java
new file mode 100644
index 000000000..1223b152d
--- /dev/null
+++ b/metrics/metrics-core/src/main/java/io/servicecomb/metrics/core/MetricsConfig.java
@@ -0,0 +1,22 @@
+/*
+ * 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 io.servicecomb.metrics.core;
+
+public class MetricsConfig {
+  public static final String METRICS_POLLING_TIME = "servicecomb.metrics.window_time";
+}
diff --git a/metrics/metrics-core/src/main/java/io/servicecomb/metrics/core/publish/DefaultDataSource.java b/metrics/metrics-core/src/main/java/io/servicecomb/metrics/core/publish/DefaultDataSource.java
index 81c439bc3..402a333d8 100644
--- a/metrics/metrics-core/src/main/java/io/servicecomb/metrics/core/publish/DefaultDataSource.java
+++ b/metrics/metrics-core/src/main/java/io/servicecomb/metrics/core/publish/DefaultDataSource.java
@@ -34,20 +34,20 @@
 
 import io.servicecomb.foundation.common.exceptions.ServiceCombException;
 import io.servicecomb.metrics.common.RegistryMetric;
+import io.servicecomb.metrics.core.MetricsConfig;
 import io.servicecomb.metrics.core.monitor.RegistryMonitor;
 import io.servicecomb.swagger.invocation.exception.InvocationException;
 
 @Component
 public class DefaultDataSource implements DataSource {
-  private static final String METRICS_POLLING_TIME = "servicecomb.metrics.window_time";
-
   private final RegistryMonitor registryMonitor;
 
   private final Map<Long, Integer> appliedWindowTimes = new HashMap<>();
 
   @Autowired
   public DefaultDataSource(RegistryMonitor registryMonitor) {
-    this(registryMonitor, DynamicPropertyFactory.getInstance().getStringProperty(METRICS_POLLING_TIME, "5000").get());
+    this(registryMonitor,
+        DynamicPropertyFactory.getInstance().getStringProperty(MetricsConfig.METRICS_POLLING_TIME, "5000").get());
   }
 
   public DefaultDataSource(RegistryMonitor registryMonitor, String pollingSettings) {
diff --git a/metrics/metrics-sample/pom.xml b/metrics/metrics-extension/pom.xml
similarity index 90%
rename from metrics/metrics-sample/pom.xml
rename to metrics/metrics-extension/pom.xml
index b78f37ab4..bdbe4f300 100644
--- a/metrics/metrics-sample/pom.xml
+++ b/metrics/metrics-extension/pom.xml
@@ -26,11 +26,7 @@
   </parent>
   <modelVersion>4.0.0</modelVersion>
 
-  <artifactId>metrics-sample</artifactId>
+  <artifactId>metrics-extension</artifactId>
   <packaging>pom</packaging>
 
-  <modules>
-    <module>metrics-performance-test</module>
-  </modules>
-  
 </project>
\ No newline at end of file
diff --git a/metrics/metrics-sample/metrics-performance-test/src/main/java/io/servicecomb/metrics/sample/perf/PerfService.java b/metrics/metrics-sample/metrics-performance-test/src/main/java/io/servicecomb/metrics/sample/perf/PerfService.java
deleted file mode 100644
index e6651a8f5..000000000
--- a/metrics/metrics-sample/metrics-performance-test/src/main/java/io/servicecomb/metrics/sample/perf/PerfService.java
+++ /dev/null
@@ -1,89 +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 io.servicecomb.metrics.sample.perf;
-
-import java.util.UUID;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import io.servicecomb.metrics.core.publish.DataSource;
-import io.servicecomb.provider.rest.common.RestSchema;
-
-@RestSchema(schemaId = "demoServiceEndpoint")
-@RequestMapping(path = "/")
-public class PerfService {
-
-  private final DataSource dataSource;
-
-  @Autowired
-  public PerfService(DataSource dataSource) {
-    this.dataSource = dataSource;
-  }
-
-  @GetMapping(path = "/f0")
-  public String fun0() {
-    return UUID.randomUUID().toString();
-  }
-
-  @GetMapping(path = "/f1")
-  public String fun1() {
-    return UUID.randomUUID().toString();
-  }
-
-  @GetMapping(path = "/f2")
-  public String fun2() {
-    return UUID.randomUUID().toString();
-  }
-
-  @GetMapping(path = "/f3")
-  public String fun3() {
-    return UUID.randomUUID().toString();
-  }
-
-  @GetMapping(path = "/f4")
-  public String fun4() {
-    return UUID.randomUUID().toString();
-  }
-
-  @GetMapping(path = "/f5")
-  public String fun5() {
-    return UUID.randomUUID().toString();
-  }
-
-  @GetMapping(path = "/f6")
-  public String fun6() {
-    return UUID.randomUUID().toString();
-  }
-
-  @GetMapping(path = "/f7")
-  public String fun7() {
-    return UUID.randomUUID().toString();
-  }
-
-  @GetMapping(path = "/f8")
-  public String fun8() {
-    return UUID.randomUUID().toString();
-  }
-
-  @GetMapping(path = "/f9")
-  public String fun9() {
-    return UUID.randomUUID().toString();
-  }
-}
diff --git a/metrics/pom.xml b/metrics/pom.xml
index f3cc665a3..7331a3b0b 100644
--- a/metrics/pom.xml
+++ b/metrics/pom.xml
@@ -31,8 +31,8 @@
   <artifactId>metrics</artifactId>
 
   <modules>
-    <module>metrics-core</module>
-    <module>metrics-sample</module>
     <module>metrics-common</module>
+    <module>metrics-core</module>
+    <module>metrics-extension</module>
   </modules>
 </project>
\ No newline at end of file
diff --git a/samples/bmi/calculator/pom.xml b/samples/bmi/calculator/pom.xml
index ffd84f1ed..3a1d71564 100644
--- a/samples/bmi/calculator/pom.xml
+++ b/samples/bmi/calculator/pom.xml
@@ -32,16 +32,6 @@
     <dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter</artifactId>
-      <exclusions>
-        <exclusion>
-          <groupId>org.springframework.boot</groupId>
-          <artifactId>spring-boot-starter-logging</artifactId>
-        </exclusion>
-      </exclusions>
-    </dependency>
-    <dependency>
-      <groupId>org.springframework.boot</groupId>
-      <artifactId>spring-boot-starter-log4j2</artifactId>
     </dependency>
 
     <dependency>
diff --git a/samples/bmi/calculator/src/main/resources/microservice.yaml b/samples/bmi/calculator/src/main/resources/microservice.yaml
index 8069b4674..a7a7a6b41 100644
--- a/samples/bmi/calculator/src/main/resources/microservice.yaml
+++ b/samples/bmi/calculator/src/main/resources/microservice.yaml
@@ -31,15 +31,4 @@ cse:
   handler:
     chain:
       Provider:
-        default: bizkeeper-provider
-
-servicecomb:
-  metrics:
-    #polltime,unit is second
-    polltime: 5
-    #metrics double value round places,default value is 1
-    round_places: 1
-    file:
-      enabled: true
-      #metrics file name prefix setting,default value is "metrics"
-      name_prefix: bmi.calculator
\ No newline at end of file
+        default: bizkeeper-provider
\ No newline at end of file
diff --git a/samples/metrics-write-file-sample/metrics-write-file-common/pom.xml b/samples/metrics-write-file-sample/metrics-write-file-common/pom.xml
new file mode 100644
index 000000000..def56c237
--- /dev/null
+++ b/samples/metrics-write-file-sample/metrics-write-file-common/pom.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>metrics-write-file-sample</artifactId>
+    <groupId>io.servicecomb.samples</groupId>
+    <version>0.6.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>metrics-write-file-common</artifactId>
+  <dependencies>
+    <dependency>
+      <groupId>io.servicecomb</groupId>
+      <artifactId>provider-springmvc</artifactId>
+    </dependency>
+  </dependencies>
+</project>
\ No newline at end of file
diff --git a/samples/metrics-write-file-sample/metrics-write-file-common/src/main/java/io/servicecomb/samples/mwf/SimpleService.java b/samples/metrics-write-file-sample/metrics-write-file-common/src/main/java/io/servicecomb/samples/mwf/SimpleService.java
new file mode 100644
index 000000000..fbfc01f3f
--- /dev/null
+++ b/samples/metrics-write-file-sample/metrics-write-file-common/src/main/java/io/servicecomb/samples/mwf/SimpleService.java
@@ -0,0 +1,36 @@
+/*
+ * 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 io.servicecomb.samples.mwf;
+
+import java.util.UUID;
+
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import io.servicecomb.provider.rest.common.RestSchema;
+
+//simple service sim
+@RestSchema(schemaId = "demoServiceEndpoint")
+@RequestMapping(path = "/")
+public class SimpleService {
+
+  @GetMapping(path = "/f")
+  public String fun() {
+    return UUID.randomUUID().toString();
+  }
+}
diff --git a/samples/metrics-write-file-sample/metrics-write-file-config-log4j/pom.xml b/samples/metrics-write-file-sample/metrics-write-file-config-log4j/pom.xml
new file mode 100644
index 000000000..dc58bf8e5
--- /dev/null
+++ b/samples/metrics-write-file-sample/metrics-write-file-config-log4j/pom.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>metrics-write-file-sample</artifactId>
+    <groupId>io.servicecomb.samples</groupId>
+    <version>0.6.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>metrics-write-file-config-log4j</artifactId>
+
+  <dependencies>
+    <dependency>
+      <groupId>io.servicecomb.samples</groupId>
+      <artifactId>metrics-write-file</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+    </dependency>
+  </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/samples/metrics-write-file-sample/metrics-write-file-config-log4j/src/main/java/io/servicecomb/samples/mwf/Log4JMetricsFileWriter.java b/samples/metrics-write-file-sample/metrics-write-file-config-log4j/src/main/java/io/servicecomb/samples/mwf/Log4JMetricsFileWriter.java
new file mode 100644
index 000000000..716fba190
--- /dev/null
+++ b/samples/metrics-write-file-sample/metrics-write-file-config-log4j/src/main/java/io/servicecomb/samples/mwf/Log4JMetricsFileWriter.java
@@ -0,0 +1,77 @@
+/*
+ * 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 io.servicecomb.samples.mwf;
+
+import java.nio.file.Paths;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.apache.log4j.RollingFileAppender;
+import org.apache.log4j.spi.LoggingEvent;
+import org.springframework.stereotype.Component;
+
+import com.netflix.config.DynamicPropertyFactory;
+
+@Component
+public class Log4JMetricsFileWriter implements MetricsFileWriter {
+  private static final String METRICS_FILE_ROLLING_MAX_FILE_COUNT = "servicecomb.metrics.file.rolling.max_file_count";
+
+  private static final String METRICS_FILE_ROLLING_MAX_FILE_SIZE = "servicecomb.metrics.file.rolling.max_file_size";
+
+  private static final String METRICS_FILE_ROOT_PATH = "servicecomb.metrics.file.root_path";
+
+
+  private final Map<String, RollingFileAppender> fileAppenders = new ConcurrentHashMap<>();
+
+  private final int maxFileCount;
+
+  private final String maxFileSize;
+
+  private final String rootPath;
+
+  public Log4JMetricsFileWriter() {
+    maxFileCount = DynamicPropertyFactory.getInstance().getIntProperty(METRICS_FILE_ROLLING_MAX_FILE_COUNT, 10).get();
+    maxFileSize = DynamicPropertyFactory.getInstance().getStringProperty(METRICS_FILE_ROLLING_MAX_FILE_SIZE, "10MB")
+        .get();
+    rootPath = DynamicPropertyFactory.getInstance().getStringProperty(METRICS_FILE_ROOT_PATH, "target").get();
+  }
+
+  @Override
+  public void write(String loggerName, String filePrefix, String content) {
+    RollingFileAppender logger = fileAppenders.computeIfAbsent(loggerName, f -> initLogger(loggerName, filePrefix));
+    LoggingEvent event = new LoggingEvent(loggerName, Logger.getLogger(loggerName), Level.ALL,
+        content, null);
+    logger.append(event);
+  }
+
+  private RollingFileAppender initLogger(String loggerName, String filePrefix) {
+    String fileName = Paths.get(rootPath, filePrefix + "." + loggerName + ".dat").toString();
+    RollingFileAppender fileAppender = new RollingFileAppender();
+    fileAppender.setName(loggerName);
+    fileAppender.setFile(fileName);
+    fileAppender.setLayout(new PatternLayout("%m%n"));
+    fileAppender.setAppend(true);
+    fileAppender.setMaxFileSize(maxFileSize);
+    fileAppender.setMaxBackupIndex(maxFileCount);
+    fileAppender.activateOptions();
+    return fileAppender;
+  }
+}
diff --git a/samples/metrics-write-file-sample/metrics-write-file-config-log4j2/pom.xml b/samples/metrics-write-file-sample/metrics-write-file-config-log4j2/pom.xml
new file mode 100644
index 000000000..63a16895c
--- /dev/null
+++ b/samples/metrics-write-file-sample/metrics-write-file-config-log4j2/pom.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>metrics-write-file-sample</artifactId>
+    <groupId>io.servicecomb.samples</groupId>
+    <version>0.6.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>metrics-write-file-config-log4j2</artifactId>
+
+  <dependencies>
+    <dependency>
+      <groupId>io.servicecomb.samples</groupId>
+      <artifactId>metrics-write-file</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+    </dependency>
+  </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/samples/metrics-write-file-sample/metrics-write-file-config-log4j2/src/main/java/io/servicecomb/samples/mwf/Log4J2MetricsFileWriter.java b/samples/metrics-write-file-sample/metrics-write-file-config-log4j2/src/main/java/io/servicecomb/samples/mwf/Log4J2MetricsFileWriter.java
new file mode 100644
index 000000000..13a5046a6
--- /dev/null
+++ b/samples/metrics-write-file-sample/metrics-write-file-config-log4j2/src/main/java/io/servicecomb/samples/mwf/Log4J2MetricsFileWriter.java
@@ -0,0 +1,84 @@
+/*
+ * 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 io.servicecomb.samples.mwf;
+
+import java.nio.file.Paths;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.appender.RollingFileAppender;
+import org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy;
+import org.apache.logging.log4j.core.appender.rolling.SizeBasedTriggeringPolicy;
+import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.core.impl.Log4jLogEvent;
+import org.apache.logging.log4j.core.layout.PatternLayout;
+import org.apache.logging.log4j.message.SimpleMessage;
+import org.springframework.stereotype.Component;
+
+import com.netflix.config.DynamicPropertyFactory;
+
+@Component
+public class Log4J2MetricsFileWriter implements MetricsFileWriter {
+  private static final String METRICS_FILE_ROLLING_MAX_FILE_COUNT = "servicecomb.metrics.file.rolling.max_file_count";
+
+  private static final String METRICS_FILE_ROLLING_MAX_FILE_SIZE = "servicecomb.metrics.file.rolling.max_file_size";
+
+  private static final String METRICS_FILE_ROOT_PATH = "servicecomb.metrics.file.root_path";
+
+  private final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
+
+  private final Configuration config = ctx.getConfiguration();
+
+  private final Map<String, RollingFileAppender> fileAppenders = new ConcurrentHashMap<>();
+
+  private final int maxFileCount;
+
+  private final String maxFileSize;
+
+  private final String rootPath;
+
+  public Log4J2MetricsFileWriter() {
+    maxFileCount = DynamicPropertyFactory.getInstance().getIntProperty(METRICS_FILE_ROLLING_MAX_FILE_COUNT, 10).get();
+    maxFileSize = DynamicPropertyFactory.getInstance().getStringProperty(METRICS_FILE_ROLLING_MAX_FILE_SIZE, "10MB")
+        .get();
+    rootPath = DynamicPropertyFactory.getInstance().getStringProperty(METRICS_FILE_ROOT_PATH, "target").get();
+  }
+
+  @Override
+  public void write(String loggerName, String filePrefix, String content) {
+    RollingFileAppender logger = fileAppenders.computeIfAbsent(loggerName, f -> initLogger(loggerName, filePrefix));
+    logger.append(Log4jLogEvent.newBuilder().setMessage(new SimpleMessage(content)).build());
+  }
+
+  private RollingFileAppender initLogger(String loggerName, String filePrefix) {
+    String fileName = Paths.get(rootPath, filePrefix + "." + loggerName + ".dat").toString();
+    String filePattern = Paths.get(rootPath, filePrefix + "." + loggerName + "-%i.dat").toString();
+
+    PatternLayout layout = PatternLayout.newBuilder().withPattern(PatternLayout.DEFAULT_CONVERSION_PATTERN).build();
+    SizeBasedTriggeringPolicy policy = SizeBasedTriggeringPolicy.createPolicy(maxFileSize);
+    DefaultRolloverStrategy strategy = DefaultRolloverStrategy.createStrategy(String.valueOf(maxFileCount), null, null,
+        null, null, false, config);
+
+    //TODO:use RollingFileAppender.newBuilder throw No such static method exception,will improve later!
+    return RollingFileAppender
+        .createAppender(fileName, filePattern, "true", loggerName, "true", null,
+            "true", policy, strategy, layout, null, null, null, null, config);
+  }
+}
diff --git a/samples/metrics-write-file-sample/metrics-write-file-config/pom.xml b/samples/metrics-write-file-sample/metrics-write-file-config/pom.xml
new file mode 100644
index 000000000..001648d0a
--- /dev/null
+++ b/samples/metrics-write-file-sample/metrics-write-file-config/pom.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>metrics-write-file-sample</artifactId>
+    <groupId>io.servicecomb.samples</groupId>
+    <version>0.6.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>metrics-write-file-config</artifactId>
+
+
+</project>
\ No newline at end of file
diff --git a/samples/metrics-write-file-sample/metrics-write-file-config/src/main/java/io/servicecomb/samples/mwf/MetricsFileWriter.java b/samples/metrics-write-file-sample/metrics-write-file-config/src/main/java/io/servicecomb/samples/mwf/MetricsFileWriter.java
new file mode 100644
index 000000000..5ecaba118
--- /dev/null
+++ b/samples/metrics-write-file-sample/metrics-write-file-config/src/main/java/io/servicecomb/samples/mwf/MetricsFileWriter.java
@@ -0,0 +1,22 @@
+/*
+ * 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 io.servicecomb.samples.mwf;
+
+public interface MetricsFileWriter {
+  void write(String loggerName, String filePrefix, String content);
+}
diff --git a/samples/metrics-write-file-sample/metrics-write-file-log4j-springboot/pom.xml b/samples/metrics-write-file-sample/metrics-write-file-log4j-springboot/pom.xml
new file mode 100644
index 000000000..447ad59c3
--- /dev/null
+++ b/samples/metrics-write-file-sample/metrics-write-file-log4j-springboot/pom.xml
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>metrics-write-file-sample</artifactId>
+    <groupId>io.servicecomb.samples</groupId>
+    <version>0.6.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>metrics-write-file-log4j-springboot</artifactId>
+
+  <!--need exclusion log4j-over-slf4j-->
+  <!--spring boot starter included log4j-over-slf4j,this log bridge not implement the full interface for log4j,
+  excluded the bridge jar let all slf4j calls go directly to log4j instead of the bridge.
+  more info can be found here : https://www.slf4j.org/legacy.html#log4j-over-slf4j -->
+  <dependencies>
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>org.slf4j</groupId>
+          <artifactId>log4j-over-slf4j</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+
+    <dependency>
+      <groupId>io.servicecomb</groupId>
+      <artifactId>spring-boot-starter-provider</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>io.servicecomb</groupId>
+      <artifactId>handler-flowcontrol-qps</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>io.servicecomb</groupId>
+      <artifactId>handler-bizkeeper</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>io.servicecomb</groupId>
+      <artifactId>handler-tracing-zipkin</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.hibernate</groupId>
+      <artifactId>hibernate-validator</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>io.servicecomb.samples</groupId>
+      <artifactId>metrics-write-file-common</artifactId>
+    </dependency>
+
+    <!--metrics write file dependency-->
+    <dependency>
+      <groupId>io.servicecomb.samples</groupId>
+      <artifactId>metrics-write-file-config-log4j</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-maven-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
\ No newline at end of file
diff --git a/metrics/metrics-sample/metrics-performance-test/src/main/java/io/servicecomb/metrics/sample/perf/PerfApplication.java b/samples/metrics-write-file-sample/metrics-write-file-log4j-springboot/src/main/java/io/servicecomb/samples/mwf/ServiceApplication.java
similarity index 89%
rename from metrics/metrics-sample/metrics-performance-test/src/main/java/io/servicecomb/metrics/sample/perf/PerfApplication.java
rename to samples/metrics-write-file-sample/metrics-write-file-log4j-springboot/src/main/java/io/servicecomb/samples/mwf/ServiceApplication.java
index 388f5111e..bfb4354db 100644
--- a/metrics/metrics-sample/metrics-performance-test/src/main/java/io/servicecomb/metrics/sample/perf/PerfApplication.java
+++ b/samples/metrics-write-file-sample/metrics-write-file-log4j-springboot/src/main/java/io/servicecomb/samples/mwf/ServiceApplication.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package io.servicecomb.metrics.sample.perf;
+package io.servicecomb.samples.mwf;
 
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -24,8 +24,8 @@
 
 @SpringBootApplication
 @EnableServiceComb
-public class PerfApplication {
+public class ServiceApplication {
   public static void main(String[] args) {
-    SpringApplication.run(PerfApplication.class, args);
+    SpringApplication.run(ServiceApplication.class, args);
   }
 }
diff --git a/metrics/metrics-sample/metrics-performance-test/src/main/resources/microservice.yaml b/samples/metrics-write-file-sample/metrics-write-file-log4j-springboot/src/main/resources/microservice.yaml
similarity index 66%
rename from metrics/metrics-sample/metrics-performance-test/src/main/resources/microservice.yaml
rename to samples/metrics-write-file-sample/metrics-write-file-log4j-springboot/src/main/resources/microservice.yaml
index b5edcd167..748ef4d85 100644
--- a/metrics/metrics-sample/metrics-performance-test/src/main/resources/microservice.yaml
+++ b/samples/metrics-write-file-sample/metrics-write-file-log4j-springboot/src/main/resources/microservice.yaml
@@ -15,23 +15,32 @@
 ## limitations under the License.
 ## ---------------------------------------------------------------------------
 
-# all interconnected microservices must belong to an application wth the same ID
-APPLICATION_ID: metricsPerfTest
+APPLICATION_ID: mwf
 service_description:
-# name of the declaring microservice
-  name: demo
+  name: mwf-log4j2-springboot
   version: 0.0.1
 cse:
   service:
     registry:
       address: http://127.0.0.1:30100
   rest:
-    address: 0.0.0.0:7777
+    address: 0.0.0.0:8080
+  highway:
+    address: 0.0.0.0:7070
+  handler:
+    chain:
+      Provider:
+        default: bizkeeper-provider
 
 servicecomb:
   metrics:
-    #Support Muti-WindowTime (MILLISECONDS) like 10000,60000 (10s and 60s), Use WindowTimeIndex make selection,start from 0
-    #Default value is single WindowTime : 5000 (5 second)
-    #Will direct set value of "servo.pollers"
-    #More info can be found here : https://github.com/Netflix/servo/wiki/Getting-Started -> Polling Intervals Chapter
-    window_time: 5000
\ No newline at end of file
+    #metrics double value round places,default value is 1
+    round_places: 1
+    file:
+      root_path: ./samples/metrics-write-file-sample/metrics-write-file-log4j-springboot/target/metric/
+      rolling:
+        max_file_count: 10
+        max_file_size : 10MB
+
+    #output time,milliseconds
+    window_time: 5000
diff --git a/samples/metrics-write-file-sample/metrics-write-file-log4j/pom.xml b/samples/metrics-write-file-sample/metrics-write-file-log4j/pom.xml
new file mode 100644
index 000000000..f84ef1f24
--- /dev/null
+++ b/samples/metrics-write-file-sample/metrics-write-file-log4j/pom.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>metrics-write-file-sample</artifactId>
+    <groupId>io.servicecomb.samples</groupId>
+    <version>0.6.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>metrics-write-file-log4j</artifactId>
+
+  <dependencies>
+    <dependency>
+      <groupId>io.servicecomb</groupId>
+      <artifactId>handler-bizkeeper</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>io.servicecomb</groupId>
+      <artifactId>handler-loadbalance</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>io.servicecomb</groupId>
+      <artifactId>transport-highway</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>io.servicecomb</groupId>
+      <artifactId>transport-rest-vertx</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>io.servicecomb</groupId>
+      <artifactId>handler-flowcontrol-qps</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>io.servicecomb</groupId>
+      <artifactId>provider-springmvc</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>io.servicecomb.samples</groupId>
+      <artifactId>metrics-write-file-common</artifactId>
+    </dependency>
+
+    <!--metrics write file dependency-->
+    <dependency>
+      <groupId>io.servicecomb.samples</groupId>
+      <artifactId>metrics-write-file-config-log4j</artifactId>
+    </dependency>
+
+  </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/samples/metrics-write-file-sample/metrics-write-file-log4j/src/main/java/io/servicecomb/samples/mwf/ServiceApplication.java b/samples/metrics-write-file-sample/metrics-write-file-log4j/src/main/java/io/servicecomb/samples/mwf/ServiceApplication.java
new file mode 100644
index 000000000..b1a4930af
--- /dev/null
+++ b/samples/metrics-write-file-sample/metrics-write-file-log4j/src/main/java/io/servicecomb/samples/mwf/ServiceApplication.java
@@ -0,0 +1,28 @@
+/*
+ * 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 io.servicecomb.samples.mwf;
+
+import io.servicecomb.foundation.common.utils.BeanUtils;
+import io.servicecomb.foundation.common.utils.Log4jUtils;
+
+public class ServiceApplication {
+  public static void main(String[] args) throws Exception {
+    Log4jUtils.init();
+    BeanUtils.init();
+  }
+}
diff --git a/samples/metrics-write-file-sample/metrics-write-file-log4j/src/main/resources/META-INF/spring/pojo.provider.bean.xml b/samples/metrics-write-file-sample/metrics-write-file-log4j/src/main/resources/META-INF/spring/pojo.provider.bean.xml
new file mode 100644
index 000000000..55045d091
--- /dev/null
+++ b/samples/metrics-write-file-sample/metrics-write-file-log4j/src/main/resources/META-INF/spring/pojo.provider.bean.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xmlns:context="http://www.springframework.org/schema/context"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-3.0.xsd
+		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+
+  <context:component-scan base-package="io.servicecomb.samples.mwf"/>
+</beans>
diff --git a/samples/metrics-write-file-sample/metrics-write-file-log4j/src/main/resources/microservice.yaml b/samples/metrics-write-file-sample/metrics-write-file-log4j/src/main/resources/microservice.yaml
new file mode 100644
index 000000000..999300af2
--- /dev/null
+++ b/samples/metrics-write-file-sample/metrics-write-file-log4j/src/main/resources/microservice.yaml
@@ -0,0 +1,46 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+APPLICATION_ID: mwf
+service_description:
+  name: mwf-log4j
+  version: 0.0.1
+cse:
+  service:
+    registry:
+      address: http://127.0.0.1:30100
+  rest:
+    address: 0.0.0.0:8080
+  highway:
+    address: 0.0.0.0:7070
+  handler:
+    chain:
+      Provider:
+        default: bizkeeper-provider
+
+servicecomb:
+  metrics:
+    #metrics double value round places,default value is 1
+    round_places: 1
+    file:
+      root_path: ./samples/metrics-write-file-sample/metrics-write-file-log4j/target/metric/
+      rolling:
+        max_file_count: 10
+        max_file_size : 10MB
+
+    #output time,milliseconds
+    window_time: 5000
diff --git a/metrics/metrics-sample/metrics-performance-test/pom.xml b/samples/metrics-write-file-sample/metrics-write-file-log4j2-springboot/pom.xml
similarity index 69%
rename from metrics/metrics-sample/metrics-performance-test/pom.xml
rename to samples/metrics-write-file-sample/metrics-write-file-log4j2-springboot/pom.xml
index 7a51ea625..24612e3f7 100644
--- a/metrics/metrics-sample/metrics-performance-test/pom.xml
+++ b/samples/metrics-write-file-sample/metrics-write-file-log4j2-springboot/pom.xml
@@ -20,40 +20,51 @@
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <parent>
-    <artifactId>metrics-sample</artifactId>
-    <groupId>io.servicecomb</groupId>
+    <artifactId>metrics-write-file-sample</artifactId>
+    <groupId>io.servicecomb.samples</groupId>
     <version>0.6.0-SNAPSHOT</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
 
-  <artifactId>metrics-performance-test</artifactId>
+  <artifactId>metrics-write-file-log4j2-springboot</artifactId>
 
   <dependencies>
     <dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter</artifactId>
     </dependency>
+
     <dependency>
       <groupId>io.servicecomb</groupId>
       <artifactId>spring-boot-starter-provider</artifactId>
     </dependency>
 
+    <dependency>
+      <groupId>io.servicecomb</groupId>
+      <artifactId>handler-flowcontrol-qps</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>io.servicecomb</groupId>
+      <artifactId>handler-bizkeeper</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>io.servicecomb</groupId>
+      <artifactId>handler-tracing-zipkin</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.hibernate</groupId>
       <artifactId>hibernate-validator</artifactId>
     </dependency>
 
-    <!--add or move metrics-core for enable or disable-->
     <dependency>
-      <groupId>io.servicecomb</groupId>
-      <artifactId>metrics-core</artifactId>
-      <exclusions>
-        <exclusion>
-          <groupId>io.servicecomb</groupId>
-          <artifactId>foundation-metrics</artifactId>
-        </exclusion>
-      </exclusions>
-      <version>0.6.0-SNAPSHOT</version>
+      <groupId>io.servicecomb.samples</groupId>
+      <artifactId>metrics-write-file-common</artifactId>
+    </dependency>
+
+    <!--metrics write file dependency-->
+    <dependency>
+      <groupId>io.servicecomb.samples</groupId>
+      <artifactId>metrics-write-file-config-log4j2</artifactId>
     </dependency>
   </dependencies>
 
@@ -62,17 +73,6 @@
       <plugin>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-maven-plugin</artifactId>
-        <executions>
-          <execution>
-            <goals>
-              <goal>repackage</goal>
-            </goals>
-            <configuration>
-              <outputDirectory>${project.build.directory}/runnable</outputDirectory>
-              <classifier>exec</classifier>
-            </configuration>
-          </execution>
-        </executions>
       </plugin>
     </plugins>
   </build>
diff --git a/samples/metrics-write-file-sample/metrics-write-file-log4j2-springboot/src/main/java/io/servicecomb/samples/mwf/ServiceApplication.java b/samples/metrics-write-file-sample/metrics-write-file-log4j2-springboot/src/main/java/io/servicecomb/samples/mwf/ServiceApplication.java
new file mode 100644
index 000000000..bfb4354db
--- /dev/null
+++ b/samples/metrics-write-file-sample/metrics-write-file-log4j2-springboot/src/main/java/io/servicecomb/samples/mwf/ServiceApplication.java
@@ -0,0 +1,31 @@
+/*
+ * 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 io.servicecomb.samples.mwf;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+import io.servicecomb.springboot.starter.provider.EnableServiceComb;
+
+@SpringBootApplication
+@EnableServiceComb
+public class ServiceApplication {
+  public static void main(String[] args) {
+    SpringApplication.run(ServiceApplication.class, args);
+  }
+}
diff --git a/samples/metrics-write-file-sample/metrics-write-file-log4j2-springboot/src/main/resources/microservice.yaml b/samples/metrics-write-file-sample/metrics-write-file-log4j2-springboot/src/main/resources/microservice.yaml
new file mode 100644
index 000000000..e21b21ad5
--- /dev/null
+++ b/samples/metrics-write-file-sample/metrics-write-file-log4j2-springboot/src/main/resources/microservice.yaml
@@ -0,0 +1,46 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+APPLICATION_ID: mwf
+service_description:
+  name: mwf-log4j-springboot
+  version: 0.0.1
+cse:
+  service:
+    registry:
+      address: http://127.0.0.1:30100
+  rest:
+    address: 0.0.0.0:8080
+  highway:
+    address: 0.0.0.0:7070
+  handler:
+    chain:
+      Provider:
+        default: bizkeeper-provider
+
+servicecomb:
+  metrics:
+    #metrics double value round places,default value is 1
+    round_places: 1
+    file:
+      root_path: ./samples/metrics-write-file-sample/metrics-write-file-log4j2-springboot/target/metric/
+      rolling:
+        max_file_count: 10
+        max_file_size : 10MB
+
+    #output time,milliseconds
+    window_time: 5000
diff --git a/samples/metrics-write-file-sample/metrics-write-file-log4j2/pom.xml b/samples/metrics-write-file-sample/metrics-write-file-log4j2/pom.xml
new file mode 100644
index 000000000..863c37993
--- /dev/null
+++ b/samples/metrics-write-file-sample/metrics-write-file-log4j2/pom.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>metrics-write-file-sample</artifactId>
+    <groupId>io.servicecomb.samples</groupId>
+    <version>0.6.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>metrics-write-file-log4j2</artifactId>
+
+  <dependencies>
+    <dependency>
+      <groupId>io.servicecomb</groupId>
+      <artifactId>handler-bizkeeper</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>io.servicecomb</groupId>
+      <artifactId>handler-loadbalance</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>io.servicecomb</groupId>
+      <artifactId>transport-highway</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>io.servicecomb</groupId>
+      <artifactId>transport-rest-vertx</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>io.servicecomb</groupId>
+      <artifactId>handler-flowcontrol-qps</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>io.servicecomb</groupId>
+      <artifactId>provider-springmvc</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>io.servicecomb.samples</groupId>
+      <artifactId>metrics-write-file-common</artifactId>
+    </dependency>
+
+    <!--metrics write file dependency-->
+    <dependency>
+      <groupId>io.servicecomb.samples</groupId>
+      <artifactId>metrics-write-file-config-log4j2</artifactId>
+    </dependency>
+
+  </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/samples/metrics-write-file-sample/metrics-write-file-log4j2/src/main/java/io/servicecomb/samples/mwf/ServiceApplication.java b/samples/metrics-write-file-sample/metrics-write-file-log4j2/src/main/java/io/servicecomb/samples/mwf/ServiceApplication.java
new file mode 100644
index 000000000..b1a4930af
--- /dev/null
+++ b/samples/metrics-write-file-sample/metrics-write-file-log4j2/src/main/java/io/servicecomb/samples/mwf/ServiceApplication.java
@@ -0,0 +1,28 @@
+/*
+ * 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 io.servicecomb.samples.mwf;
+
+import io.servicecomb.foundation.common.utils.BeanUtils;
+import io.servicecomb.foundation.common.utils.Log4jUtils;
+
+public class ServiceApplication {
+  public static void main(String[] args) throws Exception {
+    Log4jUtils.init();
+    BeanUtils.init();
+  }
+}
diff --git a/samples/metrics-write-file-sample/metrics-write-file-log4j2/src/main/resources/microservice.yaml b/samples/metrics-write-file-sample/metrics-write-file-log4j2/src/main/resources/microservice.yaml
new file mode 100644
index 000000000..36522b640
--- /dev/null
+++ b/samples/metrics-write-file-sample/metrics-write-file-log4j2/src/main/resources/microservice.yaml
@@ -0,0 +1,46 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+APPLICATION_ID: mwf
+service_description:
+  name: mwf-log4j2
+  version: 0.0.1
+cse:
+  service:
+    registry:
+      address: http://127.0.0.1:30100
+  rest:
+    address: 0.0.0.0:8080
+  highway:
+    address: 0.0.0.0:7070
+  handler:
+    chain:
+      Provider:
+        default: bizkeeper-provider
+
+servicecomb:
+  metrics:
+    #metrics double value round places,default value is 1
+    round_places: 1
+    file:
+      root_path: ./samples/metrics-write-file-sample/metrics-write-file-log4j2/target/metric/
+      rolling:
+        max_file_count: 10
+        max_file_size : 10MB
+
+    #output time,milliseconds
+    window_time: 5000
diff --git a/samples/metrics-write-file-sample/metrics-write-file-log4j2/src/main/resources/spring/pojo.provider.bean.xml b/samples/metrics-write-file-sample/metrics-write-file-log4j2/src/main/resources/spring/pojo.provider.bean.xml
new file mode 100644
index 000000000..55045d091
--- /dev/null
+++ b/samples/metrics-write-file-sample/metrics-write-file-log4j2/src/main/resources/spring/pojo.provider.bean.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xmlns:context="http://www.springframework.org/schema/context"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-3.0.xsd
+		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+
+  <context:component-scan base-package="io.servicecomb.samples.mwf"/>
+</beans>
diff --git a/samples/metrics-write-file-sample/metrics-write-file/pom.xml b/samples/metrics-write-file-sample/metrics-write-file/pom.xml
new file mode 100644
index 000000000..acc3e2bac
--- /dev/null
+++ b/samples/metrics-write-file-sample/metrics-write-file/pom.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>metrics-write-file-sample</artifactId>
+    <groupId>io.servicecomb.samples</groupId>
+    <version>0.6.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>metrics-write-file</artifactId>
+
+  <dependencies>
+    <dependency>
+      <groupId>io.servicecomb.samples</groupId>
+      <artifactId>metrics-write-file-config</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>io.servicecomb</groupId>
+      <artifactId>metrics-core</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jmockit</groupId>
+      <artifactId>jmockit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+
+</project>
\ No newline at end of file
diff --git a/samples/metrics-write-file-sample/metrics-write-file/src/main/java/io/servicecomb/samples/mwf/FileContentConvertor.java b/samples/metrics-write-file-sample/metrics-write-file/src/main/java/io/servicecomb/samples/mwf/FileContentConvertor.java
new file mode 100644
index 000000000..16ea4ced7
--- /dev/null
+++ b/samples/metrics-write-file-sample/metrics-write-file/src/main/java/io/servicecomb/samples/mwf/FileContentConvertor.java
@@ -0,0 +1,27 @@
+/*
+ * 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 io.servicecomb.samples.mwf;
+
+import java.util.Map;
+
+import io.servicecomb.metrics.common.RegistryMetric;
+
+//convert metrics to output content
+public interface FileContentConvertor {
+  Map<String, String> convert(RegistryMetric registryMetric);
+}
diff --git a/samples/metrics-write-file-sample/metrics-write-file/src/main/java/io/servicecomb/samples/mwf/FileContentFormatter.java b/samples/metrics-write-file-sample/metrics-write-file/src/main/java/io/servicecomb/samples/mwf/FileContentFormatter.java
new file mode 100644
index 000000000..83501b28e
--- /dev/null
+++ b/samples/metrics-write-file-sample/metrics-write-file/src/main/java/io/servicecomb/samples/mwf/FileContentFormatter.java
@@ -0,0 +1,24 @@
+/*
+ * 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 io.servicecomb.samples.mwf;
+
+import java.util.Map;
+
+public interface FileContentFormatter {
+  Map<String, String> format(Map<String, String> input);
+}
diff --git a/samples/metrics-write-file-sample/metrics-write-file/src/main/java/io/servicecomb/samples/mwf/MetricsBootListener.java b/samples/metrics-write-file-sample/metrics-write-file/src/main/java/io/servicecomb/samples/mwf/MetricsBootListener.java
new file mode 100644
index 000000000..83a19cad1
--- /dev/null
+++ b/samples/metrics-write-file-sample/metrics-write-file/src/main/java/io/servicecomb/samples/mwf/MetricsBootListener.java
@@ -0,0 +1,41 @@
+/*
+ * 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 io.servicecomb.samples.mwf;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import io.servicecomb.core.BootListener;
+
+@Component
+public class MetricsBootListener implements BootListener {
+
+  private final WriteFileInitializer initializer;
+
+  @Autowired
+  public MetricsBootListener(WriteFileInitializer initializer) {
+    this.initializer = initializer;
+  }
+
+  @Override
+  public void onBootEvent(BootEvent event) {
+    if (EventType.BEFORE_REGISTRY.equals(event.getEventType())) {
+      this.initializer.startOutput();
+    }
+  }
+}
diff --git a/samples/metrics-write-file-sample/metrics-write-file/src/main/java/io/servicecomb/samples/mwf/SimpleFileContentConvertor.java b/samples/metrics-write-file-sample/metrics-write-file/src/main/java/io/servicecomb/samples/mwf/SimpleFileContentConvertor.java
new file mode 100644
index 000000000..a2bd03612
--- /dev/null
+++ b/samples/metrics-write-file-sample/metrics-write-file/src/main/java/io/servicecomb/samples/mwf/SimpleFileContentConvertor.java
@@ -0,0 +1,60 @@
+/*
+ * 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 io.servicecomb.samples.mwf;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import com.netflix.config.DynamicPropertyFactory;
+
+import io.servicecomb.metrics.common.RegistryMetric;
+
+public class SimpleFileContentConvertor implements FileContentConvertor {
+
+  private static final String METRICS_ROUND_PLACES = "servicecomb.metrics.round_places";
+
+  private final int doubleRoundPlaces;
+
+  private final String doubleStringFormatter;
+
+  public SimpleFileContentConvertor() {
+    doubleRoundPlaces = DynamicPropertyFactory.getInstance().getIntProperty(METRICS_ROUND_PLACES, 1).get();
+    doubleStringFormatter = "%." + String.valueOf(doubleRoundPlaces) + "f";
+  }
+
+  @Override
+  public Map<String, String> convert(RegistryMetric registryMetric) {
+    Map<String, String> pickedMetrics = new HashMap<>();
+    for (Entry<String, Number> metric : registryMetric.toMap().entrySet()) {
+      pickedMetrics.put(metric.getKey(), String.format(doubleStringFormatter,
+          round(metric.getValue().doubleValue(), doubleRoundPlaces)));
+    }
+    return pickedMetrics;
+  }
+
+  private double round(double value, int places) {
+    if (!Double.isNaN(value)) {
+      BigDecimal decimal = new BigDecimal(value);
+      return decimal.setScale(places, RoundingMode.HALF_UP).doubleValue();
+    }
+    return 0;
+  }
+}
diff --git a/samples/metrics-write-file-sample/metrics-write-file/src/main/java/io/servicecomb/samples/mwf/SimpleFileContentFormatter.java b/samples/metrics-write-file-sample/metrics-write-file/src/main/java/io/servicecomb/samples/mwf/SimpleFileContentFormatter.java
new file mode 100644
index 000000000..0390269ed
--- /dev/null
+++ b/samples/metrics-write-file-sample/metrics-write-file/src/main/java/io/servicecomb/samples/mwf/SimpleFileContentFormatter.java
@@ -0,0 +1,86 @@
+/*
+ * 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 io.servicecomb.samples.mwf;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.stream.Collectors;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+
+import io.servicecomb.foundation.common.utils.JsonUtils;
+
+public class SimpleFileContentFormatter implements FileContentFormatter {
+  private static final Logger logger = LoggerFactory.getLogger(SimpleFileContentFormatter.class);
+
+  private final String applicationName;
+
+  private final String hostName;
+
+  public SimpleFileContentFormatter(String hostName, String applicationName) {
+    this.hostName = hostName;
+    this.applicationName = applicationName;
+  }
+
+  @Override
+  public Map<String, String> format(Map<String, String> input) {
+    return input.entrySet().stream()
+        .collect(Collectors.toMap(Entry::getKey, entry -> {
+          try {
+            return JsonUtils.writeValueAsString(
+                new OutputJsonObject(applicationName, hostName, entry.getKey(), entry.getValue()));
+          } catch (JsonProcessingException e) {
+            logger.error("error format metrics data", e);
+            return "";
+          }
+        }));
+  }
+
+
+  class OutputJsonObject {
+    private String plugin_id;
+
+    private Map<String, Object> metric;
+
+    public String getPlugin_id() {
+      return plugin_id;
+    }
+
+    public Map<String, Object> getMetric() {
+      return metric;
+    }
+
+    public OutputJsonObject() {
+    }
+
+    public OutputJsonObject(String plugin_id, String hostName, String metricName, String metricValue) {
+      this();
+      this.plugin_id = plugin_id;
+      this.metric = new HashMap<>();
+      this.metric.put("node", hostName);
+      this.metric.put("scope_name", "");
+      this.metric.put("timestamp", System.currentTimeMillis());
+      this.metric.put("inface_name", "");
+      this.metric.put(metricName, metricValue);
+    }
+  }
+}
diff --git a/samples/metrics-write-file-sample/metrics-write-file/src/main/java/io/servicecomb/samples/mwf/WriteFileInitializer.java b/samples/metrics-write-file-sample/metrics-write-file/src/main/java/io/servicecomb/samples/mwf/WriteFileInitializer.java
new file mode 100644
index 000000000..fb606b95f
--- /dev/null
+++ b/samples/metrics-write-file-sample/metrics-write-file/src/main/java/io/servicecomb/samples/mwf/WriteFileInitializer.java
@@ -0,0 +1,100 @@
+/*
+ * 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 io.servicecomb.samples.mwf;
+
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+
+import java.util.Map;
+import java.util.concurrent.Executors;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import com.netflix.config.DynamicPropertyFactory;
+
+import io.servicecomb.foundation.common.net.NetUtils;
+import io.servicecomb.metrics.common.RegistryMetric;
+import io.servicecomb.metrics.core.MetricsConfig;
+import io.servicecomb.metrics.core.publish.DataSource;
+import io.servicecomb.serviceregistry.RegistryUtils;
+import io.servicecomb.serviceregistry.api.registry.Microservice;
+
+@Component
+public class WriteFileInitializer {
+  private final int metricPoll;
+
+  private FileContentConvertor convertor;
+
+  private FileContentFormatter formatter;
+
+  private final DataSource dataSource;
+
+  private final MetricsFileWriter fileWriter;
+
+  private String filePrefix;
+
+  private String hostName;
+
+  @Autowired
+  public WriteFileInitializer(MetricsFileWriter fileWriter, DataSource dataSource) {
+    metricPoll = DynamicPropertyFactory.getInstance().getIntProperty(MetricsConfig.METRICS_POLLING_TIME, 5000).get();
+    this.fileWriter = fileWriter;
+    this.dataSource = dataSource;
+    this.convertor = new SimpleFileContentConvertor();
+  }
+
+  public WriteFileInitializer(MetricsFileWriter fileWriter, DataSource dataSource, String hostName, String filePrefix) {
+    metricPoll = DynamicPropertyFactory.getInstance().getIntProperty(MetricsConfig.METRICS_POLLING_TIME, 5000).get();
+    this.fileWriter = fileWriter;
+    this.dataSource = dataSource;
+    this.hostName = hostName;
+    this.filePrefix = filePrefix;
+    this.convertor = new SimpleFileContentConvertor();
+    this.formatter = new SimpleFileContentFormatter(hostName, filePrefix);
+  }
+
+  public void startOutput() {
+    if (StringUtils.isEmpty(filePrefix)) {
+      Microservice microservice = RegistryUtils.getMicroservice();
+      filePrefix = microservice.getAppId() + "." + microservice.getServiceName();
+    }
+    if (StringUtils.isEmpty(hostName)) {
+      hostName = NetUtils.getHostName();
+      if (StringUtils.isEmpty(hostName)) {
+        hostName = NetUtils.getHostAddress();
+      }
+    }
+
+    formatter = new SimpleFileContentFormatter(hostName, filePrefix);
+
+    final Runnable poller = this::run;
+    Executors.newScheduledThreadPool(1)
+        .scheduleWithFixedDelay(poller, 0, metricPoll, MILLISECONDS);
+  }
+
+  public void run() {
+    RegistryMetric registryMetric = dataSource.getRegistryMetric();
+    Map<String, String> convertedMetrics = convertor.convert(registryMetric);
+    Map<String, String> formattedMetrics = formatter.format(convertedMetrics);
+
+    for (String metricName : formattedMetrics.keySet()) {
+      fileWriter.write(metricName, filePrefix, formattedMetrics.get(metricName));
+    }
+  }
+}
diff --git a/samples/metrics-write-file-sample/metrics-write-file/src/test/java/io/servicecomb/samples/mwf/TestWriteFile.java b/samples/metrics-write-file-sample/metrics-write-file/src/test/java/io/servicecomb/samples/mwf/TestWriteFile.java
new file mode 100644
index 000000000..f3b089b7a
--- /dev/null
+++ b/samples/metrics-write-file-sample/metrics-write-file/src/test/java/io/servicecomb/samples/mwf/TestWriteFile.java
@@ -0,0 +1,158 @@
+/*
+ * 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 io.servicecomb.samples.mwf;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import io.servicecomb.metrics.common.CallMetric;
+import io.servicecomb.metrics.common.ConsumerInvocationMetric;
+import io.servicecomb.metrics.common.RegistryMetric;
+import io.servicecomb.metrics.common.SystemMetric;
+import io.servicecomb.metrics.common.TimerMetric;
+import io.servicecomb.metrics.core.publish.DataSource;
+import io.servicecomb.serviceregistry.Features;
+import io.servicecomb.serviceregistry.RegistryUtils;
+import io.servicecomb.serviceregistry.ServiceRegistry;
+import io.servicecomb.serviceregistry.api.registry.Microservice;
+import io.servicecomb.serviceregistry.api.registry.MicroserviceInstance;
+import io.servicecomb.serviceregistry.cache.InstanceCacheManager;
+import io.servicecomb.serviceregistry.client.ServiceRegistryClient;
+import io.servicecomb.serviceregistry.consumer.AppManager;
+import mockit.Expectations;
+
+public class TestWriteFile {
+
+  @Test
+  public void test() {
+
+    new Expectations(RegistryUtils.class) {
+      {
+        RegistryUtils.getServiceRegistry();
+        result = new ServiceRegistry() {
+          @Override
+          public void init() {
+
+          }
+
+          @Override
+          public void run() {
+
+          }
+
+          @Override
+          public void destroy() {
+
+          }
+
+          @Override
+          public Set<String> getCombinedMicroserviceNames() {
+            return null;
+          }
+
+          @Override
+          public Microservice getMicroservice() {
+            return null;
+          }
+
+          @Override
+          public MicroserviceInstance getMicroserviceInstance() {
+            return null;
+          }
+
+          @Override
+          public ServiceRegistryClient getServiceRegistryClient() {
+            return null;
+          }
+
+          @Override
+          public AppManager getAppManager() {
+            return null;
+          }
+
+          @Override
+          public InstanceCacheManager getInstanceCacheManager() {
+            return null;
+          }
+
+          @Override
+          public List<MicroserviceInstance> findServiceInstance(String appId, String microserviceName,
+              String microserviceVersionRule) {
+            return null;
+          }
+
+          @Override
+          public boolean updateMicroserviceProperties(Map<String, String> properties) {
+            return false;
+          }
+
+          @Override
+          public boolean updateInstanceProperties(Map<String, String> instanceProperties) {
+            return false;
+          }
+
+          @Override
+          public Microservice getRemoteMicroservice(String microserviceId) {
+            return null;
+          }
+
+          @Override
+          public Features getFeatures() {
+            return null;
+          }
+        };
+      }
+    };
+
+    StringBuilder builder = new StringBuilder();
+
+    MetricsFileWriter writer = (loggerName, filePrefix, content) ->
+        builder.append(loggerName).append(filePrefix).append(content);
+
+    SystemMetric systemMetric = new SystemMetric(50, 10, 1, 2, 3,
+        4, 5, 6, 7, 8);
+
+    Map<String, ConsumerInvocationMetric> consumerInvocationMetricMap = new HashMap<>();
+    consumerInvocationMetricMap.put("A", new ConsumerInvocationMetric("A", "A",
+        new TimerMetric("A1", 1, 2, 3, 4), new CallMetric("A2", 100, 999.44444)));
+
+    consumerInvocationMetricMap.put("B", new ConsumerInvocationMetric("B", "B",
+        new TimerMetric("B1", 1, 2, 3, 4), new CallMetric("B2", 100, 888.66666)));
+
+    RegistryMetric metric = new RegistryMetric(systemMetric, consumerInvocationMetricMap, new HashMap<>());
+
+    DataSource dataSource = Mockito.mock(DataSource.class);
+    Mockito.when(dataSource.getRegistryMetric()).thenReturn(metric);
+
+    WriteFileInitializer writeFileInitializer = new WriteFileInitializer(writer, dataSource,
+        "localhost", "appId.serviceName");
+
+    writeFileInitializer.run();
+
+    String sb = builder.toString();
+
+    Assert.assertTrue(sb.contains("999.4"));
+    Assert.assertTrue(sb.contains("888.7"));
+  }
+}
diff --git a/samples/metrics-write-file-sample/pom.xml b/samples/metrics-write-file-sample/pom.xml
new file mode 100644
index 000000000..31f5b4bcc
--- /dev/null
+++ b/samples/metrics-write-file-sample/pom.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>samples</artifactId>
+    <groupId>io.servicecomb.samples</groupId>
+    <version>0.6.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>metrics-write-file-sample</artifactId>
+  <packaging>pom</packaging>
+  <modules>
+    <module>metrics-write-file-config</module>
+    <module>metrics-write-file</module>
+    <module>metrics-write-file-config-log4j</module>
+    <module>metrics-write-file-config-log4j2</module>
+    <module>metrics-write-file-common</module>
+    <module>metrics-write-file-log4j</module>
+    <module>metrics-write-file-log4j2</module>
+    <module>metrics-write-file-log4j-springboot</module>
+    <module>metrics-write-file-log4j2-springboot</module>
+  </modules>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>io.servicecomb</groupId>
+        <artifactId>metrics-core</artifactId>
+        <version>0.6.0-SNAPSHOT</version>
+      </dependency>
+      <dependency>
+        <groupId>io.servicecomb.samples</groupId>
+        <artifactId>metrics-write-file-config</artifactId>
+        <version>0.6.0-SNAPSHOT</version>
+      </dependency>
+      <dependency>
+        <groupId>io.servicecomb.samples</groupId>
+        <artifactId>metrics-write-file</artifactId>
+        <version>0.6.0-SNAPSHOT</version>
+      </dependency>
+      <dependency>
+        <groupId>io.servicecomb.samples</groupId>
+        <artifactId>metrics-write-file-common</artifactId>
+        <version>0.6.0-SNAPSHOT</version>
+      </dependency>
+      <dependency>
+        <groupId>io.servicecomb.samples</groupId>
+        <artifactId>metrics-write-file-config-log4j</artifactId>
+        <version>0.6.0-SNAPSHOT</version>
+      </dependency>
+      <dependency>
+        <groupId>io.servicecomb.samples</groupId>
+        <artifactId>metrics-write-file-config-log4j2</artifactId>
+        <version>0.6.0-SNAPSHOT</version>
+      </dependency>
+      <dependency>
+        <groupId>io.servicecomb.samples</groupId>
+        <artifactId>metrics-write-file</artifactId>
+        <version>0.6.0-SNAPSHOT</version>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+</project>
\ No newline at end of file
diff --git a/samples/pom.xml b/samples/pom.xml
index a12e858db..d83bf3950 100644
--- a/samples/pom.xml
+++ b/samples/pom.xml
@@ -16,81 +16,81 @@
   ~ limitations under the License.
   -->
 <project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
 
-    <groupId>io.servicecomb.samples</groupId>
-    <artifactId>samples</artifactId>
-    <packaging>pom</packaging>
-    <version>0.6.0-SNAPSHOT</version>
-    <modules>
-        <module>codefirst-sample</module>
-        <module>custom-handler-sample</module>
-        <module>jaxrs-sample</module>
-        <module>pojo-sample</module>
-        <module>springmvc-sample</module>
-        <module>common-schema</module>
-        <module>auth-sample</module>
-        <module>bmi</module>
+  <groupId>io.servicecomb.samples</groupId>
+  <artifactId>samples</artifactId>
+  <packaging>pom</packaging>
+  <version>0.6.0-SNAPSHOT</version>
+  <modules>
+    <module>codefirst-sample</module>
+    <module>custom-handler-sample</module>
+    <module>jaxrs-sample</module>
+    <module>pojo-sample</module>
+    <module>springmvc-sample</module>
+    <module>common-schema</module>
+    <module>auth-sample</module>
+    <module>bmi</module>
+    <module>metrics-write-file-sample</module>
+  </modules>
 
-    </modules>
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>io.servicecomb</groupId>
+        <artifactId>java-chassis-dependencies</artifactId>
+        <version>0.6.0-SNAPSHOT</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+      <dependency>
+        <groupId>io.servicecomb.samples</groupId>
+        <artifactId>common-schema</artifactId>
+        <version>0.6.0-SNAPSHOT</version>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
 
-    <dependencyManagement>
-        <dependencies>
-            <dependency>
-                <groupId>io.servicecomb</groupId>
-                <artifactId>java-chassis-dependencies</artifactId>
-                <version>0.6.0-SNAPSHOT</version>
-                <type>pom</type>
-                <scope>import</scope>
-            </dependency>
-            <dependency>
-                <groupId>io.servicecomb.samples</groupId>
-                <artifactId>common-schema</artifactId>
-                <version>0.6.0-SNAPSHOT</version>
-            </dependency>
-        </dependencies>
-    </dependencyManagement>
-
-    <build>
-        <plugins>
-            <!-- ??????jdk1.8?? -->
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <version>3.1</version>
-                <configuration>
-                    <compilerArgument>-parameters</compilerArgument>
-                    <encoding>UTF-8</encoding>
-                    <source>1.8</source>
-                    <target>1.8</target>
-                </configuration>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-deploy-plugin</artifactId>
-                <configuration>
-                    <skip>true</skip>
-                </configuration>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.rat</groupId>
-                <artifactId>apache-rat-plugin</artifactId>
-                <configuration>
-                    <excludes>
-                        <exclude>.travis.yml</exclude>
-                        <exclude>**/*.md</exclude>
-                        <exclude>**/target/*</exclude>
-                        <!-- Skip the ssl configuration files -->
-                        <exculde>**/resources/ssl/**</exculde>
-                        <!-- Skip the protobuf files -->
-                        <exclude>**/*.proto</exclude>
-                        <!-- Skip the idl files -->
-                        <exclude>**/*.idl</exclude>
-                    </excludes>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
+  <build>
+    <plugins>
+      <!-- ??????jdk1.8?? -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>3.1</version>
+        <configuration>
+          <compilerArgument>-parameters</compilerArgument>
+          <encoding>UTF-8</encoding>
+          <source>1.8</source>
+          <target>1.8</target>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-deploy-plugin</artifactId>
+        <configuration>
+          <skip>true</skip>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.rat</groupId>
+        <artifactId>apache-rat-plugin</artifactId>
+        <configuration>
+          <excludes>
+            <exclude>.travis.yml</exclude>
+            <exclude>**/*.md</exclude>
+            <exclude>**/target/*</exclude>
+            <!-- Skip the ssl configuration files -->
+            <exculde>**/resources/ssl/**</exculde>
+            <!-- Skip the protobuf files -->
+            <exclude>**/*.proto</exclude>
+            <!-- Skip the idl files -->
+            <exclude>**/*.idl</exclude>
+          </excludes>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
 </project>
diff --git a/samples/springmvc-sample/springmvc-consumer/src/main/java/io/servicecomb/samples/springmvc/consumer/SpringmvcConsumerMain.java b/samples/springmvc-sample/springmvc-consumer/src/main/java/io/servicecomb/samples/springmvc/consumer/SpringmvcConsumerMain.java
index 35fcffe61..9ad487535 100644
--- a/samples/springmvc-sample/springmvc-consumer/src/main/java/io/servicecomb/samples/springmvc/consumer/SpringmvcConsumerMain.java
+++ b/samples/springmvc-sample/springmvc-consumer/src/main/java/io/servicecomb/samples/springmvc/consumer/SpringmvcConsumerMain.java
@@ -16,15 +16,10 @@
  */
 package io.servicecomb.samples.springmvc.consumer;
 
-import java.util.HashMap;
-import java.util.Map;
-
 import org.springframework.stereotype.Component;
 import org.springframework.web.client.RestTemplate;
 
-import io.servicecomb.foundation.common.exceptions.ServiceCombException;
 import io.servicecomb.foundation.common.utils.BeanUtils;
-import io.servicecomb.foundation.common.utils.JsonUtils;
 import io.servicecomb.foundation.common.utils.Log4jUtils;
 import io.servicecomb.provider.pojo.RpcReference;
 import io.servicecomb.provider.springmvc.reference.RestTemplateBuilder;
@@ -56,26 +51,6 @@ public static void main(String[] args) throws Exception {
     // POJO Consumer
     System.out.println("POJO consumer sayhi services: " + hello.sayHi("Java Chassis"));
     System.out.println("POJO consumer sayhi services: " + hello.sayHello(person));
-
-    String metricsResult = restTemplate.getForObject("cse://springmvc/springmvchello/metricsForTest/", String.class);
-
-    @SuppressWarnings("unchecked")
-    Map<String, String> resultMap = JsonUtils.OBJ_MAPPER.readValue(metricsResult, HashMap.class);
-
-    if (!resultMap.get("CPU and Memory").contains("heapUsed=")) {
-      throw new ServiceCombException("check metrics error");
-    }
-
-    if (!resultMap.get("totalRequestProvider OPERATIONAL_LEVEL")
-        .equals("{springmvc.springmvcHello.sayHi=2, springmvc.springmvcHello.sayHello=2, springmvc.springmvcHello.metricsForTest=1}")) {
-      throw new ServiceCombException("check metrics error");
-    }
-
-    if (!resultMap.get("RequestQueueRelated").contains("springmvc.springmvcHello.sayHi") ||
-        !resultMap.get("RequestQueueRelated").contains("springmvc.springmvcHello.sayHello")){
-      throw new ServiceCombException("check metrics error");
-    }
-
   }
 
   public static void init() throws Exception {
diff --git a/samples/springmvc-sample/springmvc-provider/src/main/java/io/servicecomb/samples/springmvc/provider/SpringmvcHelloImpl.java b/samples/springmvc-sample/springmvc-provider/src/main/java/io/servicecomb/samples/springmvc/provider/SpringmvcHelloImpl.java
index a5f2317e4..328fd94f5 100644
--- a/samples/springmvc-sample/springmvc-provider/src/main/java/io/servicecomb/samples/springmvc/provider/SpringmvcHelloImpl.java
+++ b/samples/springmvc-sample/springmvc-provider/src/main/java/io/servicecomb/samples/springmvc/provider/SpringmvcHelloImpl.java
@@ -18,10 +18,6 @@
 package io.servicecomb.samples.springmvc.provider;
 
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 import javax.ws.rs.core.MediaType;
 
 import org.springframework.beans.factory.annotation.Autowired;
@@ -30,10 +26,6 @@
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.netflix.servo.monitor.Monitor;
-
-import io.servicecomb.foundation.common.utils.JsonUtils;
 import io.servicecomb.foundation.metrics.MetricsServoRegistry;
 import io.servicecomb.provider.rest.common.RestSchema;
 import io.servicecomb.samples.common.schema.Hello;
@@ -61,19 +53,4 @@ public String sayHi(@RequestParam(name = "name") String name) {
   public String sayHello(@RequestBody Person person) {
     return "Hello person " + person.getName();
   }
-
-  //metrics it test
-  @RequestMapping(path = "/metricsForTest", method = RequestMethod.GET)
-  public String metricsForTest() {
-    List<Monitor<?>> monitors = registry.getMetricsMonitors();
-    Map<String, String> values = new HashMap<>();
-    for (Monitor<?> monitor : monitors) {
-      values.put(monitor.getConfig().getName(), monitor.getValue().toString());
-    }
-    try {
-      return JsonUtils.writeValueAsString(values);
-    } catch (JsonProcessingException e) {
-      return "{}";
-    }
-  }
 }


 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services