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 2022/04/13 12:50:39 UTC

[tomee] branch master updated (28d74c923b -> 1e2e6ef385)

This is an automated email from the ASF dual-hosted git repository.

jlmonteiro pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git


    from 28d74c923b TOMEE-3901 change openejb.cdi.ignore-not-loadable-extensions default to true
     new efeee67bb5 Don't carry on the jakarta and the non jakarta version of batchee
     new 1e2e6ef385 TOMEE-3896 Smallrye Metrics integration and wiring

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 boms/tomee-plume/pom.xml                           | 11 ----
 container/openejb-core/pom.xml                     |  6 ++
 .../MicroProfileMetricsTCKDeploymentPackager.java  |  9 ++-
 .../metrics/src/test/resources/arquillian.xml      |  1 +
 .../microprofile/TomEEMicroProfileListener.java    | 17 +++---
 .../health/MicroProfileHealthReporterProducer.java |  3 +
 .../metrics/MPMetricsCDIExtension.java             | 27 +++++----
 .../metrics/MicroProfileMetricsEndpoint.java       | 58 ++++++++++++++++++
 .../MicroProfileServletContainerInitializer.java   | 46 +++++++--------
 .../jakarta.enterprise.inject.spi.Extension        |  1 +
 .../jakarta.servlet.ServletContainerInitializer    |  1 +
 .../META-INF/services/jakarta.ws.rs.ext.Providers  |  1 +
 .../io/smallrye/metrics/base-metrics.properties    | 69 ++++++++++++++++++++++
 .../io/smallrye/metrics/vendor-metrics.properties  | 15 +++++
 tomee/tomee-plume-webapp/pom.xml                   | 18 ++----
 tomee/tomee-plus-webapp/pom.xml                    |  6 ++
 16 files changed, 220 insertions(+), 69 deletions(-)
 copy arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/classloader/HashCdiExtension.java => tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/metrics/MPMetricsCDIExtension.java (57%)
 create mode 100644 tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/metrics/MicroProfileMetricsEndpoint.java
 copy mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/MPJWTInitializer.java => tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/metrics/MicroProfileServletContainerInitializer.java (56%)
 create mode 100644 tomee/tomee-microprofile/mp-common/src/main/resources/META-INF/services/jakarta.servlet.ServletContainerInitializer
 create mode 100644 tomee/tomee-microprofile/mp-common/src/main/resources/META-INF/services/jakarta.ws.rs.ext.Providers
 create mode 100644 tomee/tomee-microprofile/mp-common/src/main/resources/io/smallrye/metrics/base-metrics.properties
 create mode 100644 tomee/tomee-microprofile/mp-common/src/main/resources/io/smallrye/metrics/vendor-metrics.properties


[tomee] 01/02: Don't carry on the jakarta and the non jakarta version of batchee

Posted by jl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jlmonteiro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git

commit efeee67bb5b013044aac8c3866f8e9a367864317
Author: Jean-Louis Monteiro <jl...@tomitribe.com>
AuthorDate: Wed Apr 13 12:35:38 2022 +0200

    Don't carry on the jakarta and the non jakarta version of batchee
---
 boms/tomee-plume/pom.xml         | 11 -----------
 container/openejb-core/pom.xml   |  6 ++++++
 tomee/tomee-plume-webapp/pom.xml | 18 ++++++------------
 tomee/tomee-plus-webapp/pom.xml  |  6 ++++++
 4 files changed, 18 insertions(+), 23 deletions(-)

diff --git a/boms/tomee-plume/pom.xml b/boms/tomee-plume/pom.xml
index 3b2cf5d009..cdcca63528 100644
--- a/boms/tomee-plume/pom.xml
+++ b/boms/tomee-plume/pom.xml
@@ -551,17 +551,6 @@
         </exclusion>
       </exclusions>
     </dependency>
-    <dependency>
-      <groupId>org.apache.batchee</groupId>
-      <artifactId>batchee-jbatch</artifactId>
-      <version>1.0.2-SNAPSHOT</version>
-      <exclusions>
-        <exclusion>
-          <artifactId>*</artifactId>
-          <groupId>*</groupId>
-        </exclusion>
-      </exclusions>
-    </dependency>
     <dependency>
       <groupId>org.apache.batchee</groupId>
       <artifactId>batchee-jbatch</artifactId>
diff --git a/container/openejb-core/pom.xml b/container/openejb-core/pom.xml
index dfbd28b517..817ea1b26a 100644
--- a/container/openejb-core/pom.xml
+++ b/container/openejb-core/pom.xml
@@ -734,6 +734,12 @@
       <version>${batchee.version}</version>
       <scope>provided</scope>
       <classifier>jakarta</classifier>
+      <exclusions>
+        <exclusion>
+          <groupId>org.apache.batchee</groupId>
+          <artifactId>*</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
 
   </dependencies>
diff --git a/tomee/tomee-plume-webapp/pom.xml b/tomee/tomee-plume-webapp/pom.xml
index e5a6ef6252..9e5f5e0623 100644
--- a/tomee/tomee-plume-webapp/pom.xml
+++ b/tomee/tomee-plume-webapp/pom.xml
@@ -360,18 +360,12 @@
       <version>${batchee.version}</version>
       <scope>runtime</scope>
       <classifier>jakarta</classifier>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.commons</groupId>
-      <artifactId>commons-jcs-jcache</artifactId>
-      <version>${jcs.version}</version>
-      <scope>runtime</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.batchee</groupId>
-      <artifactId>batchee-jbatch</artifactId>
-      <version>${batchee.version}</version>
-      <scope>runtime</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>org.apache.batchee</groupId>
+          <artifactId>*</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.apache.commons</groupId>
diff --git a/tomee/tomee-plus-webapp/pom.xml b/tomee/tomee-plus-webapp/pom.xml
index 3955646df3..052cac4130 100644
--- a/tomee/tomee-plus-webapp/pom.xml
+++ b/tomee/tomee-plus-webapp/pom.xml
@@ -364,6 +364,12 @@
       <version>${batchee.version}</version>
       <scope>runtime</scope>
       <classifier>jakarta</classifier>
+      <exclusions>
+        <exclusion>
+          <groupId>org.apache.batchee</groupId>
+          <artifactId>*</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.apache.commons</groupId>


[tomee] 02/02: TOMEE-3896 Smallrye Metrics integration and wiring

Posted by jl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jlmonteiro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git

commit 1e2e6ef38534264df997207e6e61c11527a298a9
Author: Jean-Louis Monteiro <jl...@tomitribe.com>
AuthorDate: Wed Apr 13 14:50:30 2022 +0200

    TOMEE-3896 Smallrye Metrics integration and wiring
---
 .../MicroProfileMetricsTCKDeploymentPackager.java  |  9 ++-
 .../metrics/src/test/resources/arquillian.xml      |  1 +
 .../microprofile/TomEEMicroProfileListener.java    | 17 +++---
 .../health/MicroProfileHealthReporterProducer.java |  3 +
 .../metrics/MPMetricsCDIExtension.java             | 39 ++++++++++++
 .../metrics/MicroProfileMetricsEndpoint.java       | 58 ++++++++++++++++++
 .../MicroProfileServletContainerInitializer.java   | 60 +++++++++++++++++++
 .../jakarta.enterprise.inject.spi.Extension        |  1 +
 .../jakarta.servlet.ServletContainerInitializer    |  1 +
 .../META-INF/services/jakarta.ws.rs.ext.Providers  |  1 +
 .../io/smallrye/metrics/base-metrics.properties    | 69 ++++++++++++++++++++++
 .../io/smallrye/metrics/vendor-metrics.properties  | 15 +++++
 12 files changed, 264 insertions(+), 10 deletions(-)

diff --git a/tck/microprofile-tck/metrics/src/test/java/org/apache/tomee/microprofile/tck/metrics/MicroProfileMetricsTCKDeploymentPackager.java b/tck/microprofile-tck/metrics/src/test/java/org/apache/tomee/microprofile/tck/metrics/MicroProfileMetricsTCKDeploymentPackager.java
index 329ecfcf73..5da3a136ea 100644
--- a/tck/microprofile-tck/metrics/src/test/java/org/apache/tomee/microprofile/tck/metrics/MicroProfileMetricsTCKDeploymentPackager.java
+++ b/tck/microprofile-tck/metrics/src/test/java/org/apache/tomee/microprofile/tck/metrics/MicroProfileMetricsTCKDeploymentPackager.java
@@ -37,13 +37,16 @@ public class MicroProfileMetricsTCKDeploymentPackager extends ServletProtocolDep
     public Archive<?> generateDeployment(final TestDeployment testDeployment,
                                          final Collection<ProtocolArchiveProcessor> processors) {
         final Archive<?> applicationArchive = testDeployment.getApplicationArchive();
+        final WebArchive wrapperWar = ShrinkWrap.create(WebArchive.class, "microprofile-metrics.war");
         if (applicationArchive instanceof JavaArchive) {
-            final WebArchive wrapperWar =
-                    ShrinkWrap.create(WebArchive.class, "microprofile-metrics.war").addAsLibrary(applicationArchive);
+            wrapperWar.addAsLibrary(applicationArchive);
             return super.generateDeployment(new TestDeploymentDelegate(testDeployment, wrapperWar), processors);
         }
 
-        return super.generateDeployment(testDeployment, processors);
+        wrapperWar.merge(applicationArchive);
+        return super.generateDeployment(new TestDeploymentDelegate(testDeployment, wrapperWar), processors);
+
+        // return super.generateDeployment(testDeployment, processors);
     }
 
     private static class TestDeploymentDelegate extends TestDeployment {
diff --git a/tck/microprofile-tck/metrics/src/test/resources/arquillian.xml b/tck/microprofile-tck/metrics/src/test/resources/arquillian.xml
index ce97b1d36c..8408d7432f 100644
--- a/tck/microprofile-tck/metrics/src/test/resources/arquillian.xml
+++ b/tck/microprofile-tck/metrics/src/test/resources/arquillian.xml
@@ -27,6 +27,7 @@
       <property name="ajpPort">-1</property>
       <property name="stopPort">-1</property>
       <property name="classifier">microprofile</property>
+      <property name="debug">false</property>
       <property name="conf">src/test/conf</property>
       <property name="dir">target/tomee</property>
       <property name="appWorkingDir">target/workdir</property>
diff --git a/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/TomEEMicroProfileListener.java b/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/TomEEMicroProfileListener.java
index 66f13cb72a..418906f59c 100644
--- a/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/TomEEMicroProfileListener.java
+++ b/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/TomEEMicroProfileListener.java
@@ -17,6 +17,7 @@
 package org.apache.tomee.microprofile;
 
 import jakarta.servlet.ServletContext;
+import jakarta.servlet.ServletRegistration;
 import org.apache.openejb.assembler.classic.WebAppInfo;
 import org.apache.openejb.config.event.EnhanceScannableUrlsEvent;
 import org.apache.openejb.loader.SystemInstance;
@@ -26,11 +27,13 @@ import org.apache.openejb.util.LogCategory;
 import org.apache.openejb.util.Logger;
 import org.apache.tomee.catalina.event.AfterApplicationCreated;
 import org.apache.tomee.installer.Paths;
+import org.apache.tomee.microprofile.health.MicroProfileHealthChecksEndpoint;
 
 import java.io.File;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.security.CodeSource;
+import java.util.Collection;
 import java.util.List;
 import java.util.stream.Stream;
 
@@ -51,7 +54,8 @@ public class TomEEMicroProfileListener {
             "org.apache.cxf.microprofile.client.cdi.RestClientExtension",
             "io.smallrye.config.inject.ConfigExtension",
             "io.smallrye.metrics.setup.MetricCdiInjectionExtension",
-            "io.smallrye.opentracing.SmallRyeTracingDynamicFeature"
+            "io.smallrye.opentracing.SmallRyeTracingDynamicFeature",
+            "io.smallrye.metrics.setup.MetricCdiInjectionExtension",
             };
 
     @SuppressWarnings("Duplicates")
@@ -101,13 +105,12 @@ public class TomEEMicroProfileListener {
         final WebAppInfo webApp = afterApplicationCreated.getEvent().getWeb();
 
         // These remove duplicated REST API endpoints.
-        // webApp.restClass.removeIf(className -> className.equals(HealthChecksEndpoint.class.getName()));
+        webApp.restClass.removeIf(className -> className.equals(MicroProfileHealthChecksEndpoint.class.getName()));
         // webApp.restClass.removeIf(className -> className.equals(MetricsEndpoints.class.getName()));
 
         // There remove all of MP REST API endpoint if there is a servlet already registered in /*. The issue here is
         // that REST path has priority over servlet and there may override old applications that have servlets
         // with /* mapping.
-        /*
         context.getServletRegistrations()
                .values()
                .stream()
@@ -116,10 +119,10 @@ public class TomEEMicroProfileListener {
                .filter(mapping -> mapping.equals("/*"))
                .findFirst()
                .ifPresent(mapping -> {
-                   webApp.restClass.removeIf(className -> className.equals(CdiHealthChecksEndpoint.class.getName()));
-                   webApp.restClass.removeIf(className -> className.equals(CdiMetricsEndpoints.class.getName()));
-                   webApp.restClass.removeIf(className -> className.equals(OpenAPIEndpoint.class.getName()));
+                   webApp.restClass.removeIf(className -> className.equals(MicroProfileHealthChecksEndpoint.class.getName()));
+                   // webApp.restClass.removeIf(className -> className.equals(CdiMetricsEndpoints.class.getName()));
+                   // webApp.restClass.removeIf(className -> className.equals(OpenAPIEndpoint.class.getName()));
                });
-         */
+
     }
 }
diff --git a/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/health/MicroProfileHealthReporterProducer.java b/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/health/MicroProfileHealthReporterProducer.java
index ffaedc5bab..9fd8bd146a 100644
--- a/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/health/MicroProfileHealthReporterProducer.java
+++ b/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/health/MicroProfileHealthReporterProducer.java
@@ -36,8 +36,10 @@ public class MicroProfileHealthReporterProducer {
 
         // MicroProfile Health supports the mp.health.disable-default-procedures to let users disable any vendor procedures
         final boolean defaultServerProceduresDisabled = ConfigProvider.getConfig().getOptionalValue("mp.health.disable-default-procedures", Boolean.class).orElse(false);
+
         // MicroProfile Health supports the mp.health.default.readiness.empty.response to let users specify default empty readiness responses
         final String defaultReadinessEmptyResponse = ConfigProvider.getConfig().getOptionalValue("mp.health.default.readiness.empty.response", String.class).orElse("DOWN");
+
         // MicroProfile Health supports the mp.health.default.startup.empty.response to let users specify default empty startup responses
         final String defaultStartupEmptyResponse = ConfigProvider.getConfig().getOptionalValue("mp.health.default.startup.empty.response", String.class).orElse("DOWN");
 
@@ -47,6 +49,7 @@ public class MicroProfileHealthReporterProducer {
 
         if (!defaultServerProceduresDisabled) {
             ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+
             // todo add our own server checks
         }
 
diff --git a/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/metrics/MPMetricsCDIExtension.java b/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/metrics/MPMetricsCDIExtension.java
new file mode 100644
index 0000000000..a058238c91
--- /dev/null
+++ b/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/metrics/MPMetricsCDIExtension.java
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+package org.apache.tomee.microprofile.metrics;
+
+import io.smallrye.metrics.setup.JmxRegistrar;
+import jakarta.enterprise.event.Observes;
+import jakarta.enterprise.inject.spi.AfterDeploymentValidation;
+import jakarta.enterprise.inject.spi.BeanManager;
+import jakarta.enterprise.inject.spi.Extension;
+import org.apache.openejb.util.LogCategory;
+import org.apache.openejb.util.Logger;
+
+public class MPMetricsCDIExtension implements Extension {
+
+    private void afterDeploymentValidation(@Observes final AfterDeploymentValidation avd, BeanManager bm) {
+        try {
+            final JmxRegistrar registrar = new JmxRegistrar();
+            registrar.init();
+
+        } catch (final Exception e) {
+            Logger.getInstance(LogCategory.OPENEJB, MPMetricsCDIExtension.class).error("Can't initialize Metrics Registrar: " + e.getMessage());
+        }
+    }
+
+}
\ No newline at end of file
diff --git a/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/metrics/MicroProfileMetricsEndpoint.java b/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/metrics/MicroProfileMetricsEndpoint.java
new file mode 100644
index 0000000000..d8f474494c
--- /dev/null
+++ b/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/metrics/MicroProfileMetricsEndpoint.java
@@ -0,0 +1,58 @@
+/**
+ * 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.
+ */
+package org.apache.tomee.microprofile.metrics;
+
+import io.smallrye.metrics.MetricsRequestHandler;
+import jakarta.inject.Inject;
+import jakarta.servlet.annotation.WebServlet;
+import jakarta.servlet.http.HttpServlet;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.stream.Stream;
+
+/**
+ * This is not a JAXRS endpoint but a regular servlet because the Smallrye handler does the remaining job
+ */
+@WebServlet(name = "metrics-servlet", urlPatterns = "/metrics/*")
+public class MicroProfileMetricsEndpoint extends HttpServlet {
+
+    @Inject
+    private MetricsRequestHandler metricsHandler;
+
+    @Override
+    protected void doOptions(final HttpServletRequest req, final HttpServletResponse resp) throws IOException {
+        doGet(req, resp);
+    }
+
+    @Override
+    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
+        final String requestPath = request.getContextPath().length() > 1
+                                   ? request.getRequestURI().substring(request.getContextPath().length())
+                                   : request.getRequestURI();
+        final String method = request.getMethod();
+        final Stream<String> acceptHeaders = Collections.list(request.getHeaders("Accept")).stream();
+
+        metricsHandler.handleRequest(requestPath, method, acceptHeaders, (status, message, headers) -> {
+            headers.forEach(response::addHeader);
+            response.setStatus(status);
+            response.getWriter().write(message);
+        });
+    }
+}
diff --git a/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/metrics/MicroProfileServletContainerInitializer.java b/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/metrics/MicroProfileServletContainerInitializer.java
new file mode 100644
index 0000000000..93b3956e89
--- /dev/null
+++ b/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/metrics/MicroProfileServletContainerInitializer.java
@@ -0,0 +1,60 @@
+/*
+ *     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.
+ */
+package org.apache.tomee.microprofile.metrics;
+
+import io.smallrye.metrics.jaxrs.JaxRsMetricsServletFilter;
+import jakarta.servlet.FilterRegistration;
+import jakarta.servlet.ServletContainerInitializer;
+import jakarta.servlet.ServletContext;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.ServletRegistration;
+import jakarta.servlet.annotation.HandlesTypes;
+import jakarta.servlet.annotation.WebFilter;
+import jakarta.servlet.annotation.WebServlet;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.core.Application;
+import org.apache.tomee.microprofile.jwt.MPJWTFilter;
+import org.eclipse.microprofile.auth.LoginConfig;
+
+import java.util.Set;
+
+/**
+ * Responsible for adding the filter into the chain and doing all other initialization
+ *
+ * todo do we want to be so restrictive with the HandlesTypes annotation?
+@HandlesTypes({Path.class,
+               WebServlet.class,
+               WebFilter.class
+})
+ */
+public class MicroProfileServletContainerInitializer implements ServletContainerInitializer {
+
+    @Override
+    public void onStartup(final Set<Class<?>> classes, final ServletContext ctx) throws ServletException {
+
+
+
+        final FilterRegistration.Dynamic metricsServletFilter = ctx.addFilter("mp-metrics-filter", JaxRsMetricsServletFilter.class);
+        metricsServletFilter.setAsyncSupported(true);
+        metricsServletFilter.addMappingForUrlPatterns(null, false, "/*");
+
+        final ServletRegistration.Dynamic servletRegistration = ctx.addServlet("mp-metrics-servlet", MicroProfileMetricsEndpoint.class);
+        servletRegistration.addMapping("/metrics/*");
+
+    }
+
+}
\ No newline at end of file
diff --git a/tomee/tomee-microprofile/mp-common/src/main/resources/META-INF/services/jakarta.enterprise.inject.spi.Extension b/tomee/tomee-microprofile/mp-common/src/main/resources/META-INF/services/jakarta.enterprise.inject.spi.Extension
index c2a778fd52..6517c671c2 100644
--- a/tomee/tomee-microprofile/mp-common/src/main/resources/META-INF/services/jakarta.enterprise.inject.spi.Extension
+++ b/tomee/tomee-microprofile/mp-common/src/main/resources/META-INF/services/jakarta.enterprise.inject.spi.Extension
@@ -1 +1,2 @@
 org.apache.tomee.microprofile.health.MPHealthCDIExtension
+org.apache.tomee.microprofile.metrics.MPMetricsCDIExtension
diff --git a/tomee/tomee-microprofile/mp-common/src/main/resources/META-INF/services/jakarta.servlet.ServletContainerInitializer b/tomee/tomee-microprofile/mp-common/src/main/resources/META-INF/services/jakarta.servlet.ServletContainerInitializer
new file mode 100644
index 0000000000..5d63c21c21
--- /dev/null
+++ b/tomee/tomee-microprofile/mp-common/src/main/resources/META-INF/services/jakarta.servlet.ServletContainerInitializer
@@ -0,0 +1 @@
+org.apache.tomee.microprofile.metrics.MicroProfileServletContainerInitializer
\ No newline at end of file
diff --git a/tomee/tomee-microprofile/mp-common/src/main/resources/META-INF/services/jakarta.ws.rs.ext.Providers b/tomee/tomee-microprofile/mp-common/src/main/resources/META-INF/services/jakarta.ws.rs.ext.Providers
new file mode 100644
index 0000000000..b7efaf9a18
--- /dev/null
+++ b/tomee/tomee-microprofile/mp-common/src/main/resources/META-INF/services/jakarta.ws.rs.ext.Providers
@@ -0,0 +1 @@
+io.smallrye.metrics.jaxrs.JaxRsMetricsFilter
\ No newline at end of file
diff --git a/tomee/tomee-microprofile/mp-common/src/main/resources/io/smallrye/metrics/base-metrics.properties b/tomee/tomee-microprofile/mp-common/src/main/resources/io/smallrye/metrics/base-metrics.properties
new file mode 100644
index 0000000000..954fb51c90
--- /dev/null
+++ b/tomee/tomee-microprofile/mp-common/src/main/resources/io/smallrye/metrics/base-metrics.properties
@@ -0,0 +1,69 @@
+classloader.loadedClasses.count.displayName: Current Loaded Class Count
+classloader.loadedClasses.count.type: gauge
+classloader.loadedClasses.count.unit: none
+classloader.loadedClasses.count.description: Displays the number of classes that are currently loaded in the Java virtual machine.
+classloader.loadedClasses.count.mbean: java.lang:type=ClassLoading/LoadedClassCount
+classloader.loadedClasses.total.displayName: Total Loaded Class Count
+classloader.loadedClasses.total.type: counter
+classloader.loadedClasses.total.unit: none
+classloader.loadedClasses.total.description: Displays the total number of classes that have been loaded since the Java virtual machine has started execution.
+classloader.loadedClasses.total.mbean: java.lang:type=ClassLoading/TotalLoadedClassCount
+classloader.unloadedClasses.total.displayName: Total Unloaded Class Count
+classloader.unloadedClasses.total.type: counter
+classloader.unloadedClasses.total.unit: none
+classloader.unloadedClasses.total.description: Displays the total number of classes unloaded since the Java virtual machine has started execution.
+classloader.unloadedClasses.total.mbean: java.lang:type=ClassLoading/UnloadedClassCount
+cpu.availableProcessors.displayName: Available Processors
+cpu.availableProcessors.type: gauge
+cpu.availableProcessors.unit: none
+cpu.availableProcessors.description: Displays the number of processors available to the Java virtual machine. This value may change during a particular invocation of the virtual machine.
+cpu.availableProcessors.mbean: java.lang:type=OperatingSystem/AvailableProcessors
+cpu.systemLoadAverage.displayName: System Load Average
+cpu.systemLoadAverage.type: gauge
+cpu.systemLoadAverage.unit: none
+cpu.systemLoadAverage.description: Displays the system load average for the last minute. The system load average is the sum of the number of runnable entities queued to the available processors and the number of runnable entities running on the available processors averaged over a period of time. The way in which the load average is calculated is operating system specific but is typically a damped time-dependent average. If the load average is not available, a negative value is displayed [...]
+cpu.systemLoadAverage.mbean: java.lang:type=OperatingSystem/SystemLoadAverage
+gc.total.displayName: Garbage Collection Count
+gc.total.type: counter
+gc.total.unit: none
+gc.total.multi: true
+gc.total.description:  Displays the total number of collections that have occurred. This attribute lists -1 if the collection count is undefined for this collector.
+gc.total.mbean: java.lang:type=GarbageCollector,name=%s/CollectionCount
+gc.total.tags: name=%s1
+gc.time.displayName: Garbage Collection Time
+gc.time.type: counter
+gc.time.unit: milliseconds
+gc.time.multi: true
+gc.time.description: Displays the approximate accumulated collection elapsed time in milliseconds. This attribute displays -1 if the collection elapsed time is undefined for this collector. The Java virtual machine implementation may use a high resolution timer to measure the elapsed time. This attribute may display the same value even if the collection count has been incremented if the collection elapsed time is very short.
+gc.time.mbean: java.lang:type=GarbageCollector,name=%s/CollectionTime
+gc.time.tags: name=%s1
+jvm.uptime.displayName: JVM Uptime
+jvm.uptime.type: gauge
+jvm.uptime.unit: milliseconds
+jvm.uptime.description: Displays the start time of the Java virtual machine in milliseconds. This attribute displays the approximate time when the Java virtual machine started.
+jvm.uptime.mbean: java.lang:type=Runtime/Uptime
+memory.committedHeap.mbean: java.lang:type=Memory/HeapMemoryUsage#committed
+memory.committedHeap.type: gauge
+memory.committedHeap.unit: bytes
+memory.maxHeap.mbean: java.lang:type=Memory/HeapMemoryUsage#max
+memory.maxHeap.description: Number of threads started for this server
+memory.maxHeap.unit: bytes
+memory.maxHeap.type: gauge
+memory.usedHeap.mbean: java.lang:type=Memory/HeapMemoryUsage#used
+memory.usedHeap.type: gauge
+memory.usedHeap.unit: bytes
+thread.count.mbean: java.lang:type=Threading/ThreadCount
+thread.count.description: Number of currently deployed threads
+thread.count.unit: none
+thread.count.type: gauge
+thread.count.displayName: Current Thread count
+thread.daemon.count.displayName: Daemon Thread Count
+thread.daemon.count.type: gauge
+thread.daemon.count.unit: none
+thread.daemon.count.description: Displays the current number of live daemon threads.
+thread.daemon.count.mbean: java.lang:type=Threading/DaemonThreadCount
+thread.max.count.displayName: Peak Thread Count
+thread.max.count.type: gauge
+thread.max.count.unit: none
+thread.max.count.description: Displays the peak live thread count since the Java virtual machine started or peak was reset. This includes daemon and non-daemon threads.
+thread.max.count.mbean: java.lang:type=Threading/PeakThreadCount
diff --git a/tomee/tomee-microprofile/mp-common/src/main/resources/io/smallrye/metrics/vendor-metrics.properties b/tomee/tomee-microprofile/mp-common/src/main/resources/io/smallrye/metrics/vendor-metrics.properties
new file mode 100644
index 0000000000..72e16e1d11
--- /dev/null
+++ b/tomee/tomee-microprofile/mp-common/src/main/resources/io/smallrye/metrics/vendor-metrics.properties
@@ -0,0 +1,15 @@
+BufferPool_used_memory_%s.mbean: java.nio:type=BufferPool,name=%s/MemoryUsed
+BufferPool_used_memory_%s.description: The memory used by the NIO pool: %s
+BufferPool_used_memory_%s.multi: true
+BufferPool_used_memory_%s.type: gauge
+BufferPool_used_memory_%s.unit: bytes
+memoryPool.%s.usage.mbean: java.lang:type=MemoryPool,name=%s/Usage#used
+memoryPool.%s.usage.unit: bytes
+memoryPool.%s.usage.description: Current usage of the %s memory pool
+memoryPool.%s.usage.multi: true
+memoryPool.%s.usage.type: gauge
+memoryPool.%s.usage.max.mbean: java.lang:type=MemoryPool,name=%s/PeakUsage#used
+memoryPool.%s.usage.max.unit: bytes
+memoryPool.%s.usage.max.description: Peak usage of the %s memory pool
+memoryPool.%s.usage.max.multi: true
+memoryPool.%s.usage.max.type: gauge
\ No newline at end of file