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:51:58 UTC
[01/14] tomee git commit: adding dependencies
Repository: tomee
Updated Branches:
refs/heads/master 354b14a3b -> 1d4f3a6fb
adding dependencies
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/db9022e9
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/db9022e9
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/db9022e9
Branch: refs/heads/master
Commit: db9022e95a0b0ea119146226de10c233f0ff679c
Parents: f032a7f
Author: ivanjunckes <ij...@tomitribe.com>
Authored: Fri Nov 23 11:57:51 2018 -0200
Committer: ivanjunckes <ij...@tomitribe.com>
Committed: Fri Nov 23 11:57:51 2018 -0200
----------------------------------------------------------------------
examples/mp-metrics-timed/pom.xml | 71 ++++++++++++++++++++++++++++++++++
1 file changed, 71 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/db9022e9/examples/mp-metrics-timed/pom.xml
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-timed/pom.xml b/examples/mp-metrics-timed/pom.xml
new file mode 100644
index 0000000..17e47a4
--- /dev/null
+++ b/examples/mp-metrics-timed/pom.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>examples</artifactId>
+ <groupId>org.apache.tomee</groupId>
+ <version>8.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>mp-metrics-timed</artifactId>
+
+ <packaging>war</packaging>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tomee</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>8.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.microprofile.metrics</groupId>
+ <artifactId>microprofile-metrics-api</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomee</groupId>
+ <artifactId>openejb-cxf-rs</artifactId>
+ <version>${tomee.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.junit</groupId>
+ <artifactId>arquillian-junit-container</artifactId>
+ <version>1.0.3.Final</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomee</groupId>
+ <artifactId>arquillian-tomee-remote</artifactId>
+ <version>${tomee.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomee</groupId>
+ <artifactId>apache-tomee</artifactId>
+ <version>${tomee.version}</version>
+ <type>zip</type>
+ <classifier>microprofile</classifier>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tomee.maven</groupId>
+ <artifactId>tomee-maven-plugin</artifactId>
+ <version>8.0.0-SNAPSHOT</version>
+ <configuration>
+ <tomeeClassifier>microprofile</tomeeClassifier>
+ <context>${artifactId}</context>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
[08/14] tomee git commit: fix typo
Posted by jg...@apache.org.
fix typo
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/e41a8622
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/e41a8622
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/e41a8622
Branch: refs/heads/master
Commit: e41a862225c4c1badf9125c8f52c7f5340bd8f21
Parents: 555ac00
Author: ivanjunckes <ij...@tomitribe.com>
Authored: Mon Nov 26 11:28:23 2018 -0200
Committer: ivanjunckes <ij...@tomitribe.com>
Committed: Mon Nov 26 11:28:23 2018 -0200
----------------------------------------------------------------------
examples/mp-metrics-timed/README.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/e41a8622/examples/mp-metrics-timed/README.md
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-timed/README.md b/examples/mp-metrics-timed/README.md
index 98ae694..6cad70e 100644
--- a/examples/mp-metrics-timed/README.md
+++ b/examples/mp-metrics-timed/README.md
@@ -5,7 +5,7 @@ This is an example on how to use MicroProfile metrics in TomEE.
mvn clean install tomee:run
-Within the application there is an endpoint that will give you weather status for the day and week.
+Within the application there is an endpoint that will give you weather status for the day.
##### For the day status call:
@@ -17,7 +17,7 @@ Within the application there is an endpoint that will give you weather status fo
#### Timed Feature
-MicroProfile metrics has a feature that tracks the time of an event.
+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.
@@ -59,7 +59,7 @@ Unit of the metric. Default for @Timed is nanoseconds.
#### Metric data
-Check the counter metric doing a _GET_ request:
+Check the timed metric doing a _GET_ request:
##### Prometheus format:
[14/14] tomee git commit: Merge branch 'metrics-timed-example' of
github.com:ivanjunckes/tomee
Posted by jg...@apache.org.
Merge branch 'metrics-timed-example' of github.com:ivanjunckes/tomee
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/1d4f3a6f
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/1d4f3a6f
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/1d4f3a6f
Branch: refs/heads/master
Commit: 1d4f3a6fb3be075a83ceca2c4003b217021d99ba
Parents: 354b14a 54d3a9b
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Wed Nov 28 22:51:32 2018 +0000
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Wed Nov 28 22:51:32 2018 +0000
----------------------------------------------------------------------
examples/mp-metrics-counted/pom.xml | 18 ++
examples/mp-metrics-timed/README.md | 151 +++++++++++++
examples/mp-metrics-timed/pom.xml | 88 ++++++++
.../src/main/java/WeatherService.java | 42 ++++
.../src/test/java/WeatherServiceTest.java | 215 +++++++++++++++++++
.../src/test/resources/arquillian.xml | 30 +++
examples/pom.xml | 1 +
7 files changed, 545 insertions(+)
----------------------------------------------------------------------
[02/14] tomee git commit: Adding jax-rs resource
Posted by jg...@apache.org.
Adding jax-rs resource
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/533afa8c
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/533afa8c
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/533afa8c
Branch: refs/heads/master
Commit: 533afa8cfa3f8c60d20683603be8b0033a5852e6
Parents: db9022e
Author: ivanjunckes <ij...@tomitribe.com>
Authored: Fri Nov 23 12:02:52 2018 -0200
Committer: ivanjunckes <ij...@tomitribe.com>
Committed: Fri Nov 23 12:02:52 2018 -0200
----------------------------------------------------------------------
.../src/main/java/WeatherService.java | 25 ++++++++++++++++++++
1 file changed, 25 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/533afa8c/examples/mp-metrics-timed/src/main/java/WeatherService.java
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-timed/src/main/java/WeatherService.java b/examples/mp-metrics-timed/src/main/java/WeatherService.java
new file mode 100644
index 0000000..a0f058e
--- /dev/null
+++ b/examples/mp-metrics-timed/src/main/java/WeatherService.java
@@ -0,0 +1,25 @@
+import org.eclipse.microprofile.metrics.annotation.Timed;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+@Path("/weather")
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+@ApplicationScoped
+public class WeatherService {
+
+ @Path("/day/status")
+ @Timed(name = "weather_day_timed", absolute = true,
+ displayName = "Weather Day Timed",
+ 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!";
+ }
+}
[06/14] tomee git commit: Fixing header
Posted by jg...@apache.org.
Fixing header
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/da816c4f
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/da816c4f
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/da816c4f
Branch: refs/heads/master
Commit: da816c4f953e157fe6f6231372f2ec9f821671ef
Parents: 0d5c911
Author: ivanjunckes <ij...@tomitribe.com>
Authored: Mon Nov 26 11:07:35 2018 -0200
Committer: ivanjunckes <ij...@tomitribe.com>
Committed: Mon Nov 26 11:07:35 2018 -0200
----------------------------------------------------------------------
examples/mp-metrics-counted/pom.xml | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/da816c4f/examples/mp-metrics-counted/pom.xml
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-counted/pom.xml b/examples/mp-metrics-counted/pom.xml
index c5d10e8..e480b88 100644
--- a/examples/mp-metrics-counted/pom.xml
+++ b/examples/mp-metrics-counted/pom.xml
@@ -1,4 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
[10/14] tomee git commit: Adjust to use json object
Posted by jg...@apache.org.
Adjust to use json object
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/bd401431
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/bd401431
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/bd401431
Branch: refs/heads/master
Commit: bd401431acf0d278458d5401de89d1c139e4213e
Parents: 30b75da
Author: ivanjunckes <ij...@tomitribe.com>
Authored: Mon Nov 26 15:00:38 2018 -0200
Committer: ivanjunckes <ij...@tomitribe.com>
Committed: Mon Nov 26 15:00:38 2018 -0200
----------------------------------------------------------------------
.../src/test/java/WeatherServiceTest.java | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/bd401431/examples/mp-metrics-timed/src/test/java/WeatherServiceTest.java
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-timed/src/test/java/WeatherServiceTest.java b/examples/mp-metrics-timed/src/test/java/WeatherServiceTest.java
index 074156c..f741a72 100644
--- a/examples/mp-metrics-timed/src/test/java/WeatherServiceTest.java
+++ b/examples/mp-metrics-timed/src/test/java/WeatherServiceTest.java
@@ -57,12 +57,12 @@ public class WeatherServiceTest {
private Client client;
@Before
- public void before(){
+ public void before() {
this.client = ClientBuilder.newClient();
}
@After
- public void after(){
+ public void after() {
this.client.close();
}
@@ -90,7 +90,7 @@ public class WeatherServiceTest {
.invoke()
.readEntity(String.class);
- String [] expected = {
+ String[] expected = {
"# TYPE application:weather_day_status_seconds summary timer",
"# TYPE application:weather_day_status_seconds_count timer",
"application:weather_day_status_seconds_count 1.0",
@@ -138,7 +138,9 @@ public class WeatherServiceTest {
.invoke()
.readEntity(String.class);
- String [] expected = {
+ JsonObject expectedJson = Json.createReader(new StringReader(metric)).readObject();
+
+ String[] expected = {
"count",
"meanRate",
"fifteenMinRate",
@@ -157,7 +159,10 @@ public class WeatherServiceTest {
};
Stream.of(expected)
- .forEach(text -> assertTrue("Expected: " + text + " to be present in " + metric, metric.contains(text)));
+ .forEach(text ->
+ assertTrue(
+ "Expected: " + text + " to be present in " + metric,
+ expectedJson.getJsonObject("weather_day_status").get("count") != null));
}
@Test
[09/14] tomee git commit: fixing based on romain's feedback
Posted by jg...@apache.org.
fixing based on romain's feedback
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/30b75da9
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/30b75da9
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/30b75da9
Branch: refs/heads/master
Commit: 30b75da997ad92822dd08d46830555ca0084787a
Parents: e41a862
Author: ivanjunckes <ij...@tomitribe.com>
Authored: Mon Nov 26 14:52:43 2018 -0200
Committer: ivanjunckes <ij...@tomitribe.com>
Committed: Mon Nov 26 14:52:43 2018 -0200
----------------------------------------------------------------------
.../src/test/java/WeatherServiceTest.java | 160 ++++++++++++-------
1 file changed, 101 insertions(+), 59 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/30b75da9/examples/mp-metrics-timed/src/test/java/WeatherServiceTest.java
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-timed/src/test/java/WeatherServiceTest.java b/examples/mp-metrics-timed/src/test/java/WeatherServiceTest.java
index b119ede..074156c 100644
--- a/examples/mp-metrics-timed/src/test/java/WeatherServiceTest.java
+++ b/examples/mp-metrics-timed/src/test/java/WeatherServiceTest.java
@@ -15,22 +15,27 @@
* limitations under the License.
*/
-import org.apache.cxf.jaxrs.client.WebClient;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.json.Json;
import javax.json.JsonObject;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.StringReader;
import java.net.URL;
+import java.util.stream.Stream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -49,11 +54,25 @@ public class WeatherServiceTest {
@ArquillianResource
private URL base;
+ private Client client;
+
+ @Before
+ public void before(){
+ this.client = ClientBuilder.newClient();
+ }
+
+ @After
+ public void after(){
+ this.client.close();
+ }
+
@Test
public void testTimedMetric() {
- WebClient.create(base.toExternalForm())
+ WebTarget webTarget = client.target(base.toExternalForm());
+
+ webTarget
.path("/weather/day/status")
- .get(String.class);
+ .request().buildGet().invoke();
final String metricPath = "/metrics/application/weather_day_status";
assertPrometheusFormat(metricPath);
@@ -61,74 +80,97 @@ public class WeatherServiceTest {
}
private void assertPrometheusFormat(final String metricPath) {
- final String metric = WebClient.create(base.toExternalForm())
+ WebTarget webTarget = client.target(base.toExternalForm());
+
+ String metric = webTarget
.path(metricPath)
+ .request()
.accept(MediaType.TEXT_PLAIN)
- .get(String.class);
-
- assertTrue(metric.contains("# TYPE application:weather_day_status_seconds summary timer"));
- assertTrue(metric.contains("# TYPE application:weather_day_status_seconds_count timer"));
- assertTrue(metric.contains("application:weather_day_status_seconds_count 1.0"));
- assertTrue(metric.contains("# TYPE application:weather_day_status_rate_per_second timer"));
- assertTrue(metric.contains("application:weather_day_status_rate_per_second"));
- assertTrue(metric.contains("# TYPE application:weather_day_status_one_min_rate_per_second timer"));
- assertTrue(metric.contains("application:weather_day_status_one_min_rate_per_second"));
- assertTrue(metric.contains("# TYPE application:weather_day_status_five_min_rate_per_second timer"));
- assertTrue(metric.contains("application:weather_day_status_five_min_rate_per_second"));
- assertTrue(metric.contains("# TYPE application:weather_day_status_fifteen_min_rate_per_second time"));
- assertTrue(metric.contains("application:weather_day_status_fifteen_min_rate_per_second"));
- assertTrue(metric.contains("# TYPE application:weather_day_status_min_seconds timer"));
- assertTrue(metric.contains("application:weather_day_status_min_seconds"));
- assertTrue(metric.contains("# TYPE application:weather_day_status_max_seconds timer"));
- assertTrue(metric.contains("application:weather_day_status_max_seconds"));
- assertTrue(metric.contains("# TYPE application:weather_day_status_mean_seconds timer"));
- assertTrue(metric.contains("application:weather_day_status_mean_seconds"));
- assertTrue(metric.contains("# TYPE application:weather_day_status_stddev_seconds timer"));
- assertTrue(metric.contains("application:weather_day_status_stddev_seconds"));
- assertTrue(metric.contains("# TYPE application:weather_day_status_seconds timer"));
- assertTrue(metric.contains("application:weather_day_status_seconds{quantile=\"0.5\"}"));
- assertTrue(metric.contains("# TYPE application:weather_day_status_seconds timer"));
- assertTrue(metric.contains("application:weather_day_status_seconds{quantile=\"0.75\"}"));
- assertTrue(metric.contains("# TYPE application:weather_day_status_seconds timer"));
- assertTrue(metric.contains("application:weather_day_status_seconds{quantile=\"0.95\"}"));
- assertTrue(metric.contains("# TYPE application:weather_day_status_seconds timer"));
- assertTrue(metric.contains("application:weather_day_status_seconds{quantile=\"0.98\"}"));
- assertTrue(metric.contains("# TYPE application:weather_day_status_seconds timer"));
- assertTrue(metric.contains("application:weather_day_status_seconds{quantile=\"0.99\"}"));
- assertTrue(metric.contains("# TYPE application:weather_day_status_seconds timer"));
- assertTrue(metric.contains("application:weather_day_status_seconds{quantile=\"0.999\"}"));
+ .buildGet()
+ .invoke()
+ .readEntity(String.class);
+
+ String [] expected = {
+ "# 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",
+ "# TYPE application:weather_day_status_one_min_rate_per_second timer",
+ "# TYPE application:weather_day_status_five_min_rate_per_second timer",
+ "application:weather_day_status_five_min_rate_per_second",
+ "# TYPE application:weather_day_status_fifteen_min_rate_per_second time",
+ "application:weather_day_status_fifteen_min_rate_per_second",
+ "# TYPE application:weather_day_status_min_seconds timer",
+ "application:weather_day_status_min_seconds",
+ "# TYPE application:weather_day_status_max_seconds timer",
+ "application:weather_day_status_max_seconds",
+ "# TYPE application:weather_day_status_mean_seconds timer",
+ "application:weather_day_status_mean_seconds",
+ "# TYPE application:weather_day_status_stddev_seconds timer",
+ "application:weather_day_status_stddev_seconds",
+ "# TYPE application:weather_day_status_seconds timer",
+ "application:weather_day_status_seconds{quantile=\"0.5\"}",
+ "# TYPE application:weather_day_status_seconds timer",
+ "application:weather_day_status_seconds{quantile=\"0.75\"}",
+ "# TYPE application:weather_day_status_seconds timer",
+ "application:weather_day_status_seconds{quantile=\"0.95\"}",
+ "# TYPE application:weather_day_status_seconds timer",
+ "application:weather_day_status_seconds{quantile=\"0.98\"}",
+ "# TYPE application:weather_day_status_seconds timer",
+ "application:weather_day_status_seconds{quantile=\"0.99\"}",
+ "# TYPE application:weather_day_status_seconds timer",
+ "application:weather_day_status_seconds{quantile=\"0.999\"}"
+ };
+
+ Stream.of(expected)
+ .forEach(text -> assertTrue("Expected: " + text + " to be present in " + metric, metric.contains(text)));
}
private void assertJsonFormat(final String metricPath) {
- final String metric = WebClient.create(base.toExternalForm())
+ WebTarget webTarget = client.target(base.toExternalForm());
+
+ String metric = webTarget
.path(metricPath)
+ .request()
.accept(MediaType.APPLICATION_JSON)
- .get(String.class);
-
- assertTrue(metric.contains("count"));
- assertTrue(metric.contains("meanRate"));
- assertTrue(metric.contains("fifteenMinRate"));
- assertTrue(metric.contains("fiveMinRate"));
- assertTrue(metric.contains("oneMinRate"));
- assertTrue(metric.contains("min"));
- assertTrue(metric.contains("max"));
- assertTrue(metric.contains("mean"));
- assertTrue(metric.contains("stddev"));
- assertTrue(metric.contains("p50"));
- assertTrue(metric.contains("p75"));
- assertTrue(metric.contains("p95"));
- assertTrue(metric.contains("p98"));
- assertTrue(metric.contains("p99"));
- assertTrue(metric.contains("p999"));
-
+ .buildGet()
+ .invoke()
+ .readEntity(String.class);
+
+ String [] expected = {
+ "count",
+ "meanRate",
+ "fifteenMinRate",
+ "fiveMinRate",
+ "oneMinRate",
+ "min",
+ "max",
+ "mean",
+ "stddev",
+ "p50",
+ "p75",
+ "p95",
+ "p98",
+ "p99",
+ "p999"
+ };
+
+ Stream.of(expected)
+ .forEach(text -> assertTrue("Expected: " + text + " to be present in " + metric, metric.contains(text)));
}
@Test
public void testTimedMetricMetadata() {
- final Response response = WebClient.create(base.toExternalForm())
- .path("/metrics/application/weather_day_status")
+
+ WebTarget webTarget = client.target(base.toExternalForm());
+
+ Response response = webTarget.path("/metrics/application/weather_day_status")
+ .request()
.accept(MediaType.APPLICATION_JSON)
- .options();
+ .build("OPTIONS")
+ .invoke();
+
final String metaData = response.readEntity(String.class);
JsonObject metadataJson = Json.createReader(new StringReader(metaData)).readObject();
[04/14] tomee git commit: Adding test and a few changes
Posted by jg...@apache.org.
Adding test and a few changes
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/a87cf682
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/a87cf682
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/a87cf682
Branch: refs/heads/master
Commit: a87cf682cef5e6ae4c0f46409a9df5f8f4453bef
Parents: 1b7bacc
Author: ivanjunckes <ij...@tomitribe.com>
Authored: Fri Nov 23 16:08:47 2018 -0200
Committer: ivanjunckes <ij...@tomitribe.com>
Committed: Fri Nov 23 16:08:47 2018 -0200
----------------------------------------------------------------------
.../src/main/java/WeatherService.java | 4 +-
.../src/test/java/WeatherServiceTest.java | 151 +++++++++++++++++++
.../src/test/resources/arquillian.xml | 30 ++++
examples/pom.xml | 1 +
pom.xml | 2 +-
5 files changed, 185 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/a87cf682/examples/mp-metrics-timed/src/main/java/WeatherService.java
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-timed/src/main/java/WeatherService.java b/examples/mp-metrics-timed/src/main/java/WeatherService.java
index a0f058e..e117800 100644
--- a/examples/mp-metrics-timed/src/main/java/WeatherService.java
+++ b/examples/mp-metrics-timed/src/main/java/WeatherService.java
@@ -14,8 +14,8 @@ import javax.ws.rs.core.MediaType;
public class WeatherService {
@Path("/day/status")
- @Timed(name = "weather_day_timed", absolute = true,
- displayName = "Weather Day Timed",
+ @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)
http://git-wip-us.apache.org/repos/asf/tomee/blob/a87cf682/examples/mp-metrics-timed/src/test/java/WeatherServiceTest.java
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-timed/src/test/java/WeatherServiceTest.java b/examples/mp-metrics-timed/src/test/java/WeatherServiceTest.java
new file mode 100644
index 0000000..b119ede
--- /dev/null
+++ b/examples/mp-metrics-timed/src/test/java/WeatherServiceTest.java
@@ -0,0 +1,151 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.json.Json;
+import javax.json.JsonObject;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.StringReader;
+import java.net.URL;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+@RunWith(Arquillian.class)
+public class WeatherServiceTest {
+
+ @Deployment(testable = false)
+ public static WebArchive createDeployment() {
+ final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "test.war")
+ .addClass(WeatherService.class)
+ .addAsWebInfResource(new StringAsset("<beans/>"), "beans.xml");
+ return webArchive;
+ }
+
+ @ArquillianResource
+ private URL base;
+
+ @Test
+ public void testTimedMetric() {
+ WebClient.create(base.toExternalForm())
+ .path("/weather/day/status")
+ .get(String.class);
+
+ final String metricPath = "/metrics/application/weather_day_status";
+ assertPrometheusFormat(metricPath);
+ assertJsonFormat(metricPath);
+ }
+
+ private void assertPrometheusFormat(final String metricPath) {
+ final String metric = WebClient.create(base.toExternalForm())
+ .path(metricPath)
+ .accept(MediaType.TEXT_PLAIN)
+ .get(String.class);
+
+ assertTrue(metric.contains("# TYPE application:weather_day_status_seconds summary timer"));
+ assertTrue(metric.contains("# TYPE application:weather_day_status_seconds_count timer"));
+ assertTrue(metric.contains("application:weather_day_status_seconds_count 1.0"));
+ assertTrue(metric.contains("# TYPE application:weather_day_status_rate_per_second timer"));
+ assertTrue(metric.contains("application:weather_day_status_rate_per_second"));
+ assertTrue(metric.contains("# TYPE application:weather_day_status_one_min_rate_per_second timer"));
+ assertTrue(metric.contains("application:weather_day_status_one_min_rate_per_second"));
+ assertTrue(metric.contains("# TYPE application:weather_day_status_five_min_rate_per_second timer"));
+ assertTrue(metric.contains("application:weather_day_status_five_min_rate_per_second"));
+ assertTrue(metric.contains("# TYPE application:weather_day_status_fifteen_min_rate_per_second time"));
+ assertTrue(metric.contains("application:weather_day_status_fifteen_min_rate_per_second"));
+ assertTrue(metric.contains("# TYPE application:weather_day_status_min_seconds timer"));
+ assertTrue(metric.contains("application:weather_day_status_min_seconds"));
+ assertTrue(metric.contains("# TYPE application:weather_day_status_max_seconds timer"));
+ assertTrue(metric.contains("application:weather_day_status_max_seconds"));
+ assertTrue(metric.contains("# TYPE application:weather_day_status_mean_seconds timer"));
+ assertTrue(metric.contains("application:weather_day_status_mean_seconds"));
+ assertTrue(metric.contains("# TYPE application:weather_day_status_stddev_seconds timer"));
+ assertTrue(metric.contains("application:weather_day_status_stddev_seconds"));
+ assertTrue(metric.contains("# TYPE application:weather_day_status_seconds timer"));
+ assertTrue(metric.contains("application:weather_day_status_seconds{quantile=\"0.5\"}"));
+ assertTrue(metric.contains("# TYPE application:weather_day_status_seconds timer"));
+ assertTrue(metric.contains("application:weather_day_status_seconds{quantile=\"0.75\"}"));
+ assertTrue(metric.contains("# TYPE application:weather_day_status_seconds timer"));
+ assertTrue(metric.contains("application:weather_day_status_seconds{quantile=\"0.95\"}"));
+ assertTrue(metric.contains("# TYPE application:weather_day_status_seconds timer"));
+ assertTrue(metric.contains("application:weather_day_status_seconds{quantile=\"0.98\"}"));
+ assertTrue(metric.contains("# TYPE application:weather_day_status_seconds timer"));
+ assertTrue(metric.contains("application:weather_day_status_seconds{quantile=\"0.99\"}"));
+ assertTrue(metric.contains("# TYPE application:weather_day_status_seconds timer"));
+ assertTrue(metric.contains("application:weather_day_status_seconds{quantile=\"0.999\"}"));
+ }
+
+ private void assertJsonFormat(final String metricPath) {
+ final String metric = WebClient.create(base.toExternalForm())
+ .path(metricPath)
+ .accept(MediaType.APPLICATION_JSON)
+ .get(String.class);
+
+ assertTrue(metric.contains("count"));
+ assertTrue(metric.contains("meanRate"));
+ assertTrue(metric.contains("fifteenMinRate"));
+ assertTrue(metric.contains("fiveMinRate"));
+ assertTrue(metric.contains("oneMinRate"));
+ assertTrue(metric.contains("min"));
+ assertTrue(metric.contains("max"));
+ assertTrue(metric.contains("mean"));
+ assertTrue(metric.contains("stddev"));
+ assertTrue(metric.contains("p50"));
+ assertTrue(metric.contains("p75"));
+ assertTrue(metric.contains("p95"));
+ assertTrue(metric.contains("p98"));
+ assertTrue(metric.contains("p99"));
+ assertTrue(metric.contains("p999"));
+
+ }
+
+ @Test
+ public void testTimedMetricMetadata() {
+ final Response response = WebClient.create(base.toExternalForm())
+ .path("/metrics/application/weather_day_status")
+ .accept(MediaType.APPLICATION_JSON)
+ .options();
+ final String metaData = response.readEntity(String.class);
+ JsonObject metadataJson = Json.createReader(new StringReader(metaData)).readObject();
+
+ final String expected = "{\n" +
+ " \"weather_day_status\": {\n" +
+ " \"description\": \"This metric shows the weather status of the day.\",\n" +
+ " \"displayName\": \"Weather Day Status\",\n" +
+ " \"name\": \"weather_day_status\",\n" +
+ " \"reusable\": false,\n" +
+ " \"tags\": \"\",\n" +
+ " \"type\": \"timer\",\n" +
+ " \"typeRaw\": \"TIMER\",\n" +
+ " \"unit\": \"nanoseconds\"\n" +
+ " }\n" +
+ "}";
+
+ JsonObject expectedJson = Json.createReader(new StringReader(expected)).readObject();
+ assertEquals(expectedJson, metadataJson);
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/a87cf682/examples/mp-metrics-timed/src/test/resources/arquillian.xml
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-timed/src/test/resources/arquillian.xml b/examples/mp-metrics-timed/src/test/resources/arquillian.xml
new file mode 100644
index 0000000..3029d48
--- /dev/null
+++ b/examples/mp-metrics-timed/src/test/resources/arquillian.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+ <container qualifier="tomee" default="true">
+ <configuration>
+ <property name="httpPort">-1</property>
+ <property name="stopPort">-1</property>
+ <property name="classifier">microprofile</property>
+ <property name="dir">target/apache-tomee-remote</property>
+ <property name="appWorkingDir">target/arquillian-test-working-dir</property>
+ </configuration>
+ </container>
+</arquillian>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/a87cf682/examples/pom.xml
----------------------------------------------------------------------
diff --git a/examples/pom.xml b/examples/pom.xml
index 92518e3..2e670a9 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -172,6 +172,7 @@ BROKEN, see TOMEE-2140
<module>moviefun-rest</module>
<module>resources-jmx-example</module>
<module>mp-metrics-counted</module>
+ <module>mp-metrics-timed</module>
</modules>
<dependencies>
http://git-wip-us.apache.org/repos/asf/tomee/blob/a87cf682/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index c446d34..778b110 100644
--- a/pom.xml
+++ b/pom.xml
@@ -208,7 +208,7 @@
<microprofile.health.version>1.0</microprofile.health.version>
<microprofile.health.impl.version>1.0.0</microprofile.health.impl.version>
<microprofile.metrics.version>1.1</microprofile.metrics.version>
- <microprofile.metrics.impl.version>1.0.0</microprofile.metrics.impl.version>
+ <microprofile.metrics.impl.version>1.0.1-SNAPSHOT</microprofile.metrics.impl.version>
<microprofile.rest-client.version>1.0</microprofile.rest-client.version>
<microprofile.rest-client.impl.version>${cxf.version}</microprofile.rest-client.impl.version>
<microprofile.openapi.version>1.0.1</microprofile.openapi.version>
[12/14] tomee git commit: Adding header
Posted by jg...@apache.org.
Adding header
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/54757833
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/54757833
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/54757833
Branch: refs/heads/master
Commit: 54757833329edf2de2474acfcd2a94aecc77fb57
Parents: e465b64
Author: ivanjunckes <ij...@tomitribe.com>
Authored: Mon Nov 26 15:07:19 2018 -0200
Committer: ivanjunckes <ij...@tomitribe.com>
Committed: Mon Nov 26 15:07:19 2018 -0200
----------------------------------------------------------------------
examples/mp-metrics-timed/pom.xml | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/54757833/examples/mp-metrics-timed/pom.xml
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-timed/pom.xml b/examples/mp-metrics-timed/pom.xml
index 17e47a4..01c7186 100644
--- a/examples/mp-metrics-timed/pom.xml
+++ b/examples/mp-metrics-timed/pom.xml
@@ -1,4 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
[13/14] tomee git commit: fixing assert keys based on Romain's
feedback
Posted by jg...@apache.org.
fixing assert keys based on Romain's feedback
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/54d3a9bf
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/54d3a9bf
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/54d3a9bf
Branch: refs/heads/master
Commit: 54d3a9bf3d6165de9e08cbcf6036d2c42ec3ec4b
Parents: 5475783
Author: ivanjunckes <ij...@tomitribe.com>
Authored: Tue Nov 27 14:02:13 2018 -0200
Committer: ivanjunckes <ij...@tomitribe.com>
Committed: Tue Nov 27 14:02:13 2018 -0200
----------------------------------------------------------------------
.../src/test/java/WeatherServiceTest.java | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/54d3a9bf/examples/mp-metrics-timed/src/test/java/WeatherServiceTest.java
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-timed/src/test/java/WeatherServiceTest.java b/examples/mp-metrics-timed/src/test/java/WeatherServiceTest.java
index 077338a..4938109 100644
--- a/examples/mp-metrics-timed/src/test/java/WeatherServiceTest.java
+++ b/examples/mp-metrics-timed/src/test/java/WeatherServiceTest.java
@@ -193,6 +193,23 @@ public class WeatherServiceTest {
"}";
JsonObject expectedJson = Json.createReader(new StringReader(expected)).readObject();
- assertEquals(expectedJson, metadataJson);
+ assertEquals(expectedJson.keySet().size(), metadataJson.keySet().size());
+
+ String[] expectedKeys = {
+ "description",
+ "displayName",
+ "name",
+ "reusable",
+ "tags",
+ "type",
+ "typeRaw",
+ "unit",
+ };
+
+ Stream.of(expectedKeys)
+ .forEach(text ->
+ assertTrue(
+ "Expected: " + text + " to be present in " + expected,
+ expectedJson.getJsonObject("weather_day_status").get(text) != null));
}
}
[11/14] tomee git commit: fix text
Posted by jg...@apache.org.
fix text
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/e465b64d
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/e465b64d
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/e465b64d
Branch: refs/heads/master
Commit: e465b64db3ab031043e94047ce614e74eb08bafe
Parents: bd40143
Author: ivanjunckes <ij...@tomitribe.com>
Authored: Mon Nov 26 15:06:13 2018 -0200
Committer: ivanjunckes <ij...@tomitribe.com>
Committed: Mon Nov 26 15:06:13 2018 -0200
----------------------------------------------------------------------
examples/mp-metrics-timed/src/test/java/WeatherServiceTest.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/e465b64d/examples/mp-metrics-timed/src/test/java/WeatherServiceTest.java
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-timed/src/test/java/WeatherServiceTest.java b/examples/mp-metrics-timed/src/test/java/WeatherServiceTest.java
index f741a72..077338a 100644
--- a/examples/mp-metrics-timed/src/test/java/WeatherServiceTest.java
+++ b/examples/mp-metrics-timed/src/test/java/WeatherServiceTest.java
@@ -162,7 +162,7 @@ public class WeatherServiceTest {
.forEach(text ->
assertTrue(
"Expected: " + text + " to be present in " + metric,
- expectedJson.getJsonObject("weather_day_status").get("count") != null));
+ expectedJson.getJsonObject("weather_day_status").get(text) != null));
}
@Test
[03/14] tomee git commit: Merge branch 'master' of
github.com:apache/tomee into metrics-timed-example
Posted by jg...@apache.org.
Merge branch 'master' of github.com:apache/tomee into metrics-timed-example
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/1b7baccd
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/1b7baccd
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/1b7baccd
Branch: refs/heads/master
Commit: 1b7baccd47ea7816bf7c03fb2946f25a4cb63e12
Parents: 533afa8 1bfb65a
Author: ivanjunckes <ij...@tomitribe.com>
Authored: Fri Nov 23 13:32:27 2018 -0200
Committer: ivanjunckes <ij...@tomitribe.com>
Committed: Fri Nov 23 13:32:27 2018 -0200
----------------------------------------------------------------------
.../main/java/org/apache/openejb/server/cxf/rs/CxfRSService.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
[07/14] tomee git commit: Adding README
Posted by jg...@apache.org.
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.
+
[05/14] tomee git commit: Fixinig license headers
Posted by jg...@apache.org.
Fixinig license headers
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/0d5c911f
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/0d5c911f
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/0d5c911f
Branch: refs/heads/master
Commit: 0d5c911f864b14d024836d2075f4cb1021c95863
Parents: a87cf68
Author: ivanjunckes <ij...@tomitribe.com>
Authored: Mon Nov 26 11:05:30 2018 -0200
Committer: ivanjunckes <ij...@tomitribe.com>
Committed: Mon Nov 26 11:05:30 2018 -0200
----------------------------------------------------------------------
.../src/main/java/WeatherService.java | 17 +++++++++++++++++
pom.xml | 2 +-
2 files changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/0d5c911f/examples/mp-metrics-timed/src/main/java/WeatherService.java
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-timed/src/main/java/WeatherService.java b/examples/mp-metrics-timed/src/main/java/WeatherService.java
index e117800..a19279d 100644
--- a/examples/mp-metrics-timed/src/main/java/WeatherService.java
+++ b/examples/mp-metrics-timed/src/main/java/WeatherService.java
@@ -1,3 +1,20 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
import org.eclipse.microprofile.metrics.annotation.Timed;
import javax.enterprise.context.ApplicationScoped;
http://git-wip-us.apache.org/repos/asf/tomee/blob/0d5c911f/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 778b110..c446d34 100644
--- a/pom.xml
+++ b/pom.xml
@@ -208,7 +208,7 @@
<microprofile.health.version>1.0</microprofile.health.version>
<microprofile.health.impl.version>1.0.0</microprofile.health.impl.version>
<microprofile.metrics.version>1.1</microprofile.metrics.version>
- <microprofile.metrics.impl.version>1.0.1-SNAPSHOT</microprofile.metrics.impl.version>
+ <microprofile.metrics.impl.version>1.0.0</microprofile.metrics.impl.version>
<microprofile.rest-client.version>1.0</microprofile.rest-client.version>
<microprofile.rest-client.impl.version>${cxf.version}</microprofile.rest-client.impl.version>
<microprofile.openapi.version>1.0.1</microprofile.openapi.version>