You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rz...@apache.org on 2024/04/25 09:45:22 UTC
(tomee) branch main updated: TOMEE-4113 - Update to MicroProfile Metrics 5 & SmallRye Metrics 5 (#972)
This is an automated email from the ASF dual-hosted git repository.
rzo1 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomee.git
The following commit(s) were added to refs/heads/main by this push:
new bf0c7d26d1 TOMEE-4113 - Update to MicroProfile Metrics 5 & SmallRye Metrics 5 (#972)
bf0c7d26d1 is described below
commit bf0c7d26d16628dfe05ee47f1c8213c2def5fb55
Author: Jonathan Gallimore <jo...@jrg.me.uk>
AuthorDate: Thu Apr 25 10:45:17 2024 +0100
TOMEE-4113 - Update to MicroProfile Metrics 5 & SmallRye Metrics 5 (#972)
* Something screwed up here - fixing this test
* TOMEE-3850 fix test and update for Jakarta
* Use MP Metrics 5.0.0-SNAPSHOT
* Change extension
* WIP
* WIP
* Add parameter map to MicroProfileMetricsEndpoint call to SmallRye
* Re-enable MP metrics TCK test suite, add MP Metrics Optional Tests, and increase memory limit for remote TomEE server
* Wiring for the optional tests
* Debugging the Filter
* Wire up metrics filter correctly
* Slight delay before calling the /metrics endpoint
* Micrometer version and JVM settings
* Use Microprofile Metrics API 5.0.0-RC2
* Fix MP metrics version
* Use smallrye milestone 1, and add vendor metrics for some of the stuff we expose via JMX.
* WIP
* WIP
* WIP on the TCK test suites
* Add metric registry clean up
* Update versions
* WIP
* Versions
* Update version
* Fixes from merge / rebase and latest EE10-related changes
* Minor version updates
* Update README to reflect recent changes
* Fix examples after Metrics 5.0.2
* Regenerate BOMs
* Regenerate boms + remove prometheus
* Prometheus is required for Metrics TCK
* Exclude three optional TCK tests (as we do not support gc jvm based metrics atm)
* Re-add missing TCKs
Removes outdated extension
Adjust example to metrics 5
---------
Co-authored-by: Richard Zowalla <rz...@apache.org>
---
boms/tomee-microprofile-api/pom.xml | 2 +-
boms/tomee-microprofile/pom.xml | 135 ++++++++++-
boms/tomee-plume-api/pom.xml | 2 +-
boms/tomee-plume/pom.xml | 141 ++++++++++-
boms/tomee-plus-api/pom.xml | 2 +-
boms/tomee-plus/pom.xml | 135 ++++++++++-
boms/tomee-webprofile/pom.xml | 22 +-
examples/mp-metrics-counted/pom.xml | 6 +-
.../java/org/superbiz/rest/WeatherService.java | 1 -
examples/mp-metrics-gauge/README.adoc | 1 -
examples/mp-metrics-gauge/README_es.adoc | 1 -
examples/mp-metrics-gauge/README_pt.adoc | 1 -
examples/mp-metrics-gauge/pom.xml | 2 +-
.../java/org/superbiz/rest/WeatherService.java | 1 -
examples/mp-metrics-histogram/README.adoc | 3 +-
examples/mp-metrics-histogram/README_es.adoc | 3 +-
examples/mp-metrics-histogram/README_pt.adoc | 3 +-
examples/mp-metrics-histogram/pom.xml | 6 +-
.../org/superbiz/histogram/WeatherService.java | 6 +-
.../org/superbiz/histogram/WeatherServiceTest.java | 3 +-
examples/mp-metrics-metered/README.adoc | 2 +-
examples/mp-metrics-metered/README_es.adoc | 2 +-
examples/mp-metrics-metered/README_pt.adoc | 2 +-
examples/mp-metrics-metered/pom.xml | 7 +-
.../java/org/superbiz/rest/WeatherService.java | 7 +-
examples/mp-metrics-timed/pom.xml | 6 +-
.../src/main/java/WeatherService.java | 4 +-
.../src/test/java/WeatherServiceTest.java | 130 ++---------
.../org/superbiz/rest/service/JmsResource.java | 35 ++-
pom.xml | 7 +-
tck/microprofile-tck/fault-tolerance/pom.xml | 13 ++
tck/microprofile-tck/metrics/pom.xml | 27 ++-
.../metrics/MicroProfileMetricsTCKObserver.java | 29 +++
tomee/tomee-microprofile/mp-common/pom.xml | 12 +
.../microprofile/TomEEMicroProfileListener.java | 2 +-
.../metrics/MPMetricsCDIExtension.java | 47 ----
.../metrics/MetricsFilterRegistration.java | 31 +++
.../metrics/MicroProfileMetricsEndpoint.java | 2 +-
.../tomee/microprofile/metrics/VendorMetrics.java | 258 +++++++++++++++++++++
.../META-INF/org.apache.openejb.extension | 1 +
.../META-INF/services/jakarta.ws.rs.ext.Providers | 1 -
41 files changed, 850 insertions(+), 251 deletions(-)
diff --git a/boms/tomee-microprofile-api/pom.xml b/boms/tomee-microprofile-api/pom.xml
index 6f36e02d0a..6ef9f68d6b 100644
--- a/boms/tomee-microprofile-api/pom.xml
+++ b/boms/tomee-microprofile-api/pom.xml
@@ -230,7 +230,7 @@
<dependency>
<groupId>org.eclipse.microprofile.metrics</groupId>
<artifactId>microprofile-metrics-api</artifactId>
- <version>4.0.1</version>
+ <version>5.0.2</version>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
diff --git a/boms/tomee-microprofile/pom.xml b/boms/tomee-microprofile/pom.xml
index 4f393ad0aa..eb72091ca6 100644
--- a/boms/tomee-microprofile/pom.xml
+++ b/boms/tomee-microprofile/pom.xml
@@ -111,6 +111,17 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-core</artifactId>
+ <version>4.0.4</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>com.sun.xml.messaging.saaj</groupId>
<artifactId>saaj-impl</artifactId>
@@ -199,6 +210,50 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>io.micrometer</groupId>
+ <artifactId>micrometer-commons</artifactId>
+ <version>1.12.5</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.micrometer</groupId>
+ <artifactId>micrometer-core</artifactId>
+ <version>1.12.5</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.micrometer</groupId>
+ <artifactId>micrometer-observation</artifactId>
+ <version>1.12.5</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.micrometer</groupId>
+ <artifactId>micrometer-registry-prometheus</artifactId>
+ <version>1.12.5</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-concurrent</artifactId>
@@ -243,6 +298,61 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>io.prometheus</groupId>
+ <artifactId>simpleclient</artifactId>
+ <version>0.16.0</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.prometheus</groupId>
+ <artifactId>simpleclient_common</artifactId>
+ <version>0.16.0</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.prometheus</groupId>
+ <artifactId>simpleclient_tracer_common</artifactId>
+ <version>0.16.0</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.prometheus</groupId>
+ <artifactId>simpleclient_tracer_otel</artifactId>
+ <version>0.16.0</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.prometheus</groupId>
+ <artifactId>simpleclient_tracer_otel_agent</artifactId>
+ <version>0.16.0</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>io.smallrye.common</groupId>
<artifactId>smallrye-common-annotation</artifactId>
@@ -400,7 +510,7 @@
<dependency>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-metrics</artifactId>
- <version>4.0.0</version>
+ <version>5.0.1</version>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
@@ -1918,7 +2028,7 @@
<dependency>
<groupId>org.eclipse.microprofile.metrics</groupId>
<artifactId>microprofile-metrics-api</artifactId>
- <version>4.0.1</version>
+ <version>5.0.2</version>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
@@ -1961,7 +2071,7 @@
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
- <artifactId>jaxb-core</artifactId>
+ <artifactId>jaxb-runtime</artifactId>
<version>4.0.4</version>
<exclusions>
<exclusion>
@@ -1972,7 +2082,7 @@
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
- <artifactId>jaxb-runtime</artifactId>
+ <artifactId>txw2</artifactId>
<version>4.0.4</version>
<exclusions>
<exclusion>
@@ -1982,9 +2092,9 @@
</exclusions>
</dependency>
<dependency>
- <groupId>org.glassfish.jaxb</groupId>
- <artifactId>txw2</artifactId>
- <version>4.0.4</version>
+ <groupId>org.hdrhistogram</groupId>
+ <artifactId>HdrHistogram</artifactId>
+ <version>2.1.12</version>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
@@ -2036,6 +2146,17 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.latencyutils</groupId>
+ <artifactId>LatencyUtils</artifactId>
+ <version>2.0.3</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>org.objectweb.howl</groupId>
<artifactId>howl</artifactId>
diff --git a/boms/tomee-plume-api/pom.xml b/boms/tomee-plume-api/pom.xml
index a498760f59..69b27d43b4 100644
--- a/boms/tomee-plume-api/pom.xml
+++ b/boms/tomee-plume-api/pom.xml
@@ -230,7 +230,7 @@
<dependency>
<groupId>org.eclipse.microprofile.metrics</groupId>
<artifactId>microprofile-metrics-api</artifactId>
- <version>4.0.1</version>
+ <version>5.0.2</version>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
diff --git a/boms/tomee-plume/pom.xml b/boms/tomee-plume/pom.xml
index 5614be78ae..dbf62e969b 100644
--- a/boms/tomee-plume/pom.xml
+++ b/boms/tomee-plume/pom.xml
@@ -111,6 +111,17 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-core</artifactId>
+ <version>4.0.4</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>com.sun.xml.messaging.saaj</groupId>
<artifactId>saaj-impl</artifactId>
@@ -199,6 +210,50 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>io.micrometer</groupId>
+ <artifactId>micrometer-commons</artifactId>
+ <version>1.12.5</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.micrometer</groupId>
+ <artifactId>micrometer-core</artifactId>
+ <version>1.12.5</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.micrometer</groupId>
+ <artifactId>micrometer-observation</artifactId>
+ <version>1.12.5</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.micrometer</groupId>
+ <artifactId>micrometer-registry-prometheus</artifactId>
+ <version>1.12.5</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-concurrent</artifactId>
@@ -243,6 +298,61 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>io.prometheus</groupId>
+ <artifactId>simpleclient</artifactId>
+ <version>0.16.0</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.prometheus</groupId>
+ <artifactId>simpleclient_common</artifactId>
+ <version>0.16.0</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.prometheus</groupId>
+ <artifactId>simpleclient_tracer_common</artifactId>
+ <version>0.16.0</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.prometheus</groupId>
+ <artifactId>simpleclient_tracer_otel</artifactId>
+ <version>0.16.0</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.prometheus</groupId>
+ <artifactId>simpleclient_tracer_otel_agent</artifactId>
+ <version>0.16.0</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>io.smallrye.common</groupId>
<artifactId>smallrye-common-annotation</artifactId>
@@ -400,7 +510,7 @@
<dependency>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-metrics</artifactId>
- <version>4.0.0</version>
+ <version>5.0.1</version>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
@@ -2018,7 +2128,7 @@
<dependency>
<groupId>org.eclipse.microprofile.metrics</groupId>
<artifactId>microprofile-metrics-api</artifactId>
- <version>4.0.1</version>
+ <version>5.0.2</version>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
@@ -2083,7 +2193,7 @@
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
- <artifactId>jaxb-core</artifactId>
+ <artifactId>jaxb-runtime</artifactId>
<version>4.0.4</version>
<exclusions>
<exclusion>
@@ -2094,7 +2204,7 @@
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
- <artifactId>jaxb-runtime</artifactId>
+ <artifactId>txw2</artifactId>
<version>4.0.4</version>
<exclusions>
<exclusion>
@@ -2104,9 +2214,9 @@
</exclusions>
</dependency>
<dependency>
- <groupId>org.glassfish.jaxb</groupId>
- <artifactId>txw2</artifactId>
- <version>4.0.4</version>
+ <groupId>org.glassfish</groupId>
+ <artifactId>jakarta.faces</artifactId>
+ <version>4.0.1</version>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
@@ -2115,9 +2225,9 @@
</exclusions>
</dependency>
<dependency>
- <groupId>org.glassfish</groupId>
- <artifactId>jakarta.faces</artifactId>
- <version>4.0.1</version>
+ <groupId>org.hdrhistogram</groupId>
+ <artifactId>HdrHistogram</artifactId>
+ <version>2.1.12</version>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
@@ -2169,6 +2279,17 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.latencyutils</groupId>
+ <artifactId>LatencyUtils</artifactId>
+ <version>2.0.3</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>org.objectweb.howl</groupId>
<artifactId>howl</artifactId>
diff --git a/boms/tomee-plus-api/pom.xml b/boms/tomee-plus-api/pom.xml
index b7215e18eb..8ec544bc5b 100644
--- a/boms/tomee-plus-api/pom.xml
+++ b/boms/tomee-plus-api/pom.xml
@@ -241,7 +241,7 @@
<dependency>
<groupId>org.eclipse.microprofile.metrics</groupId>
<artifactId>microprofile-metrics-api</artifactId>
- <version>4.0.1</version>
+ <version>5.0.2</version>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
diff --git a/boms/tomee-plus/pom.xml b/boms/tomee-plus/pom.xml
index 95d2a3be47..cf3eeb9e20 100644
--- a/boms/tomee-plus/pom.xml
+++ b/boms/tomee-plus/pom.xml
@@ -111,6 +111,17 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-core</artifactId>
+ <version>4.0.4</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>com.sun.xml.messaging.saaj</groupId>
<artifactId>saaj-impl</artifactId>
@@ -199,6 +210,50 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>io.micrometer</groupId>
+ <artifactId>micrometer-commons</artifactId>
+ <version>1.12.5</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.micrometer</groupId>
+ <artifactId>micrometer-core</artifactId>
+ <version>1.12.5</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.micrometer</groupId>
+ <artifactId>micrometer-observation</artifactId>
+ <version>1.12.5</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.micrometer</groupId>
+ <artifactId>micrometer-registry-prometheus</artifactId>
+ <version>1.12.5</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-concurrent</artifactId>
@@ -243,6 +298,61 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>io.prometheus</groupId>
+ <artifactId>simpleclient</artifactId>
+ <version>0.16.0</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.prometheus</groupId>
+ <artifactId>simpleclient_common</artifactId>
+ <version>0.16.0</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.prometheus</groupId>
+ <artifactId>simpleclient_tracer_common</artifactId>
+ <version>0.16.0</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.prometheus</groupId>
+ <artifactId>simpleclient_tracer_otel</artifactId>
+ <version>0.16.0</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.prometheus</groupId>
+ <artifactId>simpleclient_tracer_otel_agent</artifactId>
+ <version>0.16.0</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>io.smallrye.common</groupId>
<artifactId>smallrye-common-annotation</artifactId>
@@ -400,7 +510,7 @@
<dependency>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-metrics</artifactId>
- <version>4.0.0</version>
+ <version>5.0.1</version>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
@@ -2040,7 +2150,7 @@
<dependency>
<groupId>org.eclipse.microprofile.metrics</groupId>
<artifactId>microprofile-metrics-api</artifactId>
- <version>4.0.1</version>
+ <version>5.0.2</version>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
@@ -2094,7 +2204,7 @@
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
- <artifactId>jaxb-core</artifactId>
+ <artifactId>jaxb-runtime</artifactId>
<version>4.0.4</version>
<exclusions>
<exclusion>
@@ -2105,7 +2215,7 @@
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
- <artifactId>jaxb-runtime</artifactId>
+ <artifactId>txw2</artifactId>
<version>4.0.4</version>
<exclusions>
<exclusion>
@@ -2115,9 +2225,9 @@
</exclusions>
</dependency>
<dependency>
- <groupId>org.glassfish.jaxb</groupId>
- <artifactId>txw2</artifactId>
- <version>4.0.4</version>
+ <groupId>org.hdrhistogram</groupId>
+ <artifactId>HdrHistogram</artifactId>
+ <version>2.1.12</version>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
@@ -2169,6 +2279,17 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.latencyutils</groupId>
+ <artifactId>LatencyUtils</artifactId>
+ <version>2.0.3</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>org.objectweb.howl</groupId>
<artifactId>howl</artifactId>
diff --git a/boms/tomee-webprofile/pom.xml b/boms/tomee-webprofile/pom.xml
index a2ecf5afe1..505d38bff9 100644
--- a/boms/tomee-webprofile/pom.xml
+++ b/boms/tomee-webprofile/pom.xml
@@ -67,6 +67,17 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-core</artifactId>
+ <version>4.0.4</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>com.sun.xml.messaging.saaj</groupId>
<artifactId>saaj-impl</artifactId>
@@ -1497,17 +1508,6 @@
</exclusion>
</exclusions>
</dependency>
- <dependency>
- <groupId>org.glassfish.jaxb</groupId>
- <artifactId>jaxb-core</artifactId>
- <version>4.0.4</version>
- <exclusions>
- <exclusion>
- <artifactId>*</artifactId>
- <groupId>*</groupId>
- </exclusion>
- </exclusions>
- </dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
diff --git a/examples/mp-metrics-counted/pom.xml b/examples/mp-metrics-counted/pom.xml
index 09cf2ffcf9..8b26eff0b9 100644
--- a/examples/mp-metrics-counted/pom.xml
+++ b/examples/mp-metrics-counted/pom.xml
@@ -25,7 +25,7 @@
<name>TomEE :: Examples :: Microprofile Metrics Counted</name>
<properties>
<version.jakartaee-api>10.0-M2</version.jakartaee-api>
- <version.microprofile.metrics>4.0.1</version.microprofile.metrics>
+ <version.microprofile.metrics>5.0.2</version.microprofile.metrics>
<version.arquillian.bom>1.7.0.Final</version.arquillian.bom>
<junit.version>4.13.2</junit.version>
<docker.image.name>tomee/${project.artifactId}</docker.image.name>
@@ -94,8 +94,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
- <source>1.8</source>
- <target>1.8</target>
+ <source>17</source>
+ <target>17</target>
</configuration>
</plugin>
diff --git a/examples/mp-metrics-counted/src/main/java/org/superbiz/rest/WeatherService.java b/examples/mp-metrics-counted/src/main/java/org/superbiz/rest/WeatherService.java
index 1194fc1493..07c8fd7b90 100644
--- a/examples/mp-metrics-counted/src/main/java/org/superbiz/rest/WeatherService.java
+++ b/examples/mp-metrics-counted/src/main/java/org/superbiz/rest/WeatherService.java
@@ -35,7 +35,6 @@ public class WeatherService {
@Path("/day/status")
@Counted(name = "weather_day_status", absolute = true,
- displayName = "Weather Day Status",
description = "This metric shows the weather status of the day.",
tags = {"weather=day"})
@GET
diff --git a/examples/mp-metrics-gauge/README.adoc b/examples/mp-metrics-gauge/README.adoc
index 49369dad65..805b4a58c2 100644
--- a/examples/mp-metrics-gauge/README.adoc
+++ b/examples/mp-metrics-gauge/README.adoc
@@ -41,7 +41,6 @@ public class WeatherService {
@Path("/day/temperature")
@Gauge(name = "weather_day_temperature", absolute = true, unit = "celsius",
- displayName = "Weather Day Temperature",
description = "This metric shows the day temperature.",
tags = {"weather=temperature"})
@GET
diff --git a/examples/mp-metrics-gauge/README_es.adoc b/examples/mp-metrics-gauge/README_es.adoc
index a5e1865aee..6e9f7be0cf 100644
--- a/examples/mp-metrics-gauge/README_es.adoc
+++ b/examples/mp-metrics-gauge/README_es.adoc
@@ -43,7 +43,6 @@ public class WeatherService {
@Path("/day/temperature")
@Gauge(name = "weather_day_temperature", absolute = true, unit = "celsius",
- displayName = "Weather Day Temperature",
description = "This metric shows the day temperature.",
tags = {"weather=temperature"})
@GET
diff --git a/examples/mp-metrics-gauge/README_pt.adoc b/examples/mp-metrics-gauge/README_pt.adoc
index 18bb4ab35c..e0825d3750 100644
--- a/examples/mp-metrics-gauge/README_pt.adoc
+++ b/examples/mp-metrics-gauge/README_pt.adoc
@@ -41,7 +41,6 @@ public class WeatherService {
@Path("/day/temperature")
@Gauge(name = "weather_day_temperature", absolute = true, unit = "celsius",
- displayName = "Weather Day Temperature",
description = "This metric shows the day temperature.",
tags = {"weather=temperature"})
@GET
diff --git a/examples/mp-metrics-gauge/pom.xml b/examples/mp-metrics-gauge/pom.xml
index d41394384f..39c4e575fe 100644
--- a/examples/mp-metrics-gauge/pom.xml
+++ b/examples/mp-metrics-gauge/pom.xml
@@ -24,7 +24,7 @@
<name>TomEE :: Examples :: MicroProfile Metrics Gauge</name>
<properties>
<version.jakartaee-api>10.0-M2</version.jakartaee-api>
- <version.microprofile.metrics>4.0.1</version.microprofile.metrics>
+ <version.microprofile.metrics>5.0.2</version.microprofile.metrics>
<version.arquillian.bom>1.7.0.Final</version.arquillian.bom>
<junit.version>4.13.2</junit.version>
<tomee.version>10.0.0-M2-SNAPSHOT</tomee.version>
diff --git a/examples/mp-metrics-gauge/src/main/java/org/superbiz/rest/WeatherService.java b/examples/mp-metrics-gauge/src/main/java/org/superbiz/rest/WeatherService.java
index 078b2b1bce..3fbbfba48a 100644
--- a/examples/mp-metrics-gauge/src/main/java/org/superbiz/rest/WeatherService.java
+++ b/examples/mp-metrics-gauge/src/main/java/org/superbiz/rest/WeatherService.java
@@ -35,7 +35,6 @@ public class WeatherService {
@Path("/day/temperature")
@Gauge(name = "weather_day_temperature", absolute = true, unit = "celsius",
- displayName = "Weather Day Temperature",
description = "This metric shows the day temperature.",
tags = {"weather=temperature"})
@GET
diff --git a/examples/mp-metrics-histogram/README.adoc b/examples/mp-metrics-histogram/README.adoc
index a9ed2af370..5c13f03138 100644
--- a/examples/mp-metrics-histogram/README.adoc
+++ b/examples/mp-metrics-histogram/README.adoc
@@ -55,8 +55,7 @@ data to the histogram as shown below.
private MetricRegistry registry;
@Inject
-@Metric(name = "temperatures", description = "A histogram metrics example.",
- displayName = "Histogram of Recent New York Temperatures")
+@Metric(name = "temperatures", description = "A histogram metrics example.")
private Histogram histogram;
@Path("/histogram")
diff --git a/examples/mp-metrics-histogram/README_es.adoc b/examples/mp-metrics-histogram/README_es.adoc
index 1cce930833..2b4f60d101 100644
--- a/examples/mp-metrics-histogram/README_es.adoc
+++ b/examples/mp-metrics-histogram/README_es.adoc
@@ -53,8 +53,7 @@ Para utilizar esta función, injecta un objeto `MetricRegistry`, registra el His
private MetricRegistry registry;
@Inject
-@Metric(name = "temperatures", description = "A histogram metrics example.",
- displayName = "Histogram of Recent New York Temperatures")
+@Metric(name = "temperatures", description = "A histogram metrics example.")
private Histogram histogram;
@Path("/histogram")
diff --git a/examples/mp-metrics-histogram/README_pt.adoc b/examples/mp-metrics-histogram/README_pt.adoc
index 24ed32bbc1..867b10a414 100644
--- a/examples/mp-metrics-histogram/README_pt.adoc
+++ b/examples/mp-metrics-histogram/README_pt.adoc
@@ -53,8 +53,7 @@ Para utilizar esta função, injetamos um objeto `MetricRegistry`, registramos u
private MetricRegistry registry;
@Inject
-@Metric(name = "temperatures", description = "A histogram metrics example.",
- displayName = "Histogram of Recent New York Temperatures")
+@Metric(name = "temperatures", description = "A histogram metrics example.")
private Histogram histogram;
@Path("/histogram")
diff --git a/examples/mp-metrics-histogram/pom.xml b/examples/mp-metrics-histogram/pom.xml
index b2f6829c6e..1157841782 100644
--- a/examples/mp-metrics-histogram/pom.xml
+++ b/examples/mp-metrics-histogram/pom.xml
@@ -25,7 +25,7 @@
<name>TomEE :: Examples :: Microprofile Metrics Histogram</name>
<properties>
<version.jakartaee-api>10.0-M2</version.jakartaee-api>
- <version.microprofile.metrics>4.0.1</version.microprofile.metrics>
+ <version.microprofile.metrics>5.0.2</version.microprofile.metrics>
<version.arquillian.bom>1.7.0.Final</version.arquillian.bom>
<junit.version>4.13.2</junit.version>
<tomee.version>10.0.0-M2-SNAPSHOT</tomee.version>
@@ -92,8 +92,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
- <source>1.8</source>
- <target>1.8</target>
+ <source>17</source>
+ <target>17</target>
</configuration>
</plugin>
diff --git a/examples/mp-metrics-histogram/src/main/java/org/superbiz/histogram/WeatherService.java b/examples/mp-metrics-histogram/src/main/java/org/superbiz/histogram/WeatherService.java
index 193743fd56..08b244028a 100644
--- a/examples/mp-metrics-histogram/src/main/java/org/superbiz/histogram/WeatherService.java
+++ b/examples/mp-metrics-histogram/src/main/java/org/superbiz/histogram/WeatherService.java
@@ -20,12 +20,10 @@ import org.eclipse.microprofile.metrics.Histogram;
import org.eclipse.microprofile.metrics.Metadata;
import org.eclipse.microprofile.metrics.MetadataBuilder;
import org.eclipse.microprofile.metrics.MetricRegistry;
-import org.eclipse.microprofile.metrics.MetricType;
import org.eclipse.microprofile.metrics.annotation.Metric;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
-import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
@@ -41,8 +39,7 @@ public class WeatherService {
private MetricRegistry registry;
@Inject
- @Metric(name = "temperatures", description = "A histogram metrics example.",
- displayName = "Histogram of Recent New York Temperatures")
+ @Metric(name = "temperatures", description = "A histogram metrics example.")
private Histogram histogram;
@Path("/histogram")
@@ -52,7 +49,6 @@ public class WeatherService {
final Metadata metadata = new MetadataBuilder()
.withName("temperatures")
.withDescription("A histogram of recent New York temperatures.")
- .withType(MetricType.HISTOGRAM)
.withUnit("degrees F")
.build();
histogram = registry.histogram(metadata);
diff --git a/examples/mp-metrics-histogram/src/test/java/org/superbiz/histogram/WeatherServiceTest.java b/examples/mp-metrics-histogram/src/test/java/org/superbiz/histogram/WeatherServiceTest.java
index 62457779e4..5d26196805 100644
--- a/examples/mp-metrics-histogram/src/test/java/org/superbiz/histogram/WeatherServiceTest.java
+++ b/examples/mp-metrics-histogram/src/test/java/org/superbiz/histogram/WeatherServiceTest.java
@@ -258,8 +258,7 @@ public class WeatherServiceTest {
JsonObject metadataJson = Json.createReader(new StringReader(metaData)).readObject();
final String expected =
"{\"org.superbiz.histogram.WeatherService.temperatures\":{\"unit\":\"none\",\"type\":\"histogram\"," +
- "\"description\":\"A histogram metrics example.\",\"displayName\":\"Histogram of Recent New York " +
- "Temperatures\",\"tags\":[[]]},\"temperatures\":{\"unit\":\"degrees F\",\"type\":\"histogram\"," +
+ "\"description\":\"A histogram metrics example.\",\"displayName\":\"org.superbiz.histogram.WeatherService.temperatures\",\"tags\":[[]]},\"temperatures\":{\"unit\":\"degrees F\",\"type\":\"histogram\"," +
"\"description\":\"A histogram of recent New York temperatures.\",\"displayName\":\"temperatures\"," +
"\"tags\":[[]]}}";
diff --git a/examples/mp-metrics-metered/README.adoc b/examples/mp-metrics-metered/README.adoc
index 4b4b1c79cb..3bd3b55b72 100644
--- a/examples/mp-metrics-metered/README.adoc
+++ b/examples/mp-metrics-metered/README.adoc
@@ -45,7 +45,7 @@ To use this feature you need to annotate the JAX-RS resource method with
public class WeatherService {
@Path("/day/status")
- @Metered(name = "dailyStatus",
+ @Timed(name = "dailyStatus",
unit = MetricUnits.MINUTES,
description = "Metrics to daily weather status method",
absolute = true)
diff --git a/examples/mp-metrics-metered/README_es.adoc b/examples/mp-metrics-metered/README_es.adoc
index 107af7fc71..216c94af08 100644
--- a/examples/mp-metrics-metered/README_es.adoc
+++ b/examples/mp-metrics-metered/README_es.adoc
@@ -46,7 +46,7 @@ Para utilizar esta función, debe anotar los métodos de los recursos JAX-RS con
public class WeatherService {
@Path("/day/status")
- @Metered(name = "dailyStatus",
+ @Timed(name = "dailyStatus",
unit = MetricUnits.MINUTES,
description = "Metrics to daily weather status method",
absolute = true)
diff --git a/examples/mp-metrics-metered/README_pt.adoc b/examples/mp-metrics-metered/README_pt.adoc
index 48bc662787..65edc2d1dc 100644
--- a/examples/mp-metrics-metered/README_pt.adoc
+++ b/examples/mp-metrics-metered/README_pt.adoc
@@ -43,7 +43,7 @@ Para utilizar esta função, você deve anotar os métodos dos recursos JAX-RS c
public class WeatherService {
@Path("/day/status")
- @Metered(name = "dailyStatus",
+ @Timed(name = "dailyStatus",
unit = MetricUnits.MINUTES,
description = "Metrics to daily weather status method",
absolute = true)
diff --git a/examples/mp-metrics-metered/pom.xml b/examples/mp-metrics-metered/pom.xml
index d6241ddd15..f8e57e4854 100644
--- a/examples/mp-metrics-metered/pom.xml
+++ b/examples/mp-metrics-metered/pom.xml
@@ -24,7 +24,7 @@
<packaging>war</packaging>
<properties>
<version.jakartaee-api>10.0-M2</version.jakartaee-api>
- <version.microprofile.metrics>4.0.1</version.microprofile.metrics>
+ <version.microprofile.metrics>5.0.2</version.microprofile.metrics>
<version.arquillian.bom>1.7.0.Final</version.arquillian.bom>
<junit.version>4.13.2</junit.version>
<tomee.version>10.0.0-M2-SNAPSHOT</tomee.version>
@@ -40,7 +40,6 @@
<groupId>org.eclipse.microprofile.metrics</groupId>
<artifactId>microprofile-metrics-api</artifactId>
<version>${version.microprofile.metrics}</version>
- <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomee</groupId>
@@ -76,8 +75,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.9.0</version>
<configuration>
- <source>1.8</source>
- <target>1.8</target>
+ <source>17</source>
+ <target>17</target>
</configuration>
</plugin>
<plugin>
diff --git a/examples/mp-metrics-metered/src/main/java/org/superbiz/rest/WeatherService.java b/examples/mp-metrics-metered/src/main/java/org/superbiz/rest/WeatherService.java
index 1a5a45a18c..5a56a3fdb5 100644
--- a/examples/mp-metrics-metered/src/main/java/org/superbiz/rest/WeatherService.java
+++ b/examples/mp-metrics-metered/src/main/java/org/superbiz/rest/WeatherService.java
@@ -19,7 +19,7 @@
package org.superbiz.rest;
import org.eclipse.microprofile.metrics.MetricUnits;
-import org.eclipse.microprofile.metrics.annotation.Metered;
+import org.eclipse.microprofile.metrics.annotation.Timed;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
@@ -27,6 +27,7 @@ import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
+
@Path("/weather")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@@ -34,7 +35,7 @@ import jakarta.ws.rs.core.MediaType;
public class WeatherService {
@Path("/day/status")
- @Metered(name = "dailyStatus", unit = MetricUnits.MINUTES, description = "Metrics to daily weather status method", absolute = true)
+ @Timed(name = "dailyStatus", unit = MetricUnits.MINUTES, description = "Metrics to daily weather status method", absolute = true)
@GET
@Produces(MediaType.TEXT_PLAIN)
public String dayStatus() {
@@ -42,7 +43,7 @@ public class WeatherService {
}
@Path("/week/status")
- @Metered(name = "weeklyStatus", unit = MetricUnits.MINUTES, description = "Metrics to weekly weather status method", absolute = true)
+ @Timed(name = "weeklyStatus", unit = MetricUnits.MINUTES, description = "Metrics to weekly weather status method", absolute = true)
@GET
@Produces(MediaType.TEXT_PLAIN)
public String weekStatus() {
diff --git a/examples/mp-metrics-timed/pom.xml b/examples/mp-metrics-timed/pom.xml
index fcc049e1a4..aa2b3635b5 100644
--- a/examples/mp-metrics-timed/pom.xml
+++ b/examples/mp-metrics-timed/pom.xml
@@ -24,7 +24,7 @@
<name>TomEE :: Examples :: Microprofile Metrics Timed</name>
<properties>
<version.jakartaee-api>10.0-M2</version.jakartaee-api>
- <version.microprofile.metrics>4.0.1</version.microprofile.metrics>
+ <version.microprofile.metrics>5.0.2</version.microprofile.metrics>
<version.arquillian.bom>1.7.0.Final</version.arquillian.bom>
<junit.version>4.13.2</junit.version>
<tomee.version>10.0.0-M2-SNAPSHOT</tomee.version>
@@ -91,8 +91,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
- <source>1.8</source>
- <target>1.8</target>
+ <source>17</source>
+ <target>17</target>
</configuration>
</plugin>
diff --git a/examples/mp-metrics-timed/src/main/java/WeatherService.java b/examples/mp-metrics-timed/src/main/java/WeatherService.java
index 4da0e51bf1..814ad7ee58 100644
--- a/examples/mp-metrics-timed/src/main/java/WeatherService.java
+++ b/examples/mp-metrics-timed/src/main/java/WeatherService.java
@@ -32,8 +32,8 @@ 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.")
+ description = "This metric shows the weather status of the day.",
+ scope = "weather")
@GET
@Produces(MediaType.TEXT_PLAIN)
public String dayStatus() {
diff --git a/examples/mp-metrics-timed/src/test/java/WeatherServiceTest.java b/examples/mp-metrics-timed/src/test/java/WeatherServiceTest.java
index 46f26be50d..bd30901e06 100644
--- a/examples/mp-metrics-timed/src/test/java/WeatherServiceTest.java
+++ b/examples/mp-metrics-timed/src/test/java/WeatherServiceTest.java
@@ -23,6 +23,7 @@ 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.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -74,9 +75,10 @@ public class WeatherServiceTest {
.path("/weather/day/status")
.request().buildGet().invoke();
- final String metricPath = "/metrics/application/weather_day_status";
+ final String metricPath = "/metrics";
assertPrometheusFormat(metricPath);
- assertJsonFormat(metricPath);
+
+ // assertJsonFormat(metricPath);
}
private void assertPrometheusFormat(final String metricPath) {
@@ -91,121 +93,23 @@ public class WeatherServiceTest {
.readEntity(String.class);
String[] expected = {
- "# TYPE application_weather_day_status_rate_per_second gauge",
- "application_weather_day_status_rate_per_second",
- "# TYPE application_weather_day_status_one_min_rate_per_second gauge",
- "application_weather_day_status_one_min_rate_per_second",
- "# TYPE application_weather_day_status_five_min_rate_per_second gauge",
- "application_weather_day_status_five_min_rate_per_second",
- "# TYPE application_weather_day_status_fifteen_min_rate_per_second gauge",
- "application_weather_day_status_fifteen_min_rate_per_second",
- "# TYPE application_weather_day_status_min_seconds gauge",
- "application_weather_day_status_min_seconds",
- "# TYPE application_weather_day_status_max_seconds gauge",
- "application_weather_day_status_max_seconds",
- "# TYPE application_weather_day_status_mean_seconds gauge",
- "application_weather_day_status_mean_seconds",
- "# TYPE application_weather_day_status_stddev_seconds gauge",
- "application_weather_day_status_stddev_seconds",
- "# HELP application_weather_day_status_seconds This metric shows the weather status of the day.",
- "# TYPE application_weather_day_status_seconds summary",
- "application_weather_day_status_seconds_count",
- "application_weather_day_status_seconds_sum",
- "application_weather_day_status_seconds{quantile=\"0.5\"}",
- "application_weather_day_status_seconds{quantile=\"0.75\"}",
- "application_weather_day_status_seconds{quantile=\"0.95\"}",
- "application_weather_day_status_seconds{quantile=\"0.98\"}",
- "application_weather_day_status_seconds{quantile=\"0.99\"}",
- "application_weather_day_status_seconds{quantile=\"0.999\"}"
+ "# TYPE weather_day_status_seconds summary",
+ "# HELP weather_day_status_seconds This metric shows the weather status of the day.",
+ "weather_day_status_seconds{mp_scope=\"weather\",quantile=\"0.5\",}",
+ "weather_day_status_seconds{mp_scope=\"weather\",quantile=\"0.75\",}",
+ "weather_day_status_seconds{mp_scope=\"weather\",quantile=\"0.95\",}",
+ "weather_day_status_seconds{mp_scope=\"weather\",quantile=\"0.98\",}",
+ "weather_day_status_seconds{mp_scope=\"weather\",quantile=\"0.99\",}",
+ "weather_day_status_seconds{mp_scope=\"weather\",quantile=\"0.999\",}",
+ "weather_day_status_seconds_count{mp_scope=\"weather\",}",
+ "weather_day_status_seconds_sum{mp_scope=\"weather\",}",
+ "# TYPE weather_day_status_seconds_max gauge",
+ "# HELP weather_day_status_seconds_max This metric shows the weather status of the day.",
+ "weather_day_status_seconds_max{mp_scope=\"weather\",}"
};
Stream.of(expected)
.forEach(text -> assertTrue("Expected: " + text + " to be present in " + metric, metric.contains(text)));
}
- private void assertJsonFormat(final String metricPath) {
- WebTarget webTarget = client.target(base.toExternalForm());
-
- String metric = webTarget
- .path(metricPath)
- .request()
- .accept(MediaType.APPLICATION_JSON)
- .buildGet()
- .invoke()
- .readEntity(String.class);
-
- JsonObject expectedJson = Json.createReader(new StringReader(metric)).readObject();
-
- 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,
- expectedJson.getJsonObject("weather_day_status").get(text) != null));
- }
-
- @Test
- public void testTimedMetricMetadata() {
-
- WebTarget webTarget = client.target(base.toExternalForm());
-
- Response response = webTarget.path("/metrics/application/weather_day_status")
- .request()
- .accept(MediaType.APPLICATION_JSON)
- .build("OPTIONS")
- .invoke();
-
- 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.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));
- }
}
diff --git a/examples/rest-sse-example/src/main/java/org/superbiz/rest/service/JmsResource.java b/examples/rest-sse-example/src/main/java/org/superbiz/rest/service/JmsResource.java
index c34cc99820..1bc7a9c72d 100644
--- a/examples/rest-sse-example/src/main/java/org/superbiz/rest/service/JmsResource.java
+++ b/examples/rest-sse-example/src/main/java/org/superbiz/rest/service/JmsResource.java
@@ -16,10 +16,20 @@
*/
package org.superbiz.rest.service;
+import jakarta.annotation.Resource;
import jakarta.enterprise.event.Observes;
+import jakarta.enterprise.event.Reception;
import jakarta.inject.Singleton;
+import jakarta.jms.Connection;
+import jakarta.jms.ConnectionFactory;
import jakarta.jms.Message;
+import jakarta.jms.MessageProducer;
+import jakarta.jms.Session;
+import jakarta.jms.TextMessage;
+import jakarta.jms.Topic;
+import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
+import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.Context;
@@ -33,6 +43,12 @@ import jakarta.ws.rs.sse.SseEventSink;
@Singleton
public class JmsResource {
+ @Resource(name="EVENT")
+ private Topic topic;
+
+ @Resource
+ private ConnectionFactory cf;
+
private SseBroadcaster broadcaster;
private OutboundSseEvent.Builder builder;
@@ -42,13 +58,30 @@ public class JmsResource {
broadcaster.register(sink);
}
+ @POST
+ @Consumes(MediaType.TEXT_PLAIN)
+ public void sendMessage(final String message) {
+ try {
+ final Connection connection = cf.createConnection();
+ final Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
+ final TextMessage textMessage = session.createTextMessage(message);
+ final MessageProducer producer = session.createProducer(topic);
+ producer.send(textMessage);
+ producer.close();
+ session.close();
+ connection.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
@Context
public void setSse(final Sse sse) {
this.broadcaster = sse.newBroadcaster();
this.builder = sse.newEventBuilder();
}
- public void onMessage(final @Observes Message message) {
+ public void onMessage(final @Observes(notifyObserver = Reception.IF_EXISTS) Message message) {
if (broadcaster == null) {
return;
}
diff --git a/pom.xml b/pom.xml
index 4352a5a9b7..898d842250 100644
--- a/pom.xml
+++ b/pom.xml
@@ -175,15 +175,16 @@
<!-- Java SE version -->
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
- <maven.compiler.release>17</maven.compiler.release>
+ <maven.compiler.release>17</maven.compiler.release>
+ <version.micrometer>1.12.5</version.micrometer>
<!-- Micro Profile API -->
<version.microprofile>5.0</version.microprofile>
<version.microprofile.config>3.0.3</version.microprofile.config>
<version.microprofile.fault-tolerance>4.0.2</version.microprofile.fault-tolerance>
<version.microprofile.health>4.0.1</version.microprofile.health>
<version.microprofile.jwt>2.1</version.microprofile.jwt>
- <version.microprofile.metrics>4.0.1</version.microprofile.metrics>
+ <version.microprofile.metrics>5.0.2</version.microprofile.metrics>
<version.microprofile.openapi>3.0</version.microprofile.openapi>
<version.microprofile.opentracing>3.0</version.microprofile.opentracing>
<version.microprofile.rest-client>3.0.1</version.microprofile.rest-client>
@@ -194,7 +195,7 @@
<version.microprofile.impl.config>3.0.0</version.microprofile.impl.config>
<version.microprofile.impl.fault-tolerance>6.2.2</version.microprofile.impl.fault-tolerance>
<version.microprofile.impl.health>4.0.1</version.microprofile.impl.health>
- <version.microprofile.impl.metrics>4.0.0</version.microprofile.impl.metrics>
+ <version.microprofile.impl.metrics>5.0.1</version.microprofile.impl.metrics>
<version.microprofile.impl.openapi>3.0.1</version.microprofile.impl.openapi>
<version.microprofile.impl.opentracing>3.0.3</version.microprofile.impl.opentracing>
diff --git a/tck/microprofile-tck/fault-tolerance/pom.xml b/tck/microprofile-tck/fault-tolerance/pom.xml
index be5b261ea2..067ac57be7 100644
--- a/tck/microprofile-tck/fault-tolerance/pom.xml
+++ b/tck/microprofile-tck/fault-tolerance/pom.xml
@@ -105,6 +105,19 @@
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.tomee</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.smallrye</groupId>
+ <artifactId>smallrye-metrics</artifactId>
+ <version>${version.microprofile.impl.metrics}</version>
+ <scope>provided</scope>
+ </dependency>
+
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>apache-tomee</artifactId>
diff --git a/tck/microprofile-tck/metrics/pom.xml b/tck/microprofile-tck/metrics/pom.xml
index 769077a52e..c648380906 100644
--- a/tck/microprofile-tck/metrics/pom.xml
+++ b/tck/microprofile-tck/metrics/pom.xml
@@ -35,12 +35,22 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M6</version>
<configuration>
- <reuseForks>true</reuseForks>
- <forkCount>1C</forkCount>
+ <reuseForks>false</reuseForks>
<dependenciesToScan>
<dependency>org.eclipse.microprofile.metrics:microprofile-metrics-api-tck</dependency>
<dependency>org.eclipse.microprofile.metrics:microprofile-metrics-rest-tck</dependency>
+ <dependency>org.eclipse.microprofile.metrics:microprofile-metrics-optional-tck</dependency>
</dependenciesToScan>
+ <excludes>
+ <!-- Exclude some of the OPTIONAL tests because they aren't supported in TomEE and result in failures atm -->
+ <!-- MPMetricBaseMetricsTest.testGcTimeMetrics -->
+ <exclude>**/MPMetricBaseMetricsTest.java</exclude>
+ <!--
+ org.eclipse.microprofile.metrics.test.optional.MpMetricOptionalTest.testGetUnmappedArithException
+ org.eclipse.microprofile.metrics.test.optional.MpMetricOptionalTest.testPostUnmappedArithException
+ -->
+ <exclude>**/MpMetricOptionalTest.java</exclude>
+ </excludes>
<environmentVariables>
<MP_METRICS_TAGS>tier=integration</MP_METRICS_TAGS>
</environmentVariables>
@@ -67,8 +77,7 @@
<goal>test</goal>
</goals>
<configuration>
- <reuseForks>true</reuseForks>
- <forkCount>1C</forkCount>
+ <reuseForks>false</reuseForks>
<systemPropertyVariables>
<arquillian.launch>tomee-plus</arquillian.launch>
<java.io.tmpdir>./target</java.io.tmpdir>
@@ -81,8 +90,7 @@
<goal>test</goal>
</goals>
<configuration>
- <reuseForks>true</reuseForks>
- <forkCount>1C</forkCount>
+ <reuseForks>false</reuseForks>
<systemPropertyVariables>
<arquillian.launch>tomee-plume</arquillian.launch>
<java.io.tmpdir>./target</java.io.tmpdir>
@@ -121,6 +129,13 @@
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.eclipse.microprofile.metrics</groupId>
+ <artifactId>microprofile-metrics-optional-tck</artifactId>
+ <version>${version.microprofile.metrics}</version>
+ <scope>test</scope>
+ </dependency>
+
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
diff --git a/tck/microprofile-tck/metrics/src/test/java/org/apache/tomee/microprofile/tck/metrics/MicroProfileMetricsTCKObserver.java b/tck/microprofile-tck/metrics/src/test/java/org/apache/tomee/microprofile/tck/metrics/MicroProfileMetricsTCKObserver.java
index 7fdab048db..28959205af 100644
--- a/tck/microprofile-tck/metrics/src/test/java/org/apache/tomee/microprofile/tck/metrics/MicroProfileMetricsTCKObserver.java
+++ b/tck/microprofile-tck/metrics/src/test/java/org/apache/tomee/microprofile/tck/metrics/MicroProfileMetricsTCKObserver.java
@@ -17,10 +17,17 @@
package org.apache.tomee.microprofile.tck.metrics;
import io.restassured.RestAssured;
+import io.restassured.filter.Filter;
+import io.restassured.filter.FilterContext;
+import io.restassured.response.Response;
+import io.restassured.specification.FilterableRequestSpecification;
+import io.restassured.specification.FilterableResponseSpecification;
import org.apache.openejb.arquillian.common.TomEEContainer;
import org.jboss.arquillian.container.spi.event.container.AfterDeploy;
import org.jboss.arquillian.core.api.annotation.Observes;
+import java.util.Arrays;
+
/**
* Metrics TCK expect the deployed test archives to be in the root context. In here, we just set the RestAssured path
* so the test archives are not required to be deployed in the / context root.
@@ -30,9 +37,31 @@ public class MicroProfileMetricsTCKObserver {
public void AfterDeploy(@Observes final AfterDeploy afterDeploy) {
+ RestAssured.filters(Arrays.asList(new SingleRequestFilter()));
final int httpPort = ((TomEEContainer<?>) afterDeploy.getDeployableContainer()).getConfiguration().getHttpPort();
final String targetUrl = "http://localhost:" + httpPort;
System.setProperty("test.url", targetUrl);
RestAssured.basePath = "microprofile-metrics";
+ System.setProperty("context.root", "");
+ }
+
+ /*
+ * This forces a very short wait before calls to the /metrics endpoint. The Tomcat response is sent to the client
+ * ever-so-slightly before the metrics valve finishes completing. This ensures that the metrics are updated before
+ * the prometheus scrape takes place.
+ */
+ private static class SingleRequestFilter implements Filter {
+ @Override
+ public Response filter(final FilterableRequestSpecification filterableRequestSpecification, final FilterableResponseSpecification filterableResponseSpecification, final FilterContext filterContext) {
+ try {
+ if (filterableRequestSpecification.getURI().contains("/microprofile-metrics/metrics")) {
+ Thread.sleep(100);
+ }
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+
+ return filterContext.next(filterableRequestSpecification, filterableResponseSpecification);
+ }
}
}
diff --git a/tomee/tomee-microprofile/mp-common/pom.xml b/tomee/tomee-microprofile/mp-common/pom.xml
index 96d6419d4a..ae7c95379c 100644
--- a/tomee/tomee-microprofile/mp-common/pom.xml
+++ b/tomee/tomee-microprofile/mp-common/pom.xml
@@ -253,6 +253,18 @@
</exclusions>
</dependency>
+ <dependency>
+ <groupId>io.micrometer</groupId>
+ <artifactId>micrometer-core</artifactId>
+ <version>${version.micrometer}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>io.micrometer</groupId>
+ <artifactId>micrometer-registry-prometheus</artifactId>
+ <version>${version.micrometer}</version>
+ </dependency>
+
<dependency>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-open-api</artifactId>
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 73db580fc7..9f7f3b04b5 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
@@ -60,7 +60,7 @@ public class TomEEMicroProfileListener {
"org.apache.tomee.microprofile.jwt.cdi.MPJWTCDIExtension",
"org.apache.cxf.microprofile.client.cdi.RestClientExtension",
"io.smallrye.config.inject.ConfigExtension",
- "io.smallrye.metrics.setup.MetricCdiInjectionExtension",
+ "io.smallrye.metrics.legacyapi.LegacyMetricsExtension",
"io.smallrye.opentracing.SmallRyeTracingDynamicFeature",
"io.smallrye.opentracing.contrib.interceptor.OpenTracingInterceptor",
"io.smallrye.faulttolerance.FaultToleranceExtension",
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
deleted file mode 100644
index f406c9614e..0000000000
--- a/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/metrics/MPMetricsCDIExtension.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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;
-
-import java.io.IOException;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-public class MPMetricsCDIExtension implements Extension {
-
- private static final AtomicBoolean INIT = new AtomicBoolean(false);
-
- private void afterDeploymentValidation(@Observes final AfterDeploymentValidation avd, BeanManager bm) {
-
- if (INIT.compareAndSet(false, true)) {
- try {
- final JmxRegistrar registrar = new JmxRegistrar();
- registrar.init();
-
- } catch (final IOException 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/MetricsFilterRegistration.java b/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/metrics/MetricsFilterRegistration.java
new file mode 100644
index 0000000000..4a5361dc31
--- /dev/null
+++ b/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/metrics/MetricsFilterRegistration.java
@@ -0,0 +1,31 @@
+/*
+ * 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.JaxRsMetricsFilter;
+import jakarta.ws.rs.container.DynamicFeature;
+import jakarta.ws.rs.container.ResourceInfo;
+import jakarta.ws.rs.core.FeatureContext;
+import jakarta.ws.rs.ext.Provider;
+
+@Provider
+public class MetricsFilterRegistration implements DynamicFeature {
+ @Override
+ public void configure(ResourceInfo resourceInfo, FeatureContext context) {
+ context.register(JaxRsMetricsFilter.class);
+ }
+}
\ 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
index d8f474494c..53a4a64884 100644
--- 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
@@ -49,7 +49,7 @@ public class MicroProfileMetricsEndpoint extends HttpServlet {
final String method = request.getMethod();
final Stream<String> acceptHeaders = Collections.list(request.getHeaders("Accept")).stream();
- metricsHandler.handleRequest(requestPath, method, acceptHeaders, (status, message, headers) -> {
+ metricsHandler.handleRequest(requestPath, method, acceptHeaders, request.getParameterMap(), (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/VendorMetrics.java b/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/metrics/VendorMetrics.java
new file mode 100644
index 0000000000..fa7f1fd16a
--- /dev/null
+++ b/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/metrics/VendorMetrics.java
@@ -0,0 +1,258 @@
+/*
+ * 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.SharedMetricRegistries;
+import io.smallrye.metrics.legacyapi.LegacyMetricRegistryAdapter;
+import org.apache.openejb.assembler.classic.event.AssemblerAfterApplicationCreated;
+import org.apache.openejb.observer.Observes;
+import org.apache.openejb.util.Join;
+import org.eclipse.microprofile.metrics.Metadata;
+import org.eclipse.microprofile.metrics.MetricRegistry;
+
+import javax.management.AttributeList;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanInfo;
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectInstance;
+import javax.management.ObjectName;
+import java.lang.management.ManagementFactory;
+import java.util.*;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+
+/**
+ * This class exposes various vendor-specific metrics
+ * Our vendor specific stuff typically lives in openejb.management in JMX
+ * We have a slight issue that it doesn't look like we
+ * can tie it back to application (at the moment at least),
+ * so we probably just need to scrape everything each time.
+ */
+public class VendorMetrics {
+
+ private static final Logger LOGGER = Logger.getLogger(VendorMetrics.class.getName());
+
+ public void afterApplicationDeployed(@Observes AssemblerAfterApplicationCreated event) {
+ final MetricRegistry registry = SharedMetricRegistries.getOrCreate(MetricRegistry.VENDOR_SCOPE);
+
+ if (! (registry instanceof LegacyMetricRegistryAdapter)) {
+ return;
+ }
+
+ final MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
+ final Set<ObjectInstance> objectInstances;
+
+ try {
+ objectInstances = platformMBeanServer.queryMBeans(new ObjectName("openejb.management:*"), null);
+ } catch (MalformedObjectNameException e) {
+ LOGGER.severe("Unable to read MBeans under openejb.management");
+ return;
+ }
+
+ for (final ObjectInstance objectInstance : objectInstances) {
+ final ObjectName objectName = objectInstance.getObjectName();
+ LOGGER.info("Adding vendor metrics for " + objectName);
+ LOGGER.info("Class name: " + objectInstance.getClassName());
+
+ final List<String> nameParts = new ArrayList<>();
+
+ if (objectName.getKeyProperty("ObjectType") != null) {
+ nameParts.add(objectName.getKeyProperty("ObjectType"));
+ if (objectName.getKeyProperty("DataSource") != null) {
+ nameParts.add(objectName.getKeyProperty("DataSource"));
+ }
+ } else if (objectName.getKeyProperty("j2eeType") != null) {
+ nameParts.add(objectName.getKeyProperty("j2eeType"));
+ if (objectName.getKeyProperty("name") != null) {
+ nameParts.add(objectName.getKeyProperty("name"));
+ }
+ }
+
+ final String metricName = Join.join("_", nameParts);
+
+ try {
+ final MBeanInfo mBeanInfo = platformMBeanServer.getMBeanInfo(objectName);
+ final JMXInfo jmxInfo = JMXInfo.from(objectName, mBeanInfo);
+
+ jmxInfo.configureMetrics(registry, metricName);
+
+ } catch (Exception e) {
+ LOGGER.log(Level.SEVERE, "Unable to configure metrics for " + objectName, e);
+ }
+ }
+ }
+
+
+ private static class JMXInfo {
+ private final ObjectName objectName;
+ private long lastUpdated = 0;
+ private Map<String, JMXAttribute> attributeMap = new HashMap<>();
+
+ private JMXInfo(ObjectName objectName) {
+ this.objectName = objectName;
+ }
+
+ public static JMXInfo from(final ObjectName objectName, final MBeanInfo info) {
+
+ final List<JMXAttribute> attributes = Arrays.stream(info.getAttributes())
+ .filter(a -> JMXAttribute.getType(a.getType()) != null)
+ .map(a -> JMXAttribute.from(a))
+ .collect(Collectors.toList());
+
+
+ final JMXInfo jmxInfo = new JMXInfo(objectName);
+ attributes.forEach(a -> {
+ jmxInfo.attributeMap.put(a.getAttributeName(), a);
+ });
+
+ return jmxInfo;
+ }
+
+ public synchronized void update() {
+ final long timeNow = System.currentTimeMillis();
+
+ // try not to hammer JMX, maybe make this configurable?
+ if ((timeNow - lastUpdated) < 5000) {
+ return;
+ }
+
+ final MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
+ final String[] attributeNames = attributeMap.keySet().toArray(new String[0]);
+ final AttributeList attributes;
+
+ try {
+ attributes = platformMBeanServer.getAttributes(objectName, attributeNames);
+ } catch (Exception e) {
+ LOGGER.log(Level.SEVERE, "Unable to read metrics from JMX", e);
+ return;
+ }
+
+ attributes.asList().forEach(a -> {
+ final String name = a.getName();
+ final Object value = a.getValue();
+
+ if (! Number.class.isInstance(value)) {
+ // Log?
+ return;
+ }
+
+ final JMXAttribute jmxAttribute = attributeMap.get(name);
+ if (jmxAttribute == null) {
+ return;
+ }
+
+ jmxAttribute.setCurrentValue(Number.class.cast(value));
+ });
+
+ lastUpdated = timeNow;
+ }
+
+ public Double get(final String attributeName) {
+ update();
+
+ final JMXAttribute jmxAttribute = attributeMap.get(attributeName);
+ if (jmxAttribute == null) {
+ throw new IllegalArgumentException("Attribute name: " + attributeName + " not known");
+ }
+
+ return jmxAttribute.toDouble();
+ }
+
+ public void configureMetrics(final MetricRegistry registry, final String metricName) {
+ attributeMap.values().forEach(a -> {
+ ((LegacyMetricRegistryAdapter) registry).counter(
+ Metadata
+ .builder()
+ .withName(metricName + "_" + a.getAttributeName())
+ .build(),
+ a.getType(),
+ value -> get(a.attributeName)
+ );
+ });
+ }
+ }
+
+ private static class JMXAttribute<T extends Number> {
+ private final String attributeName;
+ private final Class<T> type;
+ private T currentValue;
+
+ public JMXAttribute(String attributeName, Class<T> type) {
+ this.attributeName = attributeName;
+ this.type = type;
+ }
+
+ public static JMXAttribute from(final MBeanAttributeInfo attributeInfo) {
+ final String name = attributeInfo.getName();
+ final Class<? extends Number> t = JMXAttribute.getType(attributeInfo.getType());
+
+ if (name == null || t == null) {
+ throw new IllegalArgumentException("Class and type must be specified");
+ }
+
+ return new JMXAttribute(name, t);
+ }
+
+ public String getAttributeName() {
+ return attributeName;
+ }
+
+ public Class<T> getType() {
+ return type;
+ }
+
+ public T getCurrentValue() {
+ return currentValue;
+ }
+
+ public void setCurrentValue(T currentValue) {
+ this.currentValue = currentValue;
+ }
+
+ public Double toDouble() {
+ if (currentValue == null) {
+ return Double.NaN;
+ }
+
+ return currentValue.doubleValue();
+ }
+
+ @Override
+ public String toString() {
+ return attributeName + "(" + type.getName() + "): " + currentValue;
+ }
+
+ public static Class<? extends Number> getType(final String type) {
+ if ("int".equals(type)) {
+ return Integer.class;
+ }
+ if ("long".equals(type)) {
+ return Long.class;
+ }
+ if ("float".equals(type)) {
+ return Float.class;
+ }
+ if ("double".equals(type)) {
+ return Double.class;
+ }
+
+ return null;
+ }
+ }
+}
diff --git a/tomee/tomee-microprofile/mp-common/src/main/resources/META-INF/org.apache.openejb.extension b/tomee/tomee-microprofile/mp-common/src/main/resources/META-INF/org.apache.openejb.extension
new file mode 100644
index 0000000000..e4b4089001
--- /dev/null
+++ b/tomee/tomee-microprofile/mp-common/src/main/resources/META-INF/org.apache.openejb.extension
@@ -0,0 +1 @@
+org.apache.tomee.microprofile.metrics.VendorMetrics
\ 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
deleted file mode 100644
index b7efaf9a18..0000000000
--- a/tomee/tomee-microprofile/mp-common/src/main/resources/META-INF/services/jakarta.ws.rs.ext.Providers
+++ /dev/null
@@ -1 +0,0 @@
-io.smallrye.metrics.jaxrs.JaxRsMetricsFilter
\ No newline at end of file