You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2018/01/09 08:57:31 UTC

[incubator-servicecomb-java-chassis] branch master updated (e39c7d1 -> 4e4b398)

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

liubao pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git.


    from e39c7d1  [SCB-188] Transport optimize for reactive (#495)
     new 5c97791  SCB-118 add prometheus integration impl
     new aaa6785  SCB-118 fix ci failed
     new 79cbd0b  SCB-118 change publish interface method metricsWithWindowTimeIndex -> metricsWithWindowTime
     new cbb41a2  SCB-118 fix pr comment
     new 3b86005  SCB-118 add integration test in demo-springmvc
     new 72b553f  SCB-118 enhance integration test check
     new 589c79b  SCB-118 remove metrics perf samples
     new bd742f4  SCB-118 resolve conflict
     new 4e4b398  SCB-118 resolve conflict

The 9 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../demo/springmvc/client/SpringmvcClient.java     | 32 +++++++++
 demo/demo-springmvc/springmvc-server/pom.xml       |  2 +-
 .../demo/springmvc/server/CodeFirstSpringmvc.java  |  8 +++
 .../src/main/resources/microservice.yaml           |  2 +-
 java-chassis-dependencies/pom.xml                  | 16 +++++
 .../metrics/common/ConsumerInvocationMetric.java   |  4 +-
 .../servicecomb/metrics/common/InstanceMetric.java | 11 ++++
 .../metrics/common/MetricsPublisher.java           |  2 +-
 .../metrics/common/ProducerInvocationMetric.java   |  8 +--
 .../servicecomb/metrics/common/RegistryMetric.java |  6 +-
 .../core/publish/DefaultMetricsPublisher.java      |  2 +-
 .../metrics/core/TestEventAndRunner.java           |  2 +-
 .../io/servicecomb/metrics/core/TestPublisher.java |  6 +-
 .../metrics-prometheus}/pom.xml                    | 18 +++--
 .../metrics/prometheus/MetricsCollector.java       | 77 ++++++++++++++++++++++
 .../metrics/prometheus/MetricsPublisher.java       | 52 +++++++++++++++
 .../pom.xml                                        |  2 +-
 metrics/pom.xml                                    |  1 +
 .../src/main/resources/microservice.yaml           | 34 ----------
 .../samples/mwf/ServiceApplication.java            | 31 ---------
 20 files changed, 226 insertions(+), 90 deletions(-)
 copy {spring-boot-starter/spring-boot-starter-provider => metrics/metrics-integration/metrics-prometheus}/pom.xml (78%)
 create mode 100644 metrics/metrics-integration/metrics-prometheus/src/main/java/io/servicecomb/metrics/prometheus/MetricsCollector.java
 create mode 100644 metrics/metrics-integration/metrics-prometheus/src/main/java/io/servicecomb/metrics/prometheus/MetricsPublisher.java
 copy metrics/{metrics-extension => metrics-integration}/pom.xml (95%)
 delete mode 100644 samples/bmi/calculator/src/main/resources/microservice.yaml
 delete mode 100644 samples/metrics-write-file-sample/metrics-write-file-log4j-springboot/src/main/java/io/servicecomb/samples/mwf/ServiceApplication.java

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

[incubator-servicecomb-java-chassis] 05/09: SCB-118 add integration test in demo-springmvc

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git

commit 3b86005e1c4744330f4e8b5814d260d0ebf81bc6
Author: zhengyangyong <ya...@huawei.com>
AuthorDate: Mon Jan 8 19:46:00 2018 +0800

    SCB-118 add integration test in demo-springmvc
    
    Signed-off-by: zhengyangyong <ya...@huawei.com>
---
 .../demo/springmvc/client/SpringmvcClient.java     | 23 ++++++++++++++++++++++
 demo/demo-springmvc/springmvc-server/pom.xml       |  2 +-
 .../demo/springmvc/server/CodeFirstSpringmvc.java  |  8 ++++++++
 .../src/main/resources/microservice.yaml           |  2 +-
 .../metrics/prometheus/MetricsCollector.java       |  2 +-
 5 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/demo/demo-springmvc/springmvc-client/src/main/java/io/servicecomb/demo/springmvc/client/SpringmvcClient.java b/demo/demo-springmvc/springmvc-client/src/main/java/io/servicecomb/demo/springmvc/client/SpringmvcClient.java
index bd23433..46fc8a6 100644
--- a/demo/demo-springmvc/springmvc-client/src/main/java/io/servicecomb/demo/springmvc/client/SpringmvcClient.java
+++ b/demo/demo-springmvc/springmvc-client/src/main/java/io/servicecomb/demo/springmvc/client/SpringmvcClient.java
@@ -128,6 +128,29 @@ public class SpringmvcClient {
     } catch (Exception e) {
       TestMgr.check("true", "false");
     }
+
+    //prometheus integration test
+    try {
+      String content = restTemplate.getForObject("cse://springmvc/codeFirstSpringmvc/prometheusForTest", String.class);
+      String[] metricLines = content.split("\n");
+      if (metricLines.length > 0) {
+        for (String metricLine : metricLines) {
+          if (!metricLine.startsWith("#")) {
+            String[] metricKeyAndValue = metricLine.split(" ");
+            if (!metricKeyAndValue[0].startsWith("servicecomb_instance_system")) {
+              if (Double.parseDouble(metricKeyAndValue[1]) < 0) {
+                TestMgr.check("true", "false");
+                break;
+              }
+            }
+          }
+        }
+      } else {
+        TestMgr.check("true", "false");
+      }
+    } catch (Exception e) {
+      TestMgr.check("true", "false");
+    }
   }
 
   private static void testController(RestTemplate template, String microserviceName) {
diff --git a/demo/demo-springmvc/springmvc-server/pom.xml b/demo/demo-springmvc/springmvc-server/pom.xml
index 772e35f..43a7551 100644
--- a/demo/demo-springmvc/springmvc-server/pom.xml
+++ b/demo/demo-springmvc/springmvc-server/pom.xml
@@ -39,7 +39,7 @@
 
 		<dependency>
 			<groupId>io.servicecomb</groupId>
-			<artifactId>metrics-core</artifactId>
+			<artifactId>metrics-prometheus</artifactId>
 		</dependency>
 
 	</dependencies>
diff --git a/demo/demo-springmvc/springmvc-server/src/main/java/io/servicecomb/demo/springmvc/server/CodeFirstSpringmvc.java b/demo/demo-springmvc/springmvc-server/src/main/java/io/servicecomb/demo/springmvc/server/CodeFirstSpringmvc.java
index a244e03..8011dbf 100644
--- a/demo/demo-springmvc/springmvc-server/src/main/java/io/servicecomb/demo/springmvc/server/CodeFirstSpringmvc.java
+++ b/demo/demo-springmvc/springmvc-server/src/main/java/io/servicecomb/demo/springmvc/server/CodeFirstSpringmvc.java
@@ -50,6 +50,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RequestPart;
 import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.client.RestTemplate;
 import org.springframework.web.multipart.MultipartFile;
 
 import com.fasterxml.jackson.core.JsonProcessingException;
@@ -352,6 +353,13 @@ public class CodeFirstSpringmvc {
     }
   }
 
+  //Only for Prometheus integration test
+  @RequestMapping(path = "/prometheusForTest", method = RequestMethod.GET)
+  public String prometheusForTest() {
+    RestTemplate defaultRestTemplate = new RestTemplate();
+    return defaultRestTemplate.getForObject("http://localhost:9696/metrics", String.class);
+  }
+
   @GetMapping(path = "/traceId")
   public String getTraceId() {
     return ContextUtils.getInvocationContext().getContext(Const.TRACE_ID_NAME);
diff --git a/demo/demo-springmvc/springmvc-server/src/main/resources/microservice.yaml b/demo/demo-springmvc/springmvc-server/src/main/resources/microservice.yaml
index f5d2304..034f0d0 100644
--- a/demo/demo-springmvc/springmvc-server/src/main/resources/microservice.yaml
+++ b/demo/demo-springmvc/springmvc-server/src/main/resources/microservice.yaml
@@ -20,7 +20,7 @@ servicecomb:
 APPLICATION_ID: springmvctest
 service_description:
   name: springmvc
-  version: 0.0.2
+  version: 0.0.3
   paths:
     - path: /test1/testpath
       property:
diff --git a/metrics/metrics-integration/metrics-prometheus/src/main/java/io/servicecomb/metrics/prometheus/MetricsCollector.java b/metrics/metrics-integration/metrics-prometheus/src/main/java/io/servicecomb/metrics/prometheus/MetricsCollector.java
index 863736b..c6dd37e 100644
--- a/metrics/metrics-integration/metrics-prometheus/src/main/java/io/servicecomb/metrics/prometheus/MetricsCollector.java
+++ b/metrics/metrics-integration/metrics-prometheus/src/main/java/io/servicecomb/metrics/prometheus/MetricsCollector.java
@@ -54,7 +54,7 @@ public class MetricsCollector extends Collector implements Collector.Describable
   }
 
   private List<MetricFamilySamples> load() {
-    RegistryMetric registryMetric = dataSource.getRegistryMetric(0);
+    RegistryMetric registryMetric = dataSource.getRegistryMetric();
     List<MetricFamilySamples> familySamples = new ArrayList<>();
     familySamples.add(getFamilySamples("Instance Level", registryMetric.getInstanceMetric().toMap()));
     for (Entry<String, ConsumerInvocationMetric> consumerMetric : registryMetric.getConsumerMetrics().entrySet()) {

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

[incubator-servicecomb-java-chassis] 03/09: SCB-118 change publish interface method metricsWithWindowTimeIndex -> metricsWithWindowTime

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git

commit 79cbd0b060c8e0beb021791da1f019a391417327
Author: zhengyangyong <ya...@huawei.com>
AuthorDate: Thu Jan 4 09:33:55 2018 +0800

    SCB-118 change publish interface method metricsWithWindowTimeIndex -> metricsWithWindowTime
    
    Signed-off-by: zhengyangyong <ya...@huawei.com>
---
 .../src/main/java/io/servicecomb/metrics/common/MetricsPublisher.java   | 2 +-
 .../io/servicecomb/metrics/core/publish/DefaultMetricsPublisher.java    | 2 +-
 .../src/test/java/io/servicecomb/metrics/core/TestPublisher.java        | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/metrics/metrics-common/src/main/java/io/servicecomb/metrics/common/MetricsPublisher.java b/metrics/metrics-common/src/main/java/io/servicecomb/metrics/common/MetricsPublisher.java
index 5e66a10..c2c2be5 100644
--- a/metrics/metrics-common/src/main/java/io/servicecomb/metrics/common/MetricsPublisher.java
+++ b/metrics/metrics-common/src/main/java/io/servicecomb/metrics/common/MetricsPublisher.java
@@ -55,5 +55,5 @@ public interface MetricsPublisher {
    * @param windowTime getAppliedWindowTime() item
    * @return RegistryMetric
    */
-  RegistryMetric metricsWithWindowTimeIndex(long windowTime);
+  RegistryMetric metricsWithWindowTime(long windowTime);
 }
diff --git a/metrics/metrics-core/src/main/java/io/servicecomb/metrics/core/publish/DefaultMetricsPublisher.java b/metrics/metrics-core/src/main/java/io/servicecomb/metrics/core/publish/DefaultMetricsPublisher.java
index e031161..1e313d0 100644
--- a/metrics/metrics-core/src/main/java/io/servicecomb/metrics/core/publish/DefaultMetricsPublisher.java
+++ b/metrics/metrics-core/src/main/java/io/servicecomb/metrics/core/publish/DefaultMetricsPublisher.java
@@ -60,7 +60,7 @@ public class DefaultMetricsPublisher implements MetricsPublisher {
   @RequestMapping(path = "/{windowTime}", method = RequestMethod.GET)
   @CrossOrigin
   @Override
-  public RegistryMetric metricsWithWindowTimeIndex(@PathVariable(name = "windowTime") long windowTime) {
+  public RegistryMetric metricsWithWindowTime(@PathVariable(name = "windowTime") long windowTime) {
     return dataSource.getRegistryMetric(windowTime);
   }
 }
diff --git a/metrics/metrics-core/src/test/java/io/servicecomb/metrics/core/TestPublisher.java b/metrics/metrics-core/src/test/java/io/servicecomb/metrics/core/TestPublisher.java
index 790299a..a0921da 100644
--- a/metrics/metrics-core/src/test/java/io/servicecomb/metrics/core/TestPublisher.java
+++ b/metrics/metrics-core/src/test/java/io/servicecomb/metrics/core/TestPublisher.java
@@ -47,7 +47,7 @@ public class TestPublisher {
     Map<String, Number> metricsMap = registryMetric.toMap();
     Assert.assertEquals(35, metricsMap.size());
 
-    registryMetric = publisher.metricsWithWindowTimeIndex(1000);
+    registryMetric = publisher.metricsWithWindowTime(1000);
     metricsMap = registryMetric.toMap();
     Assert.assertEquals(35, metricsMap.size());
 

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

[incubator-servicecomb-java-chassis] 08/09: SCB-118 resolve conflict

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git

commit bd742f47c429599691d4806028b42cf57a5b8a6d
Author: zhengyangyong <ya...@huawei.com>
AuthorDate: Tue Jan 9 14:52:09 2018 +0800

    SCB-118 resolve conflict
    
    Signed-off-by: zhengyangyong <ya...@huawei.com>
---
 metrics/metrics-integration/pom.xml | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/metrics/metrics-integration/pom.xml b/metrics/metrics-integration/pom.xml
new file mode 100644
index 0000000..a597152
--- /dev/null
+++ b/metrics/metrics-integration/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</artifactId>
+    <groupId>io.servicecomb</groupId>
+    <version>0.6.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>metrics-integration</artifactId>
+  <packaging>pom</packaging>
+
+</project>
\ No newline at end of file

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

[incubator-servicecomb-java-chassis] 07/09: SCB-118 remove metrics perf samples

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git

commit 589c79bedae962f8fb8204059fbe33e393fe5ad1
Author: zhengyangyong <ya...@huawei.com>
AuthorDate: Tue Jan 9 11:07:43 2018 +0800

    SCB-118 remove metrics perf samples
    
    Signed-off-by: zhengyangyong <ya...@huawei.com>
---
 metrics/metrics-integration/pom.xml                | 36 ----------
 .../src/main/resources/microservice.yaml           | 34 ---------
 .../samples/mwf/ServiceApplication.java            | 31 ---------
 .../metrics-write-file-log4j2-springboot/pom.xml   | 80 ----------------------
 4 files changed, 181 deletions(-)

diff --git a/metrics/metrics-integration/pom.xml b/metrics/metrics-integration/pom.xml
deleted file mode 100644
index c94879a..0000000
--- a/metrics/metrics-integration/pom.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?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</artifactId>
-    <groupId>io.servicecomb</groupId>
-    <version>0.6.0-SNAPSHOT</version>
-  </parent>
-  <modelVersion>4.0.0</modelVersion>
-
-  <artifactId>metrics-integration</artifactId>
-  <packaging>pom</packaging>
-  <modules>
-    <module>metrics-prometheus</module>
-  </modules>
-
-
-</project>
\ No newline at end of file
diff --git a/samples/bmi/calculator/src/main/resources/microservice.yaml b/samples/bmi/calculator/src/main/resources/microservice.yaml
deleted file mode 100644
index a7a7a6b..0000000
--- a/samples/bmi/calculator/src/main/resources/microservice.yaml
+++ /dev/null
@@ -1,34 +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.
-## ---------------------------------------------------------------------------
-
-# all interconnected microservices must belong to an application wth the same ID
-APPLICATION_ID: bmi
-service_description:
-# name of the declaring microservice
-  name: calculator
-  version: 0.0.1
-cse:
-  service:
-    registry:
-      address: http://127.0.0.1:30100
-  rest:
-    address: 0.0.0.0:7777
-  handler:
-    chain:
-      Provider:
-        default: bizkeeper-provider
\ No newline at end of file
diff --git a/samples/metrics-write-file-sample/metrics-write-file-log4j-springboot/src/main/java/io/servicecomb/samples/mwf/ServiceApplication.java b/samples/metrics-write-file-sample/metrics-write-file-log4j-springboot/src/main/java/io/servicecomb/samples/mwf/ServiceApplication.java
deleted file mode 100644
index bfb4354..0000000
--- a/samples/metrics-write-file-sample/metrics-write-file-log4j-springboot/src/main/java/io/servicecomb/samples/mwf/ServiceApplication.java
+++ /dev/null
@@ -1,31 +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.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/pom.xml b/samples/metrics-write-file-sample/metrics-write-file-log4j2-springboot/pom.xml
deleted file mode 100644
index 24612e3..0000000
--- a/samples/metrics-write-file-sample/metrics-write-file-log4j2-springboot/pom.xml
+++ /dev/null
@@ -1,80 +0,0 @@
-<?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-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>
-
-    <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>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.springframework.boot</groupId>
-        <artifactId>spring-boot-maven-plugin</artifactId>
-      </plugin>
-    </plugins>
-  </build>
-
-</project>
\ No newline at end of file

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

[incubator-servicecomb-java-chassis] 09/09: SCB-118 resolve conflict

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git

commit 4e4b398925cbd57ec54593cc467ed4adf96f1c87
Author: zhengyangyong <ya...@huawei.com>
AuthorDate: Tue Jan 9 16:01:12 2018 +0800

    SCB-118 resolve conflict
    
    Signed-off-by: zhengyangyong <ya...@huawei.com>
---
 .../metrics-write-file-log4j2-springboot/pom.xml   | 80 ++++++++++++++++++++++
 1 file changed, 80 insertions(+)

diff --git a/samples/metrics-write-file-sample/metrics-write-file-log4j2-springboot/pom.xml b/samples/metrics-write-file-sample/metrics-write-file-log4j2-springboot/pom.xml
new file mode 100644
index 0000000..24612e3
--- /dev/null
+++ b/samples/metrics-write-file-sample/metrics-write-file-log4j2-springboot/pom.xml
@@ -0,0 +1,80 @@
+<?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-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>
+
+    <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>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-maven-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
\ No newline at end of file

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

[incubator-servicecomb-java-chassis] 02/09: SCB-118 fix ci failed

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git

commit aaa6785646c5dd94a7ce829c4507fdd23229b855
Author: zhengyangyong <ya...@huawei.com>
AuthorDate: Wed Jan 3 19:00:40 2018 +0800

    SCB-118 fix ci failed
    
    Signed-off-by: zhengyangyong <ya...@huawei.com>
---
 .../src/test/java/io/servicecomb/metrics/core/TestEventAndRunner.java | 2 +-
 .../src/test/java/io/servicecomb/metrics/core/TestPublisher.java      | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/metrics/metrics-core/src/test/java/io/servicecomb/metrics/core/TestEventAndRunner.java b/metrics/metrics-core/src/test/java/io/servicecomb/metrics/core/TestEventAndRunner.java
index 7c6ced3..6ae2a95 100644
--- a/metrics/metrics-core/src/test/java/io/servicecomb/metrics/core/TestEventAndRunner.java
+++ b/metrics/metrics-core/src/test/java/io/servicecomb/metrics/core/TestEventAndRunner.java
@@ -250,7 +250,7 @@ public class TestEventAndRunner {
     Assert.assertEquals(model.getConsumerMetrics().get("fun2").getConsumerCall().getTotal(), 1);
 
     Map<String, Number> metrics = model.toMap();
-    Assert.assertEquals(metrics.size(), 72);
+    Assert.assertEquals(96, metrics.size());
 
     Assert.assertEquals(model.getInstanceMetric().getSystemMetric().getCpuLoad(), 1.0, 0);
     Assert.assertEquals(model.getInstanceMetric().getSystemMetric().getCpuRunningThreads(), 2, 0);
diff --git a/metrics/metrics-core/src/test/java/io/servicecomb/metrics/core/TestPublisher.java b/metrics/metrics-core/src/test/java/io/servicecomb/metrics/core/TestPublisher.java
index 4c60167..790299a 100644
--- a/metrics/metrics-core/src/test/java/io/servicecomb/metrics/core/TestPublisher.java
+++ b/metrics/metrics-core/src/test/java/io/servicecomb/metrics/core/TestPublisher.java
@@ -45,11 +45,11 @@ public class TestPublisher {
 
     RegistryMetric registryMetric = publisher.metrics();
     Map<String, Number> metricsMap = registryMetric.toMap();
-    Assert.assertEquals(metricsMap.size(), 30);
+    Assert.assertEquals(35, metricsMap.size());
 
     registryMetric = publisher.metricsWithWindowTimeIndex(1000);
     metricsMap = registryMetric.toMap();
-    Assert.assertEquals(metricsMap.size(), 30);
+    Assert.assertEquals(35, metricsMap.size());
 
     List<Long> appliedWindowTime = publisher.getAppliedWindowTime();
     Assert.assertEquals(appliedWindowTime.size(), 3);

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

[incubator-servicecomb-java-chassis] 06/09: SCB-118 enhance integration test check

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git

commit 72b553f6f928f5ec48b3bf19c8e4ceefd44883f9
Author: zhengyangyong <ya...@huawei.com>
AuthorDate: Tue Jan 9 09:01:21 2018 +0800

    SCB-118 enhance integration test check
    
    Signed-off-by: zhengyangyong <ya...@huawei.com>
---
 .../io/servicecomb/demo/springmvc/client/SpringmvcClient.java    | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/demo/demo-springmvc/springmvc-client/src/main/java/io/servicecomb/demo/springmvc/client/SpringmvcClient.java b/demo/demo-springmvc/springmvc-client/src/main/java/io/servicecomb/demo/springmvc/client/SpringmvcClient.java
index 46fc8a6..f03b9b4 100644
--- a/demo/demo-springmvc/springmvc-client/src/main/java/io/servicecomb/demo/springmvc/client/SpringmvcClient.java
+++ b/demo/demo-springmvc/springmvc-client/src/main/java/io/servicecomb/demo/springmvc/client/SpringmvcClient.java
@@ -132,6 +132,15 @@ public class SpringmvcClient {
     //prometheus integration test
     try {
       String content = restTemplate.getForObject("cse://springmvc/codeFirstSpringmvc/prometheusForTest", String.class);
+
+      TestMgr.check(true,content.contains("servicecomb_springmvc_codeFirst_addDate"));
+      TestMgr.check(true,content.contains("servicecomb_springmvc_codeFirst_sayHello"));
+      TestMgr.check(true,content.contains("servicecomb_springmvc_codeFirst_fallbackFromCache"));
+      TestMgr.check(true,content.contains("servicecomb_springmvc_codeFirst_isTrue_producer"));
+      TestMgr.check(true,content.contains("servicecomb_springmvc_codeFirst_add"));
+      TestMgr.check(true,content.contains("servicecomb_springmvc_codeFirst_sayHi2"));
+      TestMgr.check(true,content.contains("servicecomb_springmvc_codeFirst_saySomething"));
+
       String[] metricLines = content.split("\n");
       if (metricLines.length > 0) {
         for (String metricLine : metricLines) {

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

[incubator-servicecomb-java-chassis] 04/09: SCB-118 fix pr comment

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git

commit cbb41a26feaacc82a59e39e3766dea90e1f904cb
Author: zhengyangyong <ya...@huawei.com>
AuthorDate: Mon Jan 8 10:10:49 2018 +0800

    SCB-118 fix pr comment
    
    Signed-off-by: zhengyangyong <ya...@huawei.com>
---
 .../src/main/java/io/servicecomb/metrics/common/RegistryMetric.java     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/metrics/metrics-common/src/main/java/io/servicecomb/metrics/common/RegistryMetric.java b/metrics/metrics-common/src/main/java/io/servicecomb/metrics/common/RegistryMetric.java
index 4b08a7a..29958ec 100644
--- a/metrics/metrics-common/src/main/java/io/servicecomb/metrics/common/RegistryMetric.java
+++ b/metrics/metrics-common/src/main/java/io/servicecomb/metrics/common/RegistryMetric.java
@@ -57,7 +57,7 @@ public class RegistryMetric {
 
     ConsumerInvocationMetric instanceConsumerInvocationMetric = new ConsumerInvocationMetric("instance",
         MetricsConst.INSTANCE_CONSUMER_PREFIX,
-        new TimerMetric(MetricsConst.INSTANCE_CONSUMER_PREFIX + ".producerLatency"),
+        new TimerMetric(MetricsConst.INSTANCE_CONSUMER_PREFIX + ".consumerLatency"),
         new CallMetric(MetricsConst.INSTANCE_CONSUMER_PREFIX + ".consumerCall"));
     ProducerInvocationMetric instanceProducerInvocationMetric = new ProducerInvocationMetric("instance",
         MetricsConst.INSTANCE_PRODUCER_PREFIX, 0,

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

[incubator-servicecomb-java-chassis] 01/09: SCB-118 add prometheus integration impl

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git

commit 5c97791758e9d487d7ac0ebae95ee36f8dd01944
Author: zhengyangyong <ya...@huawei.com>
AuthorDate: Tue Jan 2 12:57:06 2018 +0800

    SCB-118 add prometheus integration impl
    
    Signed-off-by: zhengyangyong <ya...@huawei.com>
---
 java-chassis-dependencies/pom.xml                  | 16 +++++
 .../metrics/common/ConsumerInvocationMetric.java   |  4 +-
 .../servicecomb/metrics/common/InstanceMetric.java | 11 ++++
 .../metrics/common/ProducerInvocationMetric.java   |  8 +--
 .../servicecomb/metrics/common/RegistryMetric.java |  6 +-
 .../metrics-prometheus}/pom.xml                    | 30 ++++++---
 .../metrics/prometheus/MetricsCollector.java       | 77 ++++++++++++++++++++++
 .../metrics/prometheus/MetricsPublisher.java       | 52 +++++++++++++++
 metrics/{ => metrics-integration}/pom.xml          | 16 ++---
 metrics/pom.xml                                    |  1 +
 10 files changed, 192 insertions(+), 29 deletions(-)

diff --git a/java-chassis-dependencies/pom.xml b/java-chassis-dependencies/pom.xml
index 7c7f351..a111a3f 100644
--- a/java-chassis-dependencies/pom.xml
+++ b/java-chassis-dependencies/pom.xml
@@ -699,6 +699,17 @@
       </dependency>
 
       <dependency>
+        <groupId>io.prometheus</groupId>
+        <artifactId>simpleclient</artifactId>
+        <version>0.1.0</version>
+      </dependency>
+      <dependency>
+        <groupId>io.prometheus</groupId>
+        <artifactId>simpleclient_httpserver</artifactId>
+        <version>0.1.0</version>
+      </dependency>
+
+      <dependency>
         <groupId>io.servicecomb</groupId>
         <artifactId>foundation-common</artifactId>
         <version>0.6.0-SNAPSHOT</version>
@@ -954,6 +965,11 @@
         <artifactId>metrics-common</artifactId>
         <version>0.6.0-SNAPSHOT</version>
       </dependency>
+      <dependency>
+        <groupId>io.servicecomb</groupId>
+        <artifactId>metrics-prometheus</artifactId>
+        <version>0.6.0-SNAPSHOT</version>
+      </dependency>
     </dependencies>
   </dependencyManagement>
 
diff --git a/metrics/metrics-common/src/main/java/io/servicecomb/metrics/common/ConsumerInvocationMetric.java b/metrics/metrics-common/src/main/java/io/servicecomb/metrics/common/ConsumerInvocationMetric.java
index d4aee4a..bbd5f07 100644
--- a/metrics/metrics-common/src/main/java/io/servicecomb/metrics/common/ConsumerInvocationMetric.java
+++ b/metrics/metrics-common/src/main/java/io/servicecomb/metrics/common/ConsumerInvocationMetric.java
@@ -46,8 +46,8 @@ public class ConsumerInvocationMetric extends InvocationMetric {
 
   public ConsumerInvocationMetric merge(ConsumerInvocationMetric metric) {
     return new ConsumerInvocationMetric(this.getOperationName(), this.getPrefix(),
-        metric.getConsumerLatency().merge(consumerLatency),
-        metric.getConsumerCall().merge(consumerCall));
+        consumerLatency.merge(metric.getConsumerLatency()),
+        consumerCall.merge(metric.getConsumerCall()));
   }
 
   public Map<String, Number> toMap() {
diff --git a/metrics/metrics-common/src/main/java/io/servicecomb/metrics/common/InstanceMetric.java b/metrics/metrics-common/src/main/java/io/servicecomb/metrics/common/InstanceMetric.java
index b8dd03e..c7dd0c2 100644
--- a/metrics/metrics-common/src/main/java/io/servicecomb/metrics/common/InstanceMetric.java
+++ b/metrics/metrics-common/src/main/java/io/servicecomb/metrics/common/InstanceMetric.java
@@ -17,6 +17,9 @@
 
 package io.servicecomb.metrics.common;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import com.fasterxml.jackson.annotation.JsonProperty;
 
 public class InstanceMetric {
@@ -45,4 +48,12 @@ public class InstanceMetric {
     this.consumerMetric = consumerMetric;
     this.producerMetric = producerMetric;
   }
+
+  public Map<String, Number> toMap() {
+    Map<String, Number> metrics = new HashMap<>();
+    metrics.putAll(systemMetric.toMap());
+    metrics.putAll(consumerMetric.toMap());
+    metrics.putAll(producerMetric.toMap());
+    return metrics;
+  }
 }
diff --git a/metrics/metrics-common/src/main/java/io/servicecomb/metrics/common/ProducerInvocationMetric.java b/metrics/metrics-common/src/main/java/io/servicecomb/metrics/common/ProducerInvocationMetric.java
index aced1c7..511d792 100644
--- a/metrics/metrics-common/src/main/java/io/servicecomb/metrics/common/ProducerInvocationMetric.java
+++ b/metrics/metrics-common/src/main/java/io/servicecomb/metrics/common/ProducerInvocationMetric.java
@@ -71,10 +71,10 @@ public class ProducerInvocationMetric extends InvocationMetric {
   public ProducerInvocationMetric merge(ProducerInvocationMetric metric) {
     return new ProducerInvocationMetric(this.getOperationName(), this.getPrefix(),
         this.getWaitInQueue() + metric.getWaitInQueue(),
-        metric.getLifeTimeInQueue().merge(lifeTimeInQueue),
-        metric.getExecutionTime().merge(executionTime),
-        metric.getProducerLatency().merge(producerLatency),
-        metric.getProducerCall().merge(producerCall));
+        lifeTimeInQueue.merge(metric.getLifeTimeInQueue()),
+        executionTime.merge(metric.getExecutionTime()),
+        producerLatency.merge(metric.getProducerLatency()),
+        producerCall.merge(metric.getProducerCall()));
   }
 
   public Map<String, Number> toMap() {
diff --git a/metrics/metrics-common/src/main/java/io/servicecomb/metrics/common/RegistryMetric.java b/metrics/metrics-common/src/main/java/io/servicecomb/metrics/common/RegistryMetric.java
index 1dad927..4b08a7a 100644
--- a/metrics/metrics-common/src/main/java/io/servicecomb/metrics/common/RegistryMetric.java
+++ b/metrics/metrics-common/src/main/java/io/servicecomb/metrics/common/RegistryMetric.java
@@ -57,7 +57,7 @@ public class RegistryMetric {
 
     ConsumerInvocationMetric instanceConsumerInvocationMetric = new ConsumerInvocationMetric("instance",
         MetricsConst.INSTANCE_CONSUMER_PREFIX,
-        new TimerMetric(MetricsConst.INSTANCE_PRODUCER_PREFIX + ".producerLatency"),
+        new TimerMetric(MetricsConst.INSTANCE_CONSUMER_PREFIX + ".producerLatency"),
         new CallMetric(MetricsConst.INSTANCE_CONSUMER_PREFIX + ".consumerCall"));
     ProducerInvocationMetric instanceProducerInvocationMetric = new ProducerInvocationMetric("instance",
         MetricsConst.INSTANCE_PRODUCER_PREFIX, 0,
@@ -80,9 +80,7 @@ public class RegistryMetric {
 
   public Map<String, Number> toMap() {
     Map<String, Number> metrics = new HashMap<>();
-    metrics.putAll(instanceMetric.getSystemMetric().toMap());
-    metrics.putAll(instanceMetric.getConsumerMetric().toMap());
-    metrics.putAll(instanceMetric.getProducerMetric().toMap());
+    metrics.putAll(instanceMetric.toMap());
     for (ConsumerInvocationMetric metric : consumerMetrics.values()) {
       metrics.putAll(metric.toMap());
     }
diff --git a/metrics/pom.xml b/metrics/metrics-integration/metrics-prometheus/pom.xml
similarity index 70%
copy from metrics/pom.xml
copy to metrics/metrics-integration/metrics-prometheus/pom.xml
index 7331a3b..70a1ff2 100644
--- a/metrics/pom.xml
+++ b/metrics/metrics-integration/metrics-prometheus/pom.xml
@@ -19,20 +19,30 @@
 <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>
-  <packaging>pom</packaging>
   <parent>
+    <artifactId>metrics-integration</artifactId>
     <groupId>io.servicecomb</groupId>
-    <artifactId>java-chassis-parent</artifactId>
     <version>0.6.0-SNAPSHOT</version>
-    <relativePath>../parent</relativePath>
   </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>metrics-prometheus</artifactId>
+
+  <dependencies>
+    <dependency>
+      <groupId>io.prometheus</groupId>
+      <artifactId>simpleclient</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>io.prometheus</groupId>
+      <artifactId>simpleclient_httpserver</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>io.servicecomb</groupId>
+      <artifactId>metrics-core</artifactId>
+    </dependency>
 
-  <artifactId>metrics</artifactId>
+  </dependencies>
 
-  <modules>
-    <module>metrics-common</module>
-    <module>metrics-core</module>
-    <module>metrics-extension</module>
-  </modules>
 </project>
\ No newline at end of file
diff --git a/metrics/metrics-integration/metrics-prometheus/src/main/java/io/servicecomb/metrics/prometheus/MetricsCollector.java b/metrics/metrics-integration/metrics-prometheus/src/main/java/io/servicecomb/metrics/prometheus/MetricsCollector.java
new file mode 100644
index 0000000..863736b
--- /dev/null
+++ b/metrics/metrics-integration/metrics-prometheus/src/main/java/io/servicecomb/metrics/prometheus/MetricsCollector.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.metrics.prometheus;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.stream.Collectors;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import io.prometheus.client.Collector;
+import io.prometheus.client.Collector.MetricFamilySamples.Sample;
+import io.servicecomb.metrics.common.ConsumerInvocationMetric;
+import io.servicecomb.metrics.common.ProducerInvocationMetric;
+import io.servicecomb.metrics.common.RegistryMetric;
+import io.servicecomb.metrics.core.publish.DataSource;
+
+@Component
+public class MetricsCollector extends Collector implements Collector.Describable {
+
+  private final DataSource dataSource;
+
+  @Autowired
+  public MetricsCollector(DataSource dataSource) {
+    this.dataSource = dataSource;
+  }
+
+  @Override
+  public List<MetricFamilySamples> collect() {
+    return load();
+  }
+
+  @Override
+  public List<MetricFamilySamples> describe() {
+    return load();
+  }
+
+  private List<MetricFamilySamples> load() {
+    RegistryMetric registryMetric = dataSource.getRegistryMetric(0);
+    List<MetricFamilySamples> familySamples = new ArrayList<>();
+    familySamples.add(getFamilySamples("Instance Level", registryMetric.getInstanceMetric().toMap()));
+    for (Entry<String, ConsumerInvocationMetric> consumerMetric : registryMetric.getConsumerMetrics().entrySet()) {
+      familySamples
+          .add(getFamilySamples(consumerMetric.getKey() + " Consumer Side", consumerMetric.getValue().toMap()));
+    }
+    for (Entry<String, ProducerInvocationMetric> producerMetric : registryMetric.getProducerMetrics().entrySet()) {
+      familySamples
+          .add(getFamilySamples(producerMetric.getKey() + " Producer Side", producerMetric.getValue().toMap()));
+    }
+    return familySamples;
+  }
+
+  private MetricFamilySamples getFamilySamples(String name, Map<String, Number> metrics) {
+    List<Sample> samples = metrics.entrySet().stream().map((entry) ->
+        new Sample(entry.getKey().replace(".", "_"),
+            new ArrayList<>(), new ArrayList<>(), entry.getValue().doubleValue())).collect(Collectors.toList());
+    return new MetricFamilySamples(name, Type.UNTYPED, name + " Metrics", samples);
+  }
+}
diff --git a/metrics/metrics-integration/metrics-prometheus/src/main/java/io/servicecomb/metrics/prometheus/MetricsPublisher.java b/metrics/metrics-integration/metrics-prometheus/src/main/java/io/servicecomb/metrics/prometheus/MetricsPublisher.java
new file mode 100644
index 0000000..dc83a56
--- /dev/null
+++ b/metrics/metrics-integration/metrics-prometheus/src/main/java/io/servicecomb/metrics/prometheus/MetricsPublisher.java
@@ -0,0 +1,52 @@
+/*
+ * 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.prometheus;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import com.netflix.config.DynamicPropertyFactory;
+
+import io.prometheus.client.CollectorRegistry;
+import io.prometheus.client.exporter.HTTPServer;
+import io.servicecomb.foundation.common.exceptions.ServiceCombException;
+
+@Component
+public class MetricsPublisher {
+  private static final String METRICS_PROMETHEUS_PORT = "servicecomb.metrics.prometheus.port";
+
+  private final MetricsCollector metricsCollector;
+
+  private final HTTPServer httpServer;
+
+  @Autowired
+  public MetricsPublisher(MetricsCollector metricsCollector) {
+    //prometheus default port allocation is here : https://github.com/prometheus/prometheus/wiki/Default-port-allocations
+    int publishPort = DynamicPropertyFactory.getInstance().getIntProperty(METRICS_PROMETHEUS_PORT, 9696).get();
+    this.metricsCollector = metricsCollector;
+    this.metricsCollector.register();
+    try {
+      this.httpServer = new HTTPServer(new InetSocketAddress(publishPort), CollectorRegistry.defaultRegistry, true);
+    } catch (IOException e) {
+      throw new ServiceCombException("create http publish server failed", e);
+    }
+  }
+}
diff --git a/metrics/pom.xml b/metrics/metrics-integration/pom.xml
similarity index 83%
copy from metrics/pom.xml
copy to metrics/metrics-integration/pom.xml
index 7331a3b..c94879a 100644
--- a/metrics/pom.xml
+++ b/metrics/metrics-integration/pom.xml
@@ -19,20 +19,18 @@
 <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>
-  <packaging>pom</packaging>
   <parent>
+    <artifactId>metrics</artifactId>
     <groupId>io.servicecomb</groupId>
-    <artifactId>java-chassis-parent</artifactId>
     <version>0.6.0-SNAPSHOT</version>
-    <relativePath>../parent</relativePath>
   </parent>
+  <modelVersion>4.0.0</modelVersion>
 
-  <artifactId>metrics</artifactId>
-
+  <artifactId>metrics-integration</artifactId>
+  <packaging>pom</packaging>
   <modules>
-    <module>metrics-common</module>
-    <module>metrics-core</module>
-    <module>metrics-extension</module>
+    <module>metrics-prometheus</module>
   </modules>
+
+
 </project>
\ No newline at end of file
diff --git a/metrics/pom.xml b/metrics/pom.xml
index 7331a3b..cd5adcc 100644
--- a/metrics/pom.xml
+++ b/metrics/pom.xml
@@ -34,5 +34,6 @@
     <module>metrics-common</module>
     <module>metrics-core</module>
     <module>metrics-extension</module>
+    <module>metrics-integration</module>
   </modules>
 </project>
\ No newline at end of file

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