You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jg...@apache.org on 2018/11/28 22:52:04 UTC

[07/14] tomee git commit: Adding README

Adding README


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/555ac00f
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/555ac00f
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/555ac00f

Branch: refs/heads/master
Commit: 555ac00fd543776f281594c64716e5eb4529ac40
Parents: da816c4
Author: ivanjunckes <ij...@tomitribe.com>
Authored: Mon Nov 26 11:25:33 2018 -0200
Committer: ivanjunckes <ij...@tomitribe.com>
Committed: Mon Nov 26 11:25:33 2018 -0200

----------------------------------------------------------------------
 examples/mp-metrics-timed/README.md | 151 +++++++++++++++++++++++++++++++
 1 file changed, 151 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/555ac00f/examples/mp-metrics-timed/README.md
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-timed/README.md b/examples/mp-metrics-timed/README.md
new file mode 100644
index 0000000..98ae694
--- /dev/null
+++ b/examples/mp-metrics-timed/README.md
@@ -0,0 +1,151 @@
+# Microprofile Metrics
+This is an example on how to use MicroProfile metrics in TomEE.
+
+##### Run the application:
+
+    mvn clean install tomee:run 
+
+Within the application there is an endpoint that will give you weather status for the day and week.
+
+##### For the day status call:
+
+    GET http://localhost:8080/mp-metrics-timed/weather/day/status
+    
+##### Response:
+
+    Hi, today is a sunny day!
+    
+
+#### Timed Feature
+MicroProfile metrics has a feature that tracks the time of an event.
+
+To use this feature you need to annotate the JAX-RS resource method with @Timed.
+
+    @Path("/weather")
+    @ApplicationScoped
+    public class WeatherService {
+
+        @Path("/day/status")
+        @Timed(name = "weather_day_status", absolute = true,
+                displayName = "Weather Day Status",
+                description = "This metric shows the weather status of the day.")
+        @GET
+        @Produces(MediaType.TEXT_PLAIN)
+        public String dayStatus() {
+            return "Hi, today is a sunny day!";
+        }
+    ...
+    }
+
+There are some configurations, as part of @Timed, that you need to know:
+
+**String name**
+Optional. Sets the name of the metric. If not explicitly given the name of the annotated object is used.
+
+**boolean absolute**
+If true, uses the given name as the absolute name of the metric. If false, prepends the package name and class name before the given name. Default value is false.
+
+**String displayName**
+Optional. A human readable display name for metadata.
+
+**String description**
+Optional. A description of the metric.
+
+**String[] tags**
+Optional. Array of Strings in the <key>=<value> format to supply special tags to a metric.
+
+**String unit**
+Unit of the metric. Default for @Timed is nanoseconds.
+
+#### Metric data
+
+Check the counter metric doing a _GET_ request:
+
+##### Prometheus format:
+
+    GET http://localhost:8080/mp-metrics-timed/metrics/application/weather_day_status
+    
+##### Response:
+     
+    # TYPE application:weather_day_status_seconds summary timer
+    # TYPE application:weather_day_status_seconds_count timer
+    application:weather_day_status_seconds_count 1.0
+    # TYPE application:weather_day_status_rate_per_second timer
+    application:weather_day_status_rate_per_second 0.0
+    # TYPE application:weather_day_status_one_min_rate_per_second timer
+    application:weather_day_status_one_min_rate_per_second 0.0
+    # TYPE application:weather_day_status_five_min_rate_per_second timer
+    application:weather_day_status_five_min_rate_per_second 0.0
+    # TYPE application:weather_day_status_fifteen_min_rate_per_second timer
+    application:weather_day_status_fifteen_min_rate_per_second 0.0
+    # TYPE application:weather_day_status_min_seconds timer
+    application:weather_day_status_min_seconds 48352.0
+    # TYPE application:weather_day_status_max_seconds timer
+    application:weather_day_status_max_seconds 48352.0
+    # TYPE application:weather_day_status_mean_seconds timer
+    application:weather_day_status_mean_seconds 48352.0
+    # TYPE application:weather_day_status_stddev_seconds timer
+    application:weather_day_status_stddev_seconds 0.0
+    # TYPE application:weather_day_status_seconds timer
+    application:weather_day_status_seconds{quantile="0.5"} 48352.0
+    # TYPE application:weather_day_status_seconds timer
+    application:weather_day_status_seconds{quantile="0.75"} 48352.0
+    # TYPE application:weather_day_status_seconds timer
+    application:weather_day_status_seconds{quantile="0.95"} 48352.0
+    # TYPE application:weather_day_status_seconds timer
+    application:weather_day_status_seconds{quantile="0.98"} 48352.0
+    # TYPE application:weather_day_status_seconds timer
+    application:weather_day_status_seconds{quantile="0.99"} 48352.0
+    # TYPE application:weather_day_status_seconds timer
+    application:weather_day_status_seconds{quantile="0.999"} 48352.0
+
+##### JSON Format:
+
+For json format add the header _Accept=application/json_ to the request. 
+  
+    {
+        "weather_day_status": {
+            "count": 1,
+            "fifteenMinRate": 0,
+            "fiveMinRate": 0,
+            "max": 48352,
+            "mean": 48352,
+            "meanRate": 0,
+            "min": 48352,
+            "oneMinRate": 0,
+            "p50": 48352,
+            "p75": 48352,
+            "p95": 48352,
+            "p98": 48352,
+            "p99": 48352,
+            "p999": 48352,
+            "stddev": 0
+        }
+    }
+   
+#### Metric metadata
+A metric will have a metadata so you can know more information about it, like displayName, description, tags e etc.
+
+Check the metric metadata doing a _OPTIONS_ request:
+
+##### Request
+
+    OPTIONS http://localhost:8080/mp-metrics-timed/metrics/application/weather_day_status
+
+##### Response:
+
+    {
+        "weather_day_status": {
+            "description": "This metric shows the weather status of the day.",
+            "displayName": "Weather Day Status",
+            "name": "weather_day_status",
+            "reusable": false,
+            "tags": "",
+            "type": "timer",
+            "typeRaw": "TIMER",
+            "unit": "nanoseconds"
+        }
+    }
+
+You can also try it out using the WeatherServiceTest.java available in the project.
+