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/19 20:24:31 UTC

[1/6] tomee git commit: metrics example creation

Repository: tomee
Updated Branches:
  refs/heads/master 9a0beb701 -> 51a07decf


metrics example creation


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

Branch: refs/heads/master
Commit: fffa371ffd0ac8c18163ab858ad604161273a250
Parents: 60ef186
Author: ivanjunckes <ij...@tomitribe.com>
Authored: Mon Nov 19 10:00:29 2018 -0200
Committer: ivanjunckes <ij...@tomitribe.com>
Committed: Mon Nov 19 10:00:29 2018 -0200

----------------------------------------------------------------------
 examples/pom.xml                 |  1 +
 examples/rest-mp-metrics/pom.xml | 15 +++++++++++++++
 2 files changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/fffa371f/examples/pom.xml
----------------------------------------------------------------------
diff --git a/examples/pom.xml b/examples/pom.xml
index 18d4971..4cab9e2 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -171,6 +171,7 @@ BROKEN, see TOMEE-2140
     <module>moviefun</module>
     <module>moviefun-rest</module>
     <module>resources-jmx-example</module>
+      <module>rest-mp-metrics</module>
   </modules>
 
   <dependencies>

http://git-wip-us.apache.org/repos/asf/tomee/blob/fffa371f/examples/rest-mp-metrics/pom.xml
----------------------------------------------------------------------
diff --git a/examples/rest-mp-metrics/pom.xml b/examples/rest-mp-metrics/pom.xml
new file mode 100644
index 0000000..6a31d77
--- /dev/null
+++ b/examples/rest-mp-metrics/pom.xml
@@ -0,0 +1,15 @@
+<?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>rest-mp-metrics</artifactId>
+
+
+</project>
\ No newline at end of file


[5/6] 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/be6bf8f1
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/be6bf8f1
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/be6bf8f1

Branch: refs/heads/master
Commit: be6bf8f170361dc8d296ff0a64739341de09a8d2
Parents: 017b98e
Author: ivanjunckes <ij...@tomitribe.com>
Authored: Mon Nov 19 18:11:06 2018 -0200
Committer: ivanjunckes <ij...@tomitribe.com>
Committed: Mon Nov 19 18:11:06 2018 -0200

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


http://git-wip-us.apache.org/repos/asf/tomee/blob/be6bf8f1/examples/rest-mp-metrics/README.md
----------------------------------------------------------------------
diff --git a/examples/rest-mp-metrics/README.md b/examples/rest-mp-metrics/README.md
new file mode 100644
index 0000000..9dafe75
--- /dev/null
+++ b/examples/rest-mp-metrics/README.md
@@ -0,0 +1,19 @@
+# Microprofile Metrics
+This is an example on how to use microprofile metrics in TomEE.
+
+The command to run the application the application is:
+
+    mvn clean install tomee:run 
+
+Make a call to the greeting endpoint: 
+
+    http://localhost:8080/rest-mp-metrics/greeting
+    
+Check the metrics in Prometheus format:
+    
+    http://localhost:8080/rest-mp-metrics/metrics
+    
+    
+
+     
+


[4/6] tomee git commit: adding test to microprofile metrics

Posted by jg...@apache.org.
adding test to microprofile metrics


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

Branch: refs/heads/master
Commit: 017b98e89ac68e4d5b695e06a16c7a7e43561d20
Parents: b85fe05
Author: ivanjunckes <ij...@tomitribe.com>
Authored: Mon Nov 19 17:42:38 2018 -0200
Committer: ivanjunckes <ij...@tomitribe.com>
Committed: Mon Nov 19 17:42:38 2018 -0200

----------------------------------------------------------------------
 examples/rest-mp-metrics/pom.xml                | 27 +++++++++
 .../java/org/superbiz/rest/GreetingService.java |  5 +-
 .../org/superbiz/rest/GreetingServiceTest.java  | 61 ++++++++++++++++++++
 .../src/test/resources/arquillian.xml           | 30 ++++++++++
 4 files changed, 122 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/017b98e8/examples/rest-mp-metrics/pom.xml
----------------------------------------------------------------------
diff --git a/examples/rest-mp-metrics/pom.xml b/examples/rest-mp-metrics/pom.xml
index 97890db..ded0689 100644
--- a/examples/rest-mp-metrics/pom.xml
+++ b/examples/rest-mp-metrics/pom.xml
@@ -12,6 +12,7 @@
     <artifactId>rest-mp-metrics</artifactId>
     <packaging>war</packaging>
 
+
     <dependencies>
         <dependency>
             <groupId>org.apache.tomee</groupId>
@@ -25,6 +26,32 @@
             <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>

http://git-wip-us.apache.org/repos/asf/tomee/blob/017b98e8/examples/rest-mp-metrics/src/main/java/org/superbiz/rest/GreetingService.java
----------------------------------------------------------------------
diff --git a/examples/rest-mp-metrics/src/main/java/org/superbiz/rest/GreetingService.java b/examples/rest-mp-metrics/src/main/java/org/superbiz/rest/GreetingService.java
index fa84c69..a75087e 100644
--- a/examples/rest-mp-metrics/src/main/java/org/superbiz/rest/GreetingService.java
+++ b/examples/rest-mp-metrics/src/main/java/org/superbiz/rest/GreetingService.java
@@ -2,6 +2,7 @@ package org.superbiz.rest;
 
 import org.eclipse.microprofile.metrics.annotation.Counted;
 
+import javax.enterprise.context.ApplicationScoped;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
@@ -11,10 +12,12 @@ import javax.ws.rs.core.MediaType;
 @Path("/greeting")
 @Produces(MediaType.APPLICATION_JSON)
 @Consumes(MediaType.APPLICATION_JSON)
+@ApplicationScoped
 public class GreetingService {
 
-    @Counted(monotonic = true, name = "count_messages")
+    @Counted(monotonic = true, name = "message_counter", absolute = true)
     @GET
+    @Produces(MediaType.TEXT_PLAIN)
     public String message() {
         return "Hi Microprofile Metrics!";
     }

http://git-wip-us.apache.org/repos/asf/tomee/blob/017b98e8/examples/rest-mp-metrics/src/test/java/org/superbiz/rest/GreetingServiceTest.java
----------------------------------------------------------------------
diff --git a/examples/rest-mp-metrics/src/test/java/org/superbiz/rest/GreetingServiceTest.java b/examples/rest-mp-metrics/src/test/java/org/superbiz/rest/GreetingServiceTest.java
new file mode 100644
index 0000000..dff4044
--- /dev/null
+++ b/examples/rest-mp-metrics/src/test/java/org/superbiz/rest/GreetingServiceTest.java
@@ -0,0 +1,61 @@
+/**
+ * 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.
+ */
+package org.superbiz.rest;
+
+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.ws.rs.core.MediaType;
+import java.net.URL;
+
+import static org.junit.Assert.assertEquals;
+
+@RunWith(Arquillian.class)
+public class GreetingServiceTest {
+
+    @Deployment(testable = false)
+    public static WebArchive createDeployment() {
+        final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "test.war")
+                .addClass(GreetingService.class)
+                .addAsWebInfResource(new StringAsset("<beans/>"), "beans.xml");
+        return webArchive;
+    }
+
+    @ArquillianResource
+    private URL base;
+
+    @Test
+    public void testPrometheusApplicationMetric() {
+        final String message = WebClient.create(base.toExternalForm())
+                .path("/greeting/")
+                .get(String.class);
+        assertEquals("Hi Microprofile Metrics!", message);
+
+        final String metric = WebClient.create(base.toExternalForm())
+                .path("/metrics/application/message_counter")
+                .accept(MediaType.TEXT_PLAIN)
+                .get(String.class);
+        assertEquals("# TYPE application:message_counter counter\napplication:message_counter 1.0\n", metric);
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/017b98e8/examples/rest-mp-metrics/src/test/resources/arquillian.xml
----------------------------------------------------------------------
diff --git a/examples/rest-mp-metrics/src/test/resources/arquillian.xml b/examples/rest-mp-metrics/src/test/resources/arquillian.xml
new file mode 100644
index 0000000..3029d48
--- /dev/null
+++ b/examples/rest-mp-metrics/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


[6/6] tomee git commit: Merge branch 'metrics-example' of github.com:ivanjunckes/tomee

Posted by jg...@apache.org.
Merge branch 'metrics-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/51a07dec
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/51a07dec
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/51a07dec

Branch: refs/heads/master
Commit: 51a07decf9c26b160eb37913feab1d817367273e
Parents: 9a0beb7 be6bf8f
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Mon Nov 19 20:14:42 2018 +0000
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Mon Nov 19 20:14:42 2018 +0000

----------------------------------------------------------------------
 examples/pom.xml                                |  1 +
 examples/rest-mp-metrics/README.md              | 19 ++++++
 examples/rest-mp-metrics/pom.xml                | 70 ++++++++++++++++++++
 .../java/org/superbiz/rest/GreetingService.java | 24 +++++++
 .../org/superbiz/rest/GreetingServiceTest.java  | 61 +++++++++++++++++
 .../src/test/resources/arquillian.xml           | 30 +++++++++
 6 files changed, 205 insertions(+)
----------------------------------------------------------------------



[2/6] tomee git commit: Adding rest service

Posted by jg...@apache.org.
Adding rest service


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

Branch: refs/heads/master
Commit: cd09707502f35f2b0154ec8b1062d35a2b516bed
Parents: fffa371
Author: ivanjunckes <ij...@tomitribe.com>
Authored: Mon Nov 19 10:04:18 2018 -0200
Committer: ivanjunckes <ij...@tomitribe.com>
Committed: Mon Nov 19 10:04:18 2018 -0200

----------------------------------------------------------------------
 .../java/org/superbiz/rest/GreetingService.java | 21 ++++++++++++++++++++
 1 file changed, 21 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/cd097075/examples/rest-mp-metrics/src/main/java/org/superbiz/rest/GreetingService.java
----------------------------------------------------------------------
diff --git a/examples/rest-mp-metrics/src/main/java/org/superbiz/rest/GreetingService.java b/examples/rest-mp-metrics/src/main/java/org/superbiz/rest/GreetingService.java
new file mode 100644
index 0000000..fa84c69
--- /dev/null
+++ b/examples/rest-mp-metrics/src/main/java/org/superbiz/rest/GreetingService.java
@@ -0,0 +1,21 @@
+package org.superbiz.rest;
+
+import org.eclipse.microprofile.metrics.annotation.Counted;
+
+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("/greeting")
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+public class GreetingService {
+
+    @Counted(monotonic = true, name = "count_messages")
+    @GET
+    public String message() {
+        return "Hi Microprofile Metrics!";
+    }
+}


[3/6] tomee git commit: adding tomee plugin and dependencies

Posted by jg...@apache.org.
adding tomee plugin and dependencies


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

Branch: refs/heads/master
Commit: b85fe05851e208f4744e1b7a7a5b3ea3ca89ed7e
Parents: cd09707
Author: ivanjunckes <ij...@tomitribe.com>
Authored: Mon Nov 19 10:50:30 2018 -0200
Committer: ivanjunckes <ij...@tomitribe.com>
Committed: Mon Nov 19 10:50:30 2018 -0200

----------------------------------------------------------------------
 examples/rest-mp-metrics/pom.xml | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/b85fe058/examples/rest-mp-metrics/pom.xml
----------------------------------------------------------------------
diff --git a/examples/rest-mp-metrics/pom.xml b/examples/rest-mp-metrics/pom.xml
index 6a31d77..97890db 100644
--- a/examples/rest-mp-metrics/pom.xml
+++ b/examples/rest-mp-metrics/pom.xml
@@ -10,6 +10,34 @@
     <modelVersion>4.0.0</modelVersion>
 
     <artifactId>rest-mp-metrics</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>
+    </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