WillemJiang closed pull request #580: [SCB-6] add metrics samples readme
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/580
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/samples/README.md b/samples/README.md
index 1656e85fd..dc2fa0562 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 000000000..7abd17311
--- /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 000000000..b6e041636
--- /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
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services