You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by ni...@apache.org on 2018/03/09 12:14:18 UTC
[incubator-servicecomb-java-chassis] branch master updated: SCB-6
add metrics samples readme
This is an automated email from the ASF dual-hosted git repository.
ningjiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git
The following commit(s) were added to refs/heads/master by this push:
new 68c4d0e SCB-6 add metrics samples readme
68c4d0e is described below
commit 68c4d0e3425537eb24ab18335f43b37ae9e01ee1
Author: zhengyangyong <ya...@huawei.com>
AuthorDate: Fri Mar 9 12:38:26 2018 +0800
SCB-6 add metrics samples readme
Signed-off-by: zhengyangyong <ya...@huawei.com>
---
samples/README.md | 2 ++
samples/metrics-extend-healthcheck/README.md | 47 ++++++++++++++++++++++++++++
samples/metrics-write-file-sample/README.md | 18 +++++++++++
3 files changed, 67 insertions(+)
diff --git a/samples/README.md b/samples/README.md
index 1656e85..dc2fa05 100644
--- a/samples/README.md
+++ b/samples/README.md
@@ -6,6 +6,8 @@ It's the samples of Java chassis
3. spring mvc sample
4. code first sample
5. customer handler sample
+6. extend metrics health checker sample
+7. write metrics data into separate text files sample
## 1. Start the ServiceComb/Service Center
diff --git a/samples/metrics-extend-healthcheck/README.md b/samples/metrics-extend-healthcheck/README.md
new file mode 100644
index 0000000..7abd173
--- /dev/null
+++ b/samples/metrics-extend-healthcheck/README.md
@@ -0,0 +1,47 @@
+# Extend Metrics Health Checker Sample
+## What is Health Checker
+Because micro-services is desgin by SRP(Single Responsibility Principle),one micro-service always depend on many components such as middle-ware like queue,database etc and other micro-services,so if one micro-service report failure,we want fast know what is the cause and more details to help us solve the problem.
+
+Health check mechanism can let user write some logic to check components of micro-service dependent and return check result.
+
+## How to use
+### Add your checker implementation
+Implement *org.apache.servicecomb.foundation.metrics.health.HealthChecker* interface:
+```java
+public interface HealthChecker {
+ String getName();
+
+ HealthCheckResult check();
+}
+```
+
+Then add the implementation class into **META-INF.service.org.apache.servicecomb.foundation.metrics.health.HealthChecker** by SPI(Service Provider Interface) way
+
+In this demo,we had make two checkers :
+1. CustomHealthChecker
+ always return true checker
+2. MySqlHealthChecker
+ sim check mysql can connect checker
+
+### Add Dependency in POM
+```xml
+<dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>metrics-core</artifactId>
+ <version>{version}</version>
+</dependency>
+```
+
+### Do check and get result
+If you had config rest transport address in microservice.yaml like:
+```yaml
+cse:
+ rest:
+ address: 0.0.0.0:7777
+```
+
+Then you can invoke http://{serverip}:7777/health get summary check result : true or false.
+
+**Only all registered health checker confirm isHealthy=true,the summary check result will be true,otherwise false**
+
+Also can invoke http://{serverip}:7777/health/details get details of each health checker reported.
\ No newline at end of file
diff --git a/samples/metrics-write-file-sample/README.md b/samples/metrics-write-file-sample/README.md
new file mode 100644
index 0000000..b6e04163
--- /dev/null
+++ b/samples/metrics-write-file-sample/README.md
@@ -0,0 +1,18 @@
+# Write Metrics Data into Separate Text Files Sample
+## Purpose
+This sample show how direct get metrics data and write them into separate text files,then other monitor system can load this file in order to get run state of micro-service.
+
+## What Contains
+### metrics-write-file Module
+This module contains the code how poll Monitors data from MonitorManager and convert data to a special format,then write into files.
+
+**We had designed that will use common Logging component for write file**,and there are many logging implements like log4j,log4j2,logback etc...,so we create *MetricsFileWriter* interface for later autowire.
+
+### metrics-write-file-log4j2-springboot Module
+This module contain log4j2 MetricsFileWriter implement if your project use it as Logging component.
+
+### metrics-write-file-log4j-springboot Module
+This module contain log4j MetricsFileWriter implement if your project use it as Logging component.
+
+## How to use
+Startup ServiceApplication in metrics-write-file-log4j2-springboot or metrics-write-file-log4j-springboot,you can see metric files had generated in **target/metric** folder,open your browser and make a request to http://localhost:8080/f ,wait a moment then you can see invocation metric files also be generated.
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
ningjiang@apache.org.