You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by pa...@apache.org on 2017/02/26 22:47:29 UTC

[07/50] [abbrv] polygene-java git commit: Updates in Metrics documentation, and changed doc sample to use a closure instead of anonymous class.

Updates in Metrics documentation, and changed doc sample to use a closure instead of anonymous class.


Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/28f2e974
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/28f2e974
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/28f2e974

Branch: refs/heads/serialization-3.0
Commit: 28f2e9748a259539092256698babf93b82564c8a
Parents: c71f1b2
Author: niclas <ni...@spicter.com>
Authored: Sat Feb 25 12:45:08 2017 +0800
Committer: niclas <ni...@spicter.com>
Committed: Sat Feb 25 12:45:08 2017 +0800

----------------------------------------------------------------------
 core/api/src/docs/metrics.txt                   | 17 ++++++++++++-
 .../api/metrics/DocumentationSupport.java       | 26 +++++---------------
 2 files changed, 22 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/28f2e974/core/api/src/docs/metrics.txt
----------------------------------------------------------------------
diff --git a/core/api/src/docs/metrics.txt b/core/api/src/docs/metrics.txt
index af3529e..766ed3a 100644
--- a/core/api/src/docs/metrics.txt
+++ b/core/api/src/docs/metrics.txt
@@ -39,7 +39,7 @@ handling.
 
 A Gauge can represent anything, for instance, thread pool levels, queue sizes and other resource allocations. It is
 useful to have separate gauges for percentage (%) and absolute numbers of the same resource. Operations are mainly
-interested in being alerted when threshold are reach as a percentage, as it is otherwise too many numbers to keep
+interested in being alerted when threshold are reached as a percentage, as it is otherwise too many numbers to keep
 track of.
 
 To create a Gauge, you do something like;
@@ -51,6 +51,10 @@ tag=gauge
 --------------
 
 == Counter ==
+Often we want to track the many counters in a system. This might be "number of HTTP requests" or
+"filesystem access frequency". By creating a _Counter_ metrics, it is simply a matter of calling the _increment_
+or _decrement_ on that metric. This will track both number of counts/steps as well as the rate (per second), and
+many visualization platforms. such as Kibana, Graphite and Grafana, are made to handle this particular metric very well.
 
 [snippet,java]
 --------------
@@ -59,6 +63,9 @@ tag=counter
 --------------
 
 == Histogram ==
+Histograms is about computing the running standard deviations and variances. Please see
+http://www.johndcook.com/standard_deviation.html["Accurately computing running variance"] for more detailed information.
+
 [snippet,java]
 --------------
 source=core/api/src/test/java/org/apache/polygene/api/metrics/DocumentationSupport.java
@@ -66,6 +73,12 @@ tag=histogram
 --------------
 
 == Meter ==
+The _Meter_ is a more advanced _Counter_, which measures mean throughput and one-, five-, and fifteen-minute
+exponentially-weighted moving average throughputs.
+
+Wikipedia has a section
+http://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average["Exponential moving average"] in the
+"Moving Average" article.
 
 [snippet,java]
 --------------
@@ -84,6 +97,8 @@ tag=timer
 --------------
 
 == HealthCheck ==
+HealthCheck is a metric to report the health of a system or component. The HealthCheck metric will be called upon
+regularly to report its status, which is then forwarded to the monitoring system.
 
 [snippet,java]
 --------------

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/28f2e974/core/api/src/test/java/org/apache/polygene/api/metrics/DocumentationSupport.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/metrics/DocumentationSupport.java b/core/api/src/test/java/org/apache/polygene/api/metrics/DocumentationSupport.java
index 654bd5d..78f9b43 100644
--- a/core/api/src/test/java/org/apache/polygene/api/metrics/DocumentationSupport.java
+++ b/core/api/src/test/java/org/apache/polygene/api/metrics/DocumentationSupport.java
@@ -38,14 +38,7 @@ public class DocumentationSupport
         // END SNIPPET: gauge
         // START SNIPPET: gauge
         MetricsGaugeFactory gaugeFactory = provider.createFactory( MetricsGaugeFactory.class );
-        MetricsGauge<Integer> gauge = gaugeFactory.registerGauge( "Sample Gauge", new MetricsGauge<Integer>()
-        {
-            @Override
-            public Integer value()
-            {
-                return queue.size();
-            }
-        } );
+        MetricsGauge<Integer> gauge = gaugeFactory.registerGauge( "Sample Gauge", () -> queue.size() );
         // END SNIPPET: gauge
 
         // START SNIPPET: counter
@@ -70,18 +63,11 @@ public class DocumentationSupport
 
         // START SNIPPET: healthcheck
         MetricsHealthCheckFactory healthFactory = provider.createFactory( MetricsHealthCheckFactory.class );
-        MetricsHealthCheck healthCheck = healthFactory.registerHealthCheck(
-            "Sample Healthcheck",
-            new MetricsHealthCheck()
-            {
-                @Override
-                public Result check()
-                    throws Exception
-                {
-                    ServiceStatus status = pingMyService();
-                    return new Result( status.isOk(), status.getErrorMessage(), status.getException() );
-                }
-            } );
+        MetricsHealthCheck healthCheck = healthFactory.registerHealthCheck( "Sample Healthcheck", () ->
+        {
+            ServiceStatus status = pingMyService();
+            return new MetricsHealthCheck.Result( status.isOk(), status.getErrorMessage(), status.getException() );
+        } );
         // END SNIPPET: healthcheck
 
     }