You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jl...@apache.org on 2018/12/26 14:03:58 UTC
[1/2] tomee git commit: Add files via upload
Repository: tomee
Updated Branches:
refs/heads/master 113644b66 -> b489fca7a
Add files via upload
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/197b44fa
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/197b44fa
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/197b44fa
Branch: refs/heads/master
Commit: 197b44fa88a6c207e9cba093d21c16b7a607665f
Parents: 16052e0
Author: puneethps <pu...@gmail.com>
Authored: Mon Dec 24 23:17:08 2018 +0530
Committer: GitHub <no...@github.com>
Committed: Mon Dec 24 23:17:08 2018 +0530
----------------------------------------------------------------------
examples/mp-metrics-metered/README.md | 130 +++++++++++++++++++++++++++++
1 file changed, 130 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/197b44fa/examples/mp-metrics-metered/README.md
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-metered/README.md b/examples/mp-metrics-metered/README.md
new file mode 100644
index 0000000..8008fbe
--- /dev/null
+++ b/examples/mp-metrics-metered/README.md
@@ -0,0 +1,130 @@
+index-group=Unrevised
+type=page
+status=published
+~~~~~~
+# 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 enpoint that will give you a weather weather status for the day and week.
+
+##### For the day status call:
+
+ GET http://localhost:8080/mp-metrics-metered/weather/day/status
+
+##### Response:
+
+ Hi, today is a sunny day!
+
+#### Metered Feature
+MicroProfile metrics has a feature that can be used to find the rate of requests to a service.
+
+To use this feature you need to annotate the JAX-RS resource method with @Metered.
+
+ @Path("/weather")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @ApplicationScoped
+ public class WeatherService {
+
+ @Path("/day/status")
+ @Metered(name = "dailyStatus", unit = MetricUnits.MINUTES, description = "Metrics to daily weather status method", absolute = true)
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String dayStatus() {
+ return "Hi, today is a sunny day!";
+ }
+ ...
+ }
+
+There are some configurations, as part of @Metered, 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.
+
+**boolean reusable**
+Denotes if a metric with a certain name can be registered in more than one place. Does not apply to gauges.
+
+**String unit**
+Unit of the metric. Default for @Metered is nanoseconds.
+
+#### Metric data
+
+Check the Metered metric doing a _GET_ request:
+
+##### Prometheus format:
+
+ GET http://localhost:8080/mp-metrics-metered/metrics/application/dailyStatus
+
+##### Response:
+
+ # TYPE application:daily_status_seconds_count meter
+ application:daily_status_seconds_count 1.2E-7
+ # TYPE application:daily_status_rate_per_second meter
+ application:daily_status_rate_per_second 0.0
+ # TYPE application:daily_status_one_min_rate_per_second meter
+ application:daily_status_one_min_rate_per_second 1.3376002644204984E-19
+ # TYPE application:daily_status_five_min_rate_per_second meter
+ application:daily_status_five_min_rate_per_second 3.5942838529305413E-20
+ # TYPE application:daily_status_fifteen_min_rate_per_second meter
+ application:daily_status_fifteen_min_rate_per_second 3.4665766454142955E-21
+
+
+##### JSON Format:
+
+For json format add the header _Accept=application/json_ to the request.
+
+ {
+ "dailyStatus": {
+ "count": 2,
+ "fifteenMinRate": 5.77762774235716e-14,
+ "fiveMinRate": 5.990473088217569e-13,
+ "meanRate": 0,
+ "oneMinRate": 2.229333774034164e-12,
+ "unit": "minutes"
+ }
+ }
+
+#### Metric metadata
+A metric will have a metadata so you can know more information about it, like displayName, description, tags etc.
+
+Check the metric metadata doing a _OPTIONS_ request:
+
+##### Request
+
+ OPTIONS http://localhost:8080/mp-metrics-metered/metrics/application/dailyStatus
+
+##### Response:
+
+ {
+ "dailyStatus": {
+ "description": "Metrics to daily weather status method",
+ "displayName": "",
+ "name": "dailyStatus",
+ "reusable": false,
+ "tags": "",
+ "type": "meter",
+ "typeRaw": "METERED",
+ "unit": "minutes"
+ }
+ }
+
+
+##### Test the application:
+
+ mvn test
[2/2] tomee git commit: This closes #308. Thanks puneethps.
Posted by jl...@apache.org.
This closes #308. Thanks puneethps.
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/b489fca7
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/b489fca7
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/b489fca7
Branch: refs/heads/master
Commit: b489fca7ac6ec08a3d9d14e882c32e18cb10162a
Parents: 113644b 197b44f
Author: Jean-Louis Monteiro <je...@gmail.com>
Authored: Wed Dec 26 15:03:50 2018 +0100
Committer: Jean-Louis Monteiro <je...@gmail.com>
Committed: Wed Dec 26 15:03:50 2018 +0100
----------------------------------------------------------------------
examples/mp-metrics-metered/README.md | 130 +++++++++++++++++++++++++++++
1 file changed, 130 insertions(+)
----------------------------------------------------------------------