diff --git a/api/pom.xml b/api/pom.xml
index b3aa54fd..97cad209 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -19,9 +19,9 @@
org.eclipse.microprofile.telemetry
microprofile-telemetry-parent
- 2.1-SNAPSHOT
+ 2.0.2-SNAPSHOT
-
+
microprofile-telemetry-api
pom
MicroProfile Telemetry API
diff --git a/pom.xml b/pom.xml
index d9465ea4..1a9a7193 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@
org.eclipse.microprofile.telemetry
microprofile-telemetry-parent
- 2.1-SNAPSHOT
+ 2.0.2-SNAPSHOT
pom
MicroProfile Telemetry
https://microprofile.io/project/eclipse/microprofile-telemetry
diff --git a/spec/pom.xml b/spec/pom.xml
index 5c9328ae..9454fb6b 100644
--- a/spec/pom.xml
+++ b/spec/pom.xml
@@ -19,11 +19,11 @@
org.eclipse.microprofile.telemetry
microprofile-telemetry-parent
- 2.1-SNAPSHOT
+ 2.0.2-SNAPSHOT
microprofile-telemetry-spec
pom
MicroProfile Telemetry Specification
-
\ No newline at end of file
+
diff --git a/tck/logs/pom.xml b/tck/logs/pom.xml
index 2b044639..481a57a3 100644
--- a/tck/logs/pom.xml
+++ b/tck/logs/pom.xml
@@ -19,7 +19,7 @@
org.eclipse.microprofile.telemetry
microprofile-telemetry-tck-parent
- 2.1-SNAPSHOT
+ 2.0.2-SNAPSHOT
microprofile-telemetry-logs-tck
@@ -33,7 +33,7 @@
org.eclipse.microprofile.rest.client
microprofile-rest-client-api
-
+
jakarta.enterprise
jakarta.enterprise.cdi-api
@@ -71,6 +71,6 @@
awaitility
${version.awaitility}
-
+
diff --git a/tck/logs/src/main/java/org/eclipse/microprofile/telemetry/logs/tck/application/JulTest.java b/tck/logs/src/main/java/org/eclipse/microprofile/telemetry/logs/tck/application/JulTest.java
index 7c28399b..db05e0bc 100644
--- a/tck/logs/src/main/java/org/eclipse/microprofile/telemetry/logs/tck/application/JulTest.java
+++ b/tck/logs/src/main/java/org/eclipse/microprofile/telemetry/logs/tck/application/JulTest.java
@@ -44,7 +44,8 @@ public class JulTest extends Arquillian {
public static WebArchive createDeployment() {
return ShrinkWrap.create(WebArchive.class)
.addAsResource(new StringAsset(
- "otel.sdk.disabled=false\notel.metrics.exporter=none\notel.traces.exporter=none\notel.logs.exporter=logging\notel.service.name=openliberty"),
+ "otel.sdk.disabled=false\notel.metrics.exporter=none\notel.traces.exporter=none\n" +
+ "otel.logs.exporter=logging\notel.service.name=openliberty"),
"META-INF/microprofile-config.properties")
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
}
@@ -52,16 +53,16 @@ public static WebArchive createDeployment() {
@Inject
private OpenTelemetry openTelemetry;
- private static final Logger julLogger = Logger.getLogger("jul-logger");
+ private static final Logger JUL_LOGGER = Logger.getLogger("jul-logger");
- private static final String logFilePath = System.getProperty("mptelemetry.tck.log.file.path");
+ private static final String LOG_FILE_PATH = System.getProperty("mptelemetry.tck.log.file.path");
private static final String JUL_INFO_MESSAGE = "a very distinguishable info message";
private static final String JUL_WARN_MESSAGE = "a very distinguishable warning message";
@Test
void julInfoTest() throws IOException {
- julLogger.log(Level.INFO, JUL_INFO_MESSAGE);
+ JUL_LOGGER.log(Level.INFO, JUL_INFO_MESSAGE);
try {
Assert.assertTrue(checkMessage(".*INFO.*" + JUL_INFO_MESSAGE + ".*scopeInfo:.*"));
} catch (IOException e) {
@@ -70,7 +71,7 @@ void julInfoTest() throws IOException {
@Test
void julWarnTest() throws IOException {
- julLogger.log(Level.WARNING, JUL_WARN_MESSAGE);
+ JUL_LOGGER.log(Level.WARNING, JUL_WARN_MESSAGE);
try {
Assert.assertTrue(checkMessage(".*WARN.*" + JUL_WARN_MESSAGE + ".*scopeInfo:.*"));
} catch (IOException e) {
@@ -81,7 +82,7 @@ public boolean checkMessage(String logMessage) throws IOException {
try {
try {
Thread.sleep(5000);
- BufferedReader reader = new BufferedReader(new FileReader(logFilePath));
+ BufferedReader reader = new BufferedReader(new FileReader(LOG_FILE_PATH));
String line;
while ((line = reader.readLine()) != null) {
if (line.matches(logMessage)) {
diff --git a/tck/logs/src/main/java/org/eclipse/microprofile/telemetry/logs/tck/config/ServerInstanceTest.java b/tck/logs/src/main/java/org/eclipse/microprofile/telemetry/logs/tck/config/ServerInstanceTest.java
index c47ce80e..264c30d3 100644
--- a/tck/logs/src/main/java/org/eclipse/microprofile/telemetry/logs/tck/config/ServerInstanceTest.java
+++ b/tck/logs/src/main/java/org/eclipse/microprofile/telemetry/logs/tck/config/ServerInstanceTest.java
@@ -34,14 +34,14 @@
public class ServerInstanceTest extends Arquillian {
- private static final String serviceNameUnused = "NOT_USED";
+ private static final String SERVICE_NAME_UNUSED = "NOT_USED";
// otel.sdk.disabled=false must be set at runtime level to make this test valid
@Deployment
public static WebArchive createDeployment() {
return ShrinkWrap.create(WebArchive.class)
.addAsResource(new StringAsset(
- "otel.service.name=" + serviceNameUnused),
+ "otel.service.name=" + SERVICE_NAME_UNUSED),
"META-INF/microprofile-config.properties")
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
}
diff --git a/tck/metrics/pom.xml b/tck/metrics/pom.xml
index 7e5a71db..9951a52b 100644
--- a/tck/metrics/pom.xml
+++ b/tck/metrics/pom.xml
@@ -19,7 +19,7 @@
org.eclipse.microprofile.telemetry
microprofile-telemetry-tck-parent
- 2.1-SNAPSHOT
+ 2.0.2-SNAPSHOT
microprofile-telemetry-metrics-tck
@@ -33,7 +33,7 @@
org.eclipse.microprofile.rest.client
microprofile-rest-client-api
-
+
jakarta.enterprise
jakarta.enterprise.cdi-api
@@ -45,7 +45,7 @@
io.opentelemetry
opentelemetry-sdk
-
+
io.opentelemetry
opentelemetry-sdk-common
diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/AsyncDoubleCounterTest.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/AsyncDoubleCounterTest.java
index 7eee25ff..09186b2c 100644
--- a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/AsyncDoubleCounterTest.java
+++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/AsyncDoubleCounterTest.java
@@ -21,76 +21,31 @@
**********************************************************************/
package org.eclipse.microprofile.telemetry.metrics.tck.application.cdi;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.TestLibraries;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.exporter.InMemoryMetricExporter;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.exporter.InMemoryMetricExporterProvider;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.testng.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.asset.EmptyAsset;
-import org.jboss.shrinkwrap.api.asset.StringAsset;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.eclipse.microprofile.telemetry.metrics.tck.shared.BaseMetricsTest;
import org.testng.Assert;
-import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import io.opentelemetry.api.common.Attributes;
-import io.opentelemetry.api.metrics.Meter;
-import io.opentelemetry.sdk.autoconfigure.spi.metrics.ConfigurableMetricExporterProvider;
import io.opentelemetry.sdk.metrics.data.MetricData;
import io.opentelemetry.sdk.metrics.data.MetricDataType;
-import jakarta.inject.Inject;
-public class AsyncDoubleCounterTest extends Arquillian {
- private static final String counterName = "testDoubleAsyncCounter";
- private static final String counterDescription = "Testing double counter";
- private static final String counterUnit = "Metric Tonnes";
-
- private static final double DOUBLE_WITH_ATTRIBUTES = 20.2;
- private static final double DOUBLE_WITHOUT_ATTRIBUTES = 10.1;
-
- @Deployment
- public static WebArchive createTestArchive() {
-
- return ShrinkWrap.create(WebArchive.class)
- .addClasses(InMemoryMetricExporter.class, InMemoryMetricExporterProvider.class)
- .addAsLibrary(TestLibraries.AWAITILITY_LIB)
- .addAsServiceProvider(ConfigurableMetricExporterProvider.class, InMemoryMetricExporterProvider.class)
- .addAsResource(new StringAsset(
- "otel.sdk.disabled=false\notel.metrics.exporter=in-memory\notel.logs.exporter=none\notel.traces.exporter=none\notel.metric.export.interval=3000"),
- "META-INF/microprofile-config.properties")
- .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
- }
-
- @Inject
- private Meter sdkMeter;
-
- @Inject
- private InMemoryMetricExporter metricExporter;
-
- @BeforeMethod
- void setUp() {
- if (metricExporter != null) {
- metricExporter.reset();
- }
- }
+public class AsyncDoubleCounterTest extends BaseMetricsTest {
+ private static final String COUNTER_NAME = "testDoubleAsyncCounter";
+ private static final String COUNTER_DESCRIPTION = "Testing double counter";
+ private static final String COUNTER_UNIT = "Metric Tonnes";
@Test
- void testAsyncDoubleCounter() throws InterruptedException {
+ void testAsyncDoubleCounter() {
Assert.assertNotNull(
sdkMeter
- .counterBuilder(counterName)
+ .counterBuilder(COUNTER_NAME)
.ofDoubles()
- .setDescription(counterDescription)
- .setUnit(counterUnit)
+ .setDescription(COUNTER_DESCRIPTION)
+ .setUnit(COUNTER_UNIT)
.buildWithCallback(measurement -> {
measurement.record(1, Attributes.empty());
}));
- MetricData metric = metricExporter.getMetricData(counterName).get(0);
-
- Assert.assertEquals(metric.getType(), MetricDataType.DOUBLE_SUM);
- Assert.assertEquals(metric.getDescription(), counterDescription);
- Assert.assertEquals(metric.getUnit(), counterUnit);
+ MetricData metric = assertMetric(COUNTER_NAME, MetricDataType.DOUBLE_SUM, COUNTER_DESCRIPTION, COUNTER_UNIT);
Assert.assertEquals(metric.getDoubleSumData()
.getPoints()
diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/AsyncLongCounterTest.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/AsyncLongCounterTest.java
index a7fef630..38c4a383 100644
--- a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/AsyncLongCounterTest.java
+++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/AsyncLongCounterTest.java
@@ -21,77 +21,32 @@
**********************************************************************/
package org.eclipse.microprofile.telemetry.metrics.tck.application.cdi;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.TestLibraries;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.exporter.InMemoryMetricExporter;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.exporter.InMemoryMetricExporterProvider;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.testng.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.asset.EmptyAsset;
-import org.jboss.shrinkwrap.api.asset.StringAsset;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.eclipse.microprofile.telemetry.metrics.tck.shared.BaseMetricsTest;
import org.testng.Assert;
-import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import io.opentelemetry.api.common.Attributes;
-import io.opentelemetry.api.metrics.Meter;
-import io.opentelemetry.sdk.autoconfigure.spi.metrics.ConfigurableMetricExporterProvider;
import io.opentelemetry.sdk.metrics.data.MetricData;
import io.opentelemetry.sdk.metrics.data.MetricDataType;
-import jakarta.inject.Inject;
-public class AsyncLongCounterTest extends Arquillian {
+public class AsyncLongCounterTest extends BaseMetricsTest {
- private static final String counterName = "testAsyncLongCounter";
- private static final String counterDescription = "Testing long counter";
- private static final String counterUnit = "Metric Tonnes";
-
- private static final long LONG_VALUE = 12;
- private static final long LONG_WITH_ATTRIBUTES = 24;
- private static final long LONG_WITHOUT_ATTRIBUTES = 12;
-
- @Deployment
- public static WebArchive createTestArchive() {
- return ShrinkWrap.create(WebArchive.class)
- .addClasses(InMemoryMetricExporter.class, InMemoryMetricExporterProvider.class)
- .addAsLibrary(TestLibraries.AWAITILITY_LIB)
- .addAsServiceProvider(ConfigurableMetricExporterProvider.class, InMemoryMetricExporterProvider.class)
- .addAsResource(new StringAsset(
- "otel.sdk.disabled=false\notel.metrics.exporter=in-memory\notel.logs.exporter=none\notel.traces.exporter=none\notel.metric.export.interval=3000"),
- "META-INF/microprofile-config.properties")
- .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
- }
-
- @Inject
- private Meter sdkMeter;
-
- @Inject
- private InMemoryMetricExporter metricExporter;
-
- @BeforeMethod
- void setUp() {
- if (metricExporter != null) {
- metricExporter.reset();
- }
- }
+ private static final String COUNTER_NAME = "testAsyncLongCounter";
+ private static final String COUNTER_DESCRIPTION = "Testing long counter";
+ private static final String COUNTER_UNIT = "Metric Tonnes";
@Test
- void testAsyncLongCounter() throws InterruptedException {
+ void testAsyncLongCounter() {
Assert.assertNotNull(
sdkMeter
- .counterBuilder(counterName)
- .setDescription(counterDescription)
- .setUnit(counterUnit)
+ .counterBuilder(COUNTER_NAME)
+ .setDescription(COUNTER_DESCRIPTION)
+ .setUnit(COUNTER_UNIT)
.buildWithCallback(measurement -> {
measurement.record(1, Attributes.empty());
}));
- MetricData metric = metricExporter.getMetricData((counterName)).get(0);
-
- Assert.assertEquals(metric.getType(), MetricDataType.LONG_SUM);
- Assert.assertEquals(metric.getDescription(), counterDescription);
- Assert.assertEquals(metric.getUnit(), counterUnit);
+ MetricData metric = assertMetric(COUNTER_NAME, MetricDataType.LONG_SUM, COUNTER_DESCRIPTION, COUNTER_UNIT);
Assert.assertEquals(metric.getLongSumData()
.getPoints()
diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/DoubleCounterTest.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/DoubleCounterTest.java
index 800f83c3..26c75bd8 100644
--- a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/DoubleCounterTest.java
+++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/DoubleCounterTest.java
@@ -25,71 +25,32 @@
import java.util.List;
import java.util.Map;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.TestLibraries;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.TestUtils;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.exporter.InMemoryMetricExporter;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.exporter.InMemoryMetricExporterProvider;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.testng.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.asset.EmptyAsset;
-import org.jboss.shrinkwrap.api.asset.StringAsset;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.eclipse.microprofile.telemetry.metrics.tck.shared.BaseMetricsTest;
+import org.eclipse.microprofile.telemetry.metrics.tck.shared.TestUtils;
import org.testng.Assert;
-import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.metrics.DoubleCounter;
-import io.opentelemetry.api.metrics.Meter;
-import io.opentelemetry.sdk.autoconfigure.spi.metrics.ConfigurableMetricExporterProvider;
import io.opentelemetry.sdk.metrics.data.MetricData;
import io.opentelemetry.sdk.metrics.data.MetricDataType;
-import jakarta.inject.Inject;
-public class DoubleCounterTest extends Arquillian {
- private static final String counterName = "testDoubleCounter";
- private static final String counterDescription = "Testing double counter";
- private static final String counterUnit = "Metric Tonnes";
+public class DoubleCounterTest extends BaseMetricsTest {
+ private static final String COUNTER_NAME = "testDoubleCounter";
+ private static final String COUNTER_DESCRIPTION = "Testing double counter";
+ private static final String COUNTER_UNIT = "Metric Tonnes";
private static final double DOUBLE_WITH_ATTRIBUTES = 20.2;
private static final double DOUBLE_WITHOUT_ATTRIBUTES = 10.1;
- @Deployment
- public static WebArchive createTestArchive() {
-
- return ShrinkWrap.create(WebArchive.class)
- .addClasses(InMemoryMetricExporter.class, InMemoryMetricExporterProvider.class, TestUtils.class)
- .addAsLibrary(TestLibraries.AWAITILITY_LIB)
- .addAsServiceProvider(ConfigurableMetricExporterProvider.class, InMemoryMetricExporterProvider.class)
- .addAsResource(new StringAsset(
- "otel.sdk.disabled=false\notel.metrics.exporter=in-memory\notel.logs.exporter=none\notel.traces.exporter=none\notel.metric.export.interval=3000"),
- "META-INF/microprofile-config.properties")
- .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
- }
-
- @Inject
- private Meter sdkMeter;
-
- @Inject
- private InMemoryMetricExporter metricExporter;
-
- @BeforeMethod
- void setUp() {
- if (metricExporter != null) {
- metricExporter.reset();
- }
- }
-
@Test
- void testDoubleCounter() throws InterruptedException {
-
+ void testDoubleCounter() {
DoubleCounter doubleCounter =
sdkMeter
- .counterBuilder(counterName)
+ .counterBuilder(COUNTER_NAME)
.ofDoubles()
- .setDescription(counterDescription)
- .setUnit(counterUnit)
+ .setDescription(COUNTER_DESCRIPTION)
+ .setUnit(COUNTER_UNIT)
.build();
Assert.assertNotNull(doubleCounter);
@@ -99,12 +60,12 @@ void testDoubleCounter() throws InterruptedException {
expectedResults.keySet().stream().forEach(key -> doubleCounter.add(key, expectedResults.get(key)));
- List metrics = metricExporter.getMetricData((counterName));
+ List metrics = metricExporter.getMetricData((COUNTER_NAME));
metrics.stream()
.peek(metricData -> {
Assert.assertEquals(metricData.getType(), MetricDataType.DOUBLE_SUM);
- Assert.assertEquals(metricData.getDescription(), counterDescription);
- Assert.assertEquals(metricData.getUnit(), counterUnit);
+ Assert.assertEquals(metricData.getDescription(), COUNTER_DESCRIPTION);
+ Assert.assertEquals(metricData.getUnit(), COUNTER_UNIT);
})
.flatMap(metricData -> metricData.getDoubleSumData().getPoints().stream())
.forEach(point -> {
diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/DoubleGaugeTest.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/DoubleGaugeTest.java
index 321de4b7..d8ff5059 100644
--- a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/DoubleGaugeTest.java
+++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/DoubleGaugeTest.java
@@ -21,72 +21,31 @@
**********************************************************************/
package org.eclipse.microprofile.telemetry.metrics.tck.application.cdi;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.TestLibraries;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.exporter.InMemoryMetricExporter;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.exporter.InMemoryMetricExporterProvider;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.testng.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.asset.EmptyAsset;
-import org.jboss.shrinkwrap.api.asset.StringAsset;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.eclipse.microprofile.telemetry.metrics.tck.shared.BaseMetricsTest;
import org.testng.Assert;
-import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import io.opentelemetry.api.common.Attributes;
-import io.opentelemetry.api.metrics.Meter;
-import io.opentelemetry.sdk.autoconfigure.spi.metrics.ConfigurableMetricExporterProvider;
import io.opentelemetry.sdk.metrics.data.MetricData;
import io.opentelemetry.sdk.metrics.data.MetricDataType;
-import jakarta.inject.Inject;
-public class DoubleGaugeTest extends Arquillian {
- private static final String gaugeName = "testDoubleGauge";
- private static final String gaugeDescription = "Testing double gauge";
- private static final String gaugeUnit = "ms";
-
- @Deployment
- public static WebArchive createTestArchive() {
-
- return ShrinkWrap.create(WebArchive.class)
- .addClasses(InMemoryMetricExporter.class, InMemoryMetricExporterProvider.class)
- .addAsLibrary(TestLibraries.AWAITILITY_LIB)
- .addAsServiceProvider(ConfigurableMetricExporterProvider.class, InMemoryMetricExporterProvider.class)
- .addAsResource(new StringAsset(
- "otel.sdk.disabled=false\notel.metrics.exporter=in-memory\notel.logs.exporter=none\notel.traces.exporter=none\notel.metric.export.interval=3000"),
- "META-INF/microprofile-config.properties")
- .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
- }
-
- @Inject
- private Meter sdkMeter;
-
- @Inject
- private InMemoryMetricExporter metricExporter;
-
- @BeforeMethod
- void setUp() {
- if (metricExporter != null) {
- metricExporter.reset();
- }
- }
+public class DoubleGaugeTest extends BaseMetricsTest {
+ private static final String GAUGE_NAME = "testDoubleGauge";
+ private static final String GAUGE_DESCRIPTION = "Testing double gauge";
+ private static final String GAUGE_UNIT = "ms";
@Test
void testDoubleGauge() throws InterruptedException {
Assert.assertNotNull(
sdkMeter
- .gaugeBuilder(gaugeName)
- .setDescription(gaugeDescription)
+ .gaugeBuilder(GAUGE_NAME)
+ .setDescription(GAUGE_DESCRIPTION)
.setUnit("ms")
.buildWithCallback(measurement -> {
measurement.record(1, Attributes.empty());
}));
- MetricData metric = metricExporter.getMetricData(gaugeName).get(0);
- Assert.assertEquals(metric.getType(), MetricDataType.DOUBLE_GAUGE);
- Assert.assertEquals(metric.getDescription(), gaugeDescription);
- Assert.assertEquals(metric.getUnit(), gaugeUnit);
+ MetricData metric = assertMetric(GAUGE_NAME, MetricDataType.DOUBLE_GAUGE, GAUGE_DESCRIPTION, GAUGE_UNIT);
Assert.assertEquals(metric.getDoubleGaugeData()
.getPoints()
diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/DoubleHistogramTest.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/DoubleHistogramTest.java
index 739cd0d4..9a3453ff 100644
--- a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/DoubleHistogramTest.java
+++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/DoubleHistogramTest.java
@@ -25,70 +25,32 @@
import java.util.List;
import java.util.Map;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.TestLibraries;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.TestUtils;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.exporter.InMemoryMetricExporter;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.exporter.InMemoryMetricExporterProvider;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.testng.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.asset.EmptyAsset;
-import org.jboss.shrinkwrap.api.asset.StringAsset;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.eclipse.microprofile.telemetry.metrics.tck.shared.BaseMetricsTest;
+import org.eclipse.microprofile.telemetry.metrics.tck.shared.TestUtils;
import org.testng.Assert;
-import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.metrics.DoubleHistogram;
-import io.opentelemetry.api.metrics.Meter;
-import io.opentelemetry.sdk.autoconfigure.spi.metrics.ConfigurableMetricExporterProvider;
import io.opentelemetry.sdk.metrics.data.MetricData;
import io.opentelemetry.sdk.metrics.data.MetricDataType;
-import jakarta.inject.Inject;
-public class DoubleHistogramTest extends Arquillian {
+public class DoubleHistogramTest extends BaseMetricsTest {
- private static final String histogramName = "testDoubleHistogram";
- private static final String histogramDescription = "Testing double histogram";
- private static final String histogramUnit = "Metric Tonnes";
+ private static final String HISTOGRAM_NAME = "testDoubleHistogram";
+ private static final String HISTOGRAM_DESCRIPTION = "Testing double histogram";
+ private static final String HISTOGRAM_UNIT = "Metric Tonnes";
private static final double DOUBLE_WITH_ATTRIBUTES = 20;
private static final double DOUBLE_WITHOUT_ATTRIBUTES = 10;
- @Deployment
- public static WebArchive createTestArchive() {
-
- return ShrinkWrap.create(WebArchive.class)
- .addClasses(InMemoryMetricExporter.class, InMemoryMetricExporterProvider.class, TestUtils.class)
- .addAsLibrary(TestLibraries.AWAITILITY_LIB)
- .addAsServiceProvider(ConfigurableMetricExporterProvider.class, InMemoryMetricExporterProvider.class)
- .addAsResource(new StringAsset(
- "otel.sdk.disabled=false\notel.metrics.exporter=in-memory\notel.logs.exporter=none\notel.traces.exporter=none\notel.metric.export.interval=3000"),
- "META-INF/microprofile-config.properties")
- .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
- }
-
- @Inject
- private Meter sdkMeter;
-
- @Inject
- private InMemoryMetricExporter metricExporter;
-
- @BeforeMethod
- void setUp() {
- if (metricExporter != null) {
- metricExporter.reset();
- }
- }
-
@Test
- void testDoubleHistogram() throws InterruptedException {
+ void testDoubleHistogram() {
DoubleHistogram doubleHistogram =
sdkMeter
- .histogramBuilder(histogramName)
- .setDescription(histogramDescription)
- .setUnit(histogramUnit)
+ .histogramBuilder(HISTOGRAM_NAME)
+ .setDescription(HISTOGRAM_DESCRIPTION)
+ .setUnit(HISTOGRAM_UNIT)
.build();
Assert.assertNotNull(doubleHistogram);
@@ -98,12 +60,12 @@ void testDoubleHistogram() throws InterruptedException {
expectedResults.keySet().stream().forEach(key -> doubleHistogram.record(key, expectedResults.get(key)));
- List metrics = metricExporter.getMetricData((histogramName));
+ List metrics = metricExporter.getMetricData((HISTOGRAM_NAME));
metrics.stream()
.peek(metricData -> {
Assert.assertEquals(metricData.getType(), MetricDataType.HISTOGRAM);
- Assert.assertEquals(metricData.getDescription(), histogramDescription);
- Assert.assertEquals(metricData.getUnit(), histogramUnit);
+ Assert.assertEquals(metricData.getDescription(), HISTOGRAM_DESCRIPTION);
+ Assert.assertEquals(metricData.getUnit(), HISTOGRAM_UNIT);
})
.flatMap(metricData -> metricData.getHistogramData().getPoints().stream())
.forEach(point -> {
diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/DoubleUpDownCounterTest.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/DoubleUpDownCounterTest.java
index 15279f78..2bfa2db4 100644
--- a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/DoubleUpDownCounterTest.java
+++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/DoubleUpDownCounterTest.java
@@ -25,71 +25,33 @@
import java.util.List;
import java.util.Map;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.TestLibraries;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.TestUtils;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.exporter.InMemoryMetricExporter;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.exporter.InMemoryMetricExporterProvider;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.testng.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.asset.EmptyAsset;
-import org.jboss.shrinkwrap.api.asset.StringAsset;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.eclipse.microprofile.telemetry.metrics.tck.shared.BaseMetricsTest;
+import org.eclipse.microprofile.telemetry.metrics.tck.shared.TestUtils;
import org.testng.Assert;
-import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.metrics.DoubleUpDownCounter;
-import io.opentelemetry.api.metrics.Meter;
-import io.opentelemetry.sdk.autoconfigure.spi.metrics.ConfigurableMetricExporterProvider;
import io.opentelemetry.sdk.metrics.data.MetricData;
import io.opentelemetry.sdk.metrics.data.MetricDataType;
-import jakarta.inject.Inject;
-public class DoubleUpDownCounterTest extends Arquillian {
+public class DoubleUpDownCounterTest extends BaseMetricsTest {
- private static final String counterName = "testDoubleUpDownCounter";
- private static final String counterDescription = "Testing double up down counter";
- private static final String counterUnit = "Metric Tonnes";
+ private static final String COUNTER_NAME = "testDoubleUpDownCounter";
+ private static final String COUNTER_DESCRIPTION = "Testing double up down counter";
+ private static final String COUNTER_UNIT = "Metric Tonnes";
private static final double DOUBLE_WITH_ATTRIBUTES = -20;
private static final double DOUBLE_WITHOUT_ATTRIBUTES = -10;
- @Deployment
- public static WebArchive createTestArchive() {
-
- return ShrinkWrap.create(WebArchive.class)
- .addClasses(InMemoryMetricExporter.class, InMemoryMetricExporterProvider.class, TestUtils.class)
- .addAsLibrary(TestLibraries.AWAITILITY_LIB)
- .addAsServiceProvider(ConfigurableMetricExporterProvider.class, InMemoryMetricExporterProvider.class)
- .addAsResource(new StringAsset(
- "otel.sdk.disabled=false\notel.metrics.exporter=in-memory\notel.logs.exporter=none\notel.traces.exporter=none\notel.metric.export.interval=3000"),
- "META-INF/microprofile-config.properties")
- .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
- }
-
- @Inject
- private Meter sdkMeter;
-
- @Inject
- private InMemoryMetricExporter metricExporter;
-
- @BeforeMethod
- void setUp() {
- if (metricExporter != null) {
- metricExporter.reset();
- }
- }
-
@Test
- void testDoubleUpDownCounter() throws InterruptedException {
+ void testDoubleUpDownCounter() {
DoubleUpDownCounter doubleUpDownCounter =
sdkMeter
- .upDownCounterBuilder(counterName)
+ .upDownCounterBuilder(COUNTER_NAME)
.ofDoubles()
- .setDescription(counterDescription)
- .setUnit(counterUnit)
+ .setDescription(COUNTER_DESCRIPTION)
+ .setUnit(COUNTER_UNIT)
.build();
Assert.assertNotNull(doubleUpDownCounter);
@@ -99,12 +61,12 @@ void testDoubleUpDownCounter() throws InterruptedException {
expectedResults.keySet().stream().forEach(key -> doubleUpDownCounter.add(key, expectedResults.get(key)));
- List metrics = metricExporter.getMetricData((counterName));
+ List metrics = metricExporter.getMetricData((COUNTER_NAME));
metrics.stream()
.peek(metricData -> {
Assert.assertEquals(metricData.getType(), MetricDataType.DOUBLE_SUM);
- Assert.assertEquals(metricData.getDescription(), counterDescription);
- Assert.assertEquals(metricData.getUnit(), counterUnit);
+ Assert.assertEquals(metricData.getDescription(), COUNTER_DESCRIPTION);
+ Assert.assertEquals(metricData.getUnit(), COUNTER_UNIT);
})
.flatMap(metricData -> metricData.getDoubleSumData().getPoints().stream())
.forEach(point -> {
diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/LongCounterTest.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/LongCounterTest.java
index f77794c9..71a18b52 100644
--- a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/LongCounterTest.java
+++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/LongCounterTest.java
@@ -25,72 +25,32 @@
import java.util.List;
import java.util.Map;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.TestLibraries;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.TestUtils;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.exporter.InMemoryMetricExporter;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.exporter.InMemoryMetricExporterProvider;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.testng.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.asset.EmptyAsset;
-import org.jboss.shrinkwrap.api.asset.StringAsset;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.eclipse.microprofile.telemetry.metrics.tck.shared.BaseMetricsTest;
+import org.eclipse.microprofile.telemetry.metrics.tck.shared.TestUtils;
import org.testng.Assert;
-import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.metrics.LongCounter;
-import io.opentelemetry.api.metrics.Meter;
-import io.opentelemetry.sdk.autoconfigure.spi.metrics.ConfigurableMetricExporterProvider;
import io.opentelemetry.sdk.metrics.data.MetricData;
import io.opentelemetry.sdk.metrics.data.MetricDataType;
-import jakarta.inject.Inject;
-public class LongCounterTest extends Arquillian {
+public class LongCounterTest extends BaseMetricsTest {
- private static final String counterName = "testLongCounter";
- private static final String counterDescription = "Testing long counter";
- private static final String counterUnit = "Metric Tonnes";
+ private static final String COUNTER_NAME = "testLongCounter";
+ private static final String COUNTER_DESCRIPTION = "Testing long counter";
+ private static final String COUNTER_UNIT = "Metric Tonnes";
- private static final long LONG_VALUE = 12;
private static final long LONG_WITH_ATTRIBUTES = 24;
private static final long LONG_WITHOUT_ATTRIBUTES = 12;
- @Deployment
- public static WebArchive createTestArchive() {
-
- return ShrinkWrap.create(WebArchive.class)
- .addClasses(InMemoryMetricExporter.class, InMemoryMetricExporterProvider.class, TestUtils.class)
- .addAsLibrary(TestLibraries.AWAITILITY_LIB)
- .addAsServiceProvider(ConfigurableMetricExporterProvider.class, InMemoryMetricExporterProvider.class)
- .addAsResource(new StringAsset(
- "otel.sdk.disabled=false\notel.metrics.exporter=in-memory\notel.logs.exporter=none\notel.traces.exporter=none\notel.metric.export.interval=3000"),
- "META-INF/microprofile-config.properties")
- .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
- }
-
- @Inject
- private Meter sdkMeter;
-
- @Inject
- private InMemoryMetricExporter metricExporter;
-
- @BeforeMethod
- void setUp() {
- if (metricExporter != null) {
- metricExporter.reset();
- }
- }
-
@Test
- void testLongCounter() throws InterruptedException {
-
+ void testLongCounter() {
LongCounter longCounter =
sdkMeter
- .counterBuilder(counterName)
- .setDescription(counterDescription)
- .setUnit(counterUnit)
+ .counterBuilder(COUNTER_NAME)
+ .setDescription(COUNTER_DESCRIPTION)
+ .setUnit(COUNTER_UNIT)
.build();
Assert.assertNotNull(longCounter);
@@ -100,12 +60,12 @@ void testLongCounter() throws InterruptedException {
expectedResults.keySet().stream().forEach(key -> longCounter.add(key, expectedResults.get(key)));
- List metrics = metricExporter.getMetricData((counterName));
+ List metrics = metricExporter.getMetricData(COUNTER_NAME);
metrics.stream()
.peek(metricData -> {
Assert.assertEquals(metricData.getType(), MetricDataType.LONG_SUM);
- Assert.assertEquals(metricData.getDescription(), counterDescription);
- Assert.assertEquals(metricData.getUnit(), counterUnit);
+ Assert.assertEquals(metricData.getDescription(), COUNTER_DESCRIPTION);
+ Assert.assertEquals(metricData.getUnit(), COUNTER_UNIT);
})
.flatMap(metricData -> metricData.getLongSumData().getPoints().stream())
.forEach(point -> {
diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/LongGaugeTest.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/LongGaugeTest.java
index e9275344..444c2c6b 100644
--- a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/LongGaugeTest.java
+++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/LongGaugeTest.java
@@ -21,73 +21,32 @@
**********************************************************************/
package org.eclipse.microprofile.telemetry.metrics.tck.application.cdi;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.TestLibraries;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.exporter.InMemoryMetricExporter;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.exporter.InMemoryMetricExporterProvider;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.testng.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.asset.EmptyAsset;
-import org.jboss.shrinkwrap.api.asset.StringAsset;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.eclipse.microprofile.telemetry.metrics.tck.shared.BaseMetricsTest;
import org.testng.Assert;
-import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import io.opentelemetry.api.common.Attributes;
-import io.opentelemetry.api.metrics.Meter;
-import io.opentelemetry.sdk.autoconfigure.spi.metrics.ConfigurableMetricExporterProvider;
import io.opentelemetry.sdk.metrics.data.MetricData;
import io.opentelemetry.sdk.metrics.data.MetricDataType;
-import jakarta.inject.Inject;
-public class LongGaugeTest extends Arquillian {
- private static final String gaugeName = "testLongGauge";
- private static final String gaugeDescription = "Testing long gauge";
- private static final String gaugeUnit = "ms";
-
- @Deployment
- public static WebArchive createTestArchive() {
-
- return ShrinkWrap.create(WebArchive.class)
- .addClasses(InMemoryMetricExporter.class, InMemoryMetricExporterProvider.class)
- .addAsLibrary(TestLibraries.AWAITILITY_LIB)
- .addAsServiceProvider(ConfigurableMetricExporterProvider.class, InMemoryMetricExporterProvider.class)
- .addAsResource(new StringAsset(
- "otel.sdk.disabled=false\notel.metrics.exporter=in-memory\notel.logs.exporter=none\notel.traces.exporter=none\notel.metric.export.interval=3000"),
- "META-INF/microprofile-config.properties")
- .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
- }
-
- @Inject
- private Meter sdkMeter;
-
- @Inject
- private InMemoryMetricExporter metricExporter;
-
- @BeforeMethod
- void setUp() {
- if (metricExporter != null) {
- metricExporter.reset();
- }
- }
+public class LongGaugeTest extends BaseMetricsTest {
+ private static final String GAUGE_NAME = "testLongGauge";
+ private static final String GAUGE_DESCRIPTION = "Testing long gauge";
+ private static final String GAUGE_UNIT = "ms";
@Test
- void testLongGauge() throws InterruptedException {
+ void testLongGauge() {
Assert.assertNotNull(
sdkMeter
- .gaugeBuilder(gaugeName)
+ .gaugeBuilder(GAUGE_NAME)
.ofLongs()
- .setDescription(gaugeDescription)
+ .setDescription(GAUGE_DESCRIPTION)
.setUnit("ms")
.buildWithCallback(measurement -> {
measurement.record(1, Attributes.empty());
}));
- MetricData metric = metricExporter.getMetricData((gaugeName)).get(0);
- Assert.assertEquals(metric.getType(), MetricDataType.LONG_GAUGE);
- Assert.assertEquals(metric.getDescription(), gaugeDescription);
- Assert.assertEquals(metric.getUnit(), gaugeUnit);
+ MetricData metric = assertMetric(GAUGE_NAME, MetricDataType.LONG_GAUGE, GAUGE_DESCRIPTION, GAUGE_UNIT);
Assert.assertEquals(metric.getLongGaugeData()
.getPoints()
diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/LongHistogramTest.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/LongHistogramTest.java
index efeb830c..d62f9aee 100644
--- a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/LongHistogramTest.java
+++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/LongHistogramTest.java
@@ -25,71 +25,32 @@
import java.util.List;
import java.util.Map;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.TestLibraries;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.TestUtils;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.exporter.InMemoryMetricExporter;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.exporter.InMemoryMetricExporterProvider;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.testng.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.asset.EmptyAsset;
-import org.jboss.shrinkwrap.api.asset.StringAsset;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.eclipse.microprofile.telemetry.metrics.tck.shared.BaseMetricsTest;
+import org.eclipse.microprofile.telemetry.metrics.tck.shared.TestUtils;
import org.testng.Assert;
-import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.metrics.LongHistogram;
-import io.opentelemetry.api.metrics.Meter;
-import io.opentelemetry.sdk.autoconfigure.spi.metrics.ConfigurableMetricExporterProvider;
import io.opentelemetry.sdk.metrics.data.MetricData;
import io.opentelemetry.sdk.metrics.data.MetricDataType;
-import jakarta.inject.Inject;
-public class LongHistogramTest extends Arquillian {
-
- private static final String histogramName = "testLongHistogram";
- private static final String histogramDescription = "Testing long histogram";
- private static final String histogramUnit = "Metric Tonnes";
+public class LongHistogramTest extends BaseMetricsTest {
+ private static final String HISTOGRAM_NAME = "testLongHistogram";
+ private static final String HISTOGRAM_DESCRIPTION = "Testing long histogram";
+ private static final String HISTOGRAM_UNIT = "Metric Tonnes";
private static final long LONG_WITH_ATTRIBUTES = 20;
private static final long LONG_WITHOUT_ATTRIBUTES = 10;
- @Deployment
- public static WebArchive createTestArchive() {
-
- return ShrinkWrap.create(WebArchive.class)
- .addClasses(InMemoryMetricExporter.class, InMemoryMetricExporterProvider.class, TestUtils.class)
- .addAsLibrary(TestLibraries.AWAITILITY_LIB)
- .addAsServiceProvider(ConfigurableMetricExporterProvider.class, InMemoryMetricExporterProvider.class)
- .addAsResource(new StringAsset(
- "otel.sdk.disabled=false\notel.metrics.exporter=in-memory\notel.logs.exporter=none\notel.traces.exporter=none\notel.metric.export.interval=3000"),
- "META-INF/microprofile-config.properties")
- .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
- }
-
- @Inject
- private Meter sdkMeter;
-
- @Inject
- private InMemoryMetricExporter metricExporter;
-
- @BeforeMethod
- void setUp() {
- if (metricExporter != null) {
- metricExporter.reset();
- }
- }
-
@Test
- void testLongHistogram() throws InterruptedException {
+ void testLongHistogram() {
LongHistogram longHistogram =
sdkMeter
- .histogramBuilder(histogramName)
+ .histogramBuilder(HISTOGRAM_NAME)
.ofLongs()
- .setDescription(histogramDescription)
- .setUnit(histogramUnit)
+ .setDescription(HISTOGRAM_DESCRIPTION)
+ .setUnit(HISTOGRAM_UNIT)
.build();
Assert.assertNotNull(longHistogram);
@@ -99,12 +60,12 @@ void testLongHistogram() throws InterruptedException {
expectedResults.keySet().stream().forEach(key -> longHistogram.record(key, expectedResults.get(key)));
- List metrics = metricExporter.getMetricData((histogramName));
+ List metrics = metricExporter.getMetricData((HISTOGRAM_NAME));
metrics.stream()
.peek(metricData -> {
Assert.assertEquals(metricData.getType(), MetricDataType.HISTOGRAM);
- Assert.assertEquals(metricData.getDescription(), histogramDescription);
- Assert.assertEquals(metricData.getUnit(), histogramUnit);
+ Assert.assertEquals(metricData.getDescription(), HISTOGRAM_DESCRIPTION);
+ Assert.assertEquals(metricData.getUnit(), HISTOGRAM_UNIT);
})
.flatMap(metricData -> metricData.getHistogramData().getPoints().stream())
.forEach(point -> {
diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/LongUpDownCounterTest.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/LongUpDownCounterTest.java
index 60c038e3..88379c59 100644
--- a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/LongUpDownCounterTest.java
+++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/LongUpDownCounterTest.java
@@ -25,70 +25,31 @@
import java.util.List;
import java.util.Map;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.TestLibraries;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.TestUtils;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.exporter.InMemoryMetricExporter;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.exporter.InMemoryMetricExporterProvider;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.testng.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.asset.EmptyAsset;
-import org.jboss.shrinkwrap.api.asset.StringAsset;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.eclipse.microprofile.telemetry.metrics.tck.shared.BaseMetricsTest;
+import org.eclipse.microprofile.telemetry.metrics.tck.shared.TestUtils;
import org.testng.Assert;
-import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.metrics.LongUpDownCounter;
-import io.opentelemetry.api.metrics.Meter;
-import io.opentelemetry.sdk.autoconfigure.spi.metrics.ConfigurableMetricExporterProvider;
import io.opentelemetry.sdk.metrics.data.MetricData;
import io.opentelemetry.sdk.metrics.data.MetricDataType;
-import jakarta.inject.Inject;
-public class LongUpDownCounterTest extends Arquillian {
-
- private static final String counterName = "testLongUpDownCounter";
- private static final String counterDescription = "Testing long up down counter";
- private static final String counterUnit = "Metric Tonnes";
+public class LongUpDownCounterTest extends BaseMetricsTest {
+ private static final String COUNTER_NAME = "testLongUpDownCounter";
+ private static final String COUNTER_DESCRIPTION = "Testing long up down counter";
+ private static final String COUNTER_UNIT = "Metric Tonnes";
private static final long LONG_WITH_ATTRIBUTES = -20;
private static final long LONG_WITHOUT_ATTRIBUTES = -10;
- @Deployment
- public static WebArchive createTestArchive() {
-
- return ShrinkWrap.create(WebArchive.class)
- .addClasses(InMemoryMetricExporter.class, InMemoryMetricExporterProvider.class, TestUtils.class)
- .addAsLibrary(TestLibraries.AWAITILITY_LIB)
- .addAsServiceProvider(ConfigurableMetricExporterProvider.class, InMemoryMetricExporterProvider.class)
- .addAsResource(new StringAsset(
- "otel.sdk.disabled=false\notel.metrics.exporter=in-memory\notel.logs.exporter=none\notel.traces.exporter=none\notel.metric.export.interval=3000"),
- "META-INF/microprofile-config.properties")
- .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
- }
-
- @Inject
- private Meter sdkMeter;
-
- @Inject
- private InMemoryMetricExporter metricExporter;
-
- @BeforeMethod
- void setUp() {
- if (metricExporter != null) {
- metricExporter.reset();
- }
- }
-
@Test
- void testLongUpDownCounter() throws InterruptedException {
+ void testLongUpDownCounter() {
LongUpDownCounter longUpDownCounter =
sdkMeter
- .upDownCounterBuilder(counterName)
- .setDescription(counterDescription)
- .setUnit(counterUnit)
+ .upDownCounterBuilder(COUNTER_NAME)
+ .setDescription(COUNTER_DESCRIPTION)
+ .setUnit(COUNTER_UNIT)
.build();
Assert.assertNotNull(longUpDownCounter);
@@ -96,14 +57,14 @@ void testLongUpDownCounter() throws InterruptedException {
expectedResults.put(LONG_WITH_ATTRIBUTES, Attributes.builder().put("K", "V").build());
expectedResults.put(LONG_WITHOUT_ATTRIBUTES, Attributes.empty());
- expectedResults.keySet().stream().forEach(key -> longUpDownCounter.add(key, expectedResults.get(key)));
+ expectedResults.keySet().forEach(key -> longUpDownCounter.add(key, expectedResults.get(key)));
- List metrics = metricExporter.getMetricData((counterName));
+ List metrics = metricExporter.getMetricData((COUNTER_NAME));
metrics.stream()
.peek(metricData -> {
Assert.assertEquals(metricData.getType(), MetricDataType.LONG_SUM);
- Assert.assertEquals(metricData.getDescription(), counterDescription);
- Assert.assertEquals(metricData.getUnit(), counterUnit);
+ Assert.assertEquals(metricData.getDescription(), COUNTER_DESCRIPTION);
+ Assert.assertEquals(metricData.getUnit(), COUNTER_UNIT);
})
.flatMap(metricData -> metricData.getLongSumData().getPoints().stream())
.forEach(point -> {
diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/http/HttpHistogramTest.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/http/HttpHistogramTest.java
index 2bd787d6..26da1479 100644
--- a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/http/HttpHistogramTest.java
+++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/http/HttpHistogramTest.java
@@ -33,53 +33,25 @@
import java.util.Map;
import java.util.stream.Collectors;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.BasicHttpClient;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.TestLibraries;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.exporter.InMemoryMetricExporter;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.exporter.InMemoryMetricExporterProvider;
-import org.jboss.arquillian.container.test.api.Deployment;
+import org.eclipse.microprofile.telemetry.metrics.tck.shared.BaseMetricsTest;
+import org.eclipse.microprofile.telemetry.metrics.tck.shared.BasicHttpClient;
import org.jboss.arquillian.test.api.ArquillianResource;
-import org.jboss.arquillian.testng.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.asset.EmptyAsset;
-import org.jboss.shrinkwrap.api.asset.StringAsset;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.common.AttributeKey;
-import io.opentelemetry.sdk.autoconfigure.spi.metrics.ConfigurableMetricExporterProvider;
import io.opentelemetry.sdk.metrics.data.MetricData;
-import jakarta.inject.Inject;
import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.core.Application;
import jakarta.ws.rs.core.Response;
-public class HttpHistogramTest extends Arquillian {
- @Inject
- OpenTelemetry openTelemetry;
-
- @Deployment
- public static WebArchive createTestArchive() {
- return ShrinkWrap.create(WebArchive.class)
- .addClasses(InMemoryMetricExporter.class, InMemoryMetricExporterProvider.class,
- BasicHttpClient.class)
- .addAsLibrary(TestLibraries.AWAITILITY_LIB)
- .addAsServiceProvider(ConfigurableMetricExporterProvider.class, InMemoryMetricExporterProvider.class)
- .addAsResource(new StringAsset(
- "otel.sdk.disabled=false\notel.metrics.exporter=in-memory\notel.logs.exporter=none\notel.traces.exporter=none\notel.metric.export.interval=3000"),
- "META-INF/microprofile-config.properties")
- .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
- }
+public class HttpHistogramTest extends BaseMetricsTest {
@ArquillianResource
private URL url;
- @Inject
- private InMemoryMetricExporter metricExporter;
private BasicHttpClient basicClient;
@@ -100,7 +72,6 @@ void collectsHttpRouteFromEndAttributes() {
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
- e.printStackTrace();
Assert.fail("The test thread was interrupted");
}
diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/exporter/InMemoryMetricExporter.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/exporter/InMemoryMetricExporter.java
similarity index 88%
rename from tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/exporter/InMemoryMetricExporter.java
rename to tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/exporter/InMemoryMetricExporter.java
index b320f0bb..9f553c41 100644
--- a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/exporter/InMemoryMetricExporter.java
+++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/exporter/InMemoryMetricExporter.java
@@ -18,12 +18,14 @@
*
*/
-package org.eclipse.microprofile.telemetry.metrics.tck.application.exporter;
+package org.eclipse.microprofile.telemetry.metrics.tck.exporter;
import static java.util.concurrent.TimeUnit.SECONDS;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.Objects;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.stream.Collectors;
@@ -55,21 +57,18 @@ public InMemoryMetricExporter() {
* @return a {@code List} of the finished {@code Metric}s.
*/
public List getFinishedMetricItems() {
- return finishedMetricItems.stream()
- .collect(Collectors.toList());
+ return new ArrayList<>(finishedMetricItems);
}
public List getMetricData(String metricName) {
assertMetricNameFound(metricName);
return getFinishedMetricItems().stream().filter(metric -> metric.getName() == metricName)
.collect(Collectors.toList());
- // .orElseThrow(() -> new IllegalStateException("No metric found with type " + dataType));
}
public void assertMetricNameFound(String metricName) {
Awaitility.await().pollDelay(5, SECONDS).atMost(10, SECONDS)
- .untilAsserted(() -> Assert.assertTrue(
- getFinishedMetricItems().stream().filter(metric -> metric.getName() == metricName)
- .collect(Collectors.toList()).size() > 0));
+ .untilAsserted(() -> Assert.assertNotEquals(getFinishedMetricItems().stream()
+ .filter(metric -> Objects.equals(metric.getName(), metricName)).count(), 0));
}
/**
diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/exporter/InMemoryMetricExporterProvider.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/exporter/InMemoryMetricExporterProvider.java
similarity index 94%
rename from tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/exporter/InMemoryMetricExporterProvider.java
rename to tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/exporter/InMemoryMetricExporterProvider.java
index bd798d4d..95e1cf95 100644
--- a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/exporter/InMemoryMetricExporterProvider.java
+++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/exporter/InMemoryMetricExporterProvider.java
@@ -17,7 +17,7 @@
* limitations under the License.
*
*/
-package org.eclipse.microprofile.telemetry.metrics.tck.application.exporter;
+package org.eclipse.microprofile.telemetry.metrics.tck.exporter;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.metrics.ConfigurableMetricExporterProvider;
diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/jvm/JvmClassesTest.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/jvm/JvmClassesTest.java
index 7c14b65c..dd5e0160 100644
--- a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/jvm/JvmClassesTest.java
+++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/jvm/JvmClassesTest.java
@@ -23,53 +23,28 @@
import java.io.IOException;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.TestLibraries;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.testng.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.asset.EmptyAsset;
-import org.jboss.shrinkwrap.api.asset.StringAsset;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.eclipse.microprofile.telemetry.metrics.tck.shared.BaseMetricsTest;
import org.testng.annotations.Test;
-import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.sdk.metrics.data.MetricDataType;
-import jakarta.inject.Inject;
-
-public class JvmClassesTest extends Arquillian {
-
- @Inject
- OpenTelemetry openTelemetry;
-
- @Deployment
- public static WebArchive createTestArchive() {
- return ShrinkWrap.create(WebArchive.class)
- .addClasses(MetricsReader.class)
- .addAsLibrary(TestLibraries.AWAITILITY_LIB)
- .addAsLibrary(TestLibraries.COMMONS_IO_LIB)
- .addAsResource(
- new StringAsset(
- "otel.sdk.disabled=false\notel.metrics.exporter=logging\notel.logs.exporter=none\notel.traces.exporter=none\notel.metric.export.interval=3000"),
- "META-INF/microprofile-config.properties")
- .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
- }
+public class JvmClassesTest extends BaseMetricsTest {
@Test
void testClassLoadedMetrics() throws IOException {
- MetricsReader.assertLogMessage("jvm.class.loaded", "Number of classes loaded since JVM start.", "{class}",
- MetricDataType.LONG_SUM.toString());
+ assertMetric("jvm.class.loaded", MetricDataType.LONG_SUM,
+ "Number of classes loaded since JVM start.", "{class}");
}
@Test
void testClassUnloadedMetrics() throws IOException {
- MetricsReader.assertLogMessage("jvm.class.unloaded", "Number of classes unloaded since JVM start.",
- "{class}", MetricDataType.LONG_SUM.toString());
+ assertMetric("jvm.class.unloaded", MetricDataType.LONG_SUM,
+ "Number of classes unloaded since JVM start.", "{class}");
}
@Test
void testClassCountMetrics() throws IOException {
- MetricsReader.assertLogMessage("jvm.class.count", "Number of classes currently loaded.",
- "{class}", MetricDataType.LONG_SUM.toString());
+ assertMetric("jvm.class.count", MetricDataType.LONG_SUM,
+ "Number of classes currently loaded.", "{class}");
}
}
diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/jvm/JvmCpuTest.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/jvm/JvmCpuTest.java
index aeadd035..6a44102d 100644
--- a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/jvm/JvmCpuTest.java
+++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/jvm/JvmCpuTest.java
@@ -21,57 +21,27 @@
**********************************************************************/
package org.eclipse.microprofile.telemetry.metrics.tck.jvm;
-import java.io.IOException;
-
-import org.eclipse.microprofile.telemetry.metrics.tck.application.TestLibraries;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.testng.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.asset.EmptyAsset;
-import org.jboss.shrinkwrap.api.asset.StringAsset;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.eclipse.microprofile.telemetry.metrics.tck.shared.BaseMetricsTest;
import org.testng.annotations.Test;
-import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.sdk.metrics.data.MetricDataType;
-import jakarta.inject.Inject;
-
-public class JvmCpuTest extends Arquillian {
-
- @Inject
- OpenTelemetry openTelemetry;
-
- @Deployment
- public static WebArchive createTestArchive() {
- return ShrinkWrap.create(WebArchive.class)
- .addClasses(MetricsReader.class)
- .addAsLibrary(TestLibraries.AWAITILITY_LIB)
- .addAsLibrary(TestLibraries.COMMONS_IO_LIB)
- .addAsResource(
- new StringAsset(
- "otel.sdk.disabled=false\notel.metrics.exporter=logging\notel.logs.exporter=none\notel.traces.exporter=none\notel.metric.export.interval=3000"),
- "META-INF/microprofile-config.properties")
- .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
- }
+public class JvmCpuTest extends BaseMetricsTest {
@Test
- void testCpuTimeMetric() throws IOException {
- MetricsReader.assertLogMessage("jvm.cpu.time", "CPU time used by the process as reported by the JVM.", "s",
- MetricDataType.DOUBLE_SUM.toString());
+ void testCpuTimeMetric() {
+ assertMetric("jvm.cpu.time", MetricDataType.DOUBLE_SUM,
+ "CPU time used by the process as reported by the JVM.", "s");
}
@Test
- void testCpuCountMetric() throws IOException {
- MetricsReader.assertLogMessage("jvm.cpu.count",
- "Number of processors available to the Java virtual machine.", "{cpu}",
- MetricDataType.LONG_SUM.toString());
+ void testCpuCountMetric() {
+ assertMetric("jvm.cpu.count", MetricDataType.LONG_SUM,
+ "Number of processors available to the Java virtual machine.", "{cpu}");
}
@Test
- void testCpuRecentUtilizationMetric() throws IOException {
- MetricsReader.assertLogMessage("jvm.cpu.recent_utilization",
- "Recent CPU utilization for the process as reported by the JVM.", "1",
- MetricDataType.DOUBLE_GAUGE.toString());
+ void testCpuRecentUtilizationMetric() {
+ assertMetric("jvm.cpu.recent_utilization", MetricDataType.DOUBLE_GAUGE,
+ "Recent CPU utilization for the process as reported by the JVM.", "1");
}
-
}
diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/jvm/JvmGarbageCollectionTest.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/jvm/JvmGarbageCollectionTest.java
index 4c2899d7..aeff3d1c 100644
--- a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/jvm/JvmGarbageCollectionTest.java
+++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/jvm/JvmGarbageCollectionTest.java
@@ -25,44 +25,19 @@
import java.lang.ref.WeakReference;
import java.util.concurrent.TimeUnit;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.TestLibraries;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.testng.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.asset.EmptyAsset;
-import org.jboss.shrinkwrap.api.asset.StringAsset;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.eclipse.microprofile.telemetry.metrics.tck.shared.BaseMetricsTest;
import org.testng.Assert;
import org.testng.annotations.Test;
-import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.sdk.metrics.data.MetricDataType;
-import jakarta.inject.Inject;
-
-public class JvmGarbageCollectionTest extends Arquillian {
-
- @Inject
- OpenTelemetry openTelemetry;
-
- @Deployment
- public static WebArchive createTestArchive() {
- return ShrinkWrap.create(WebArchive.class)
- .addClasses(MetricsReader.class)
- .addAsLibrary(TestLibraries.AWAITILITY_LIB)
- .addAsLibrary(TestLibraries.COMMONS_IO_LIB)
- .addAsResource(
- new StringAsset(
- "otel.sdk.disabled=false\notel.metrics.exporter=logging\notel.logs.exporter=none\notel.traces.exporter=none\notel.metric.export.interval=3000"),
- "META-INF/microprofile-config.properties")
- .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
- }
+public class JvmGarbageCollectionTest extends BaseMetricsTest {
@Test
void testGarbageCollectionCountMetric() throws IOException {
waitForGarbageCollection();
- MetricsReader.assertLogMessage("jvm.gc.duration", "Duration of JVM garbage collection actions.", "s",
- MetricDataType.HISTOGRAM.toString());
+ assertMetric("jvm.gc.duration", MetricDataType.HISTOGRAM,
+ "Duration of JVM garbage collection actions.", "s");
}
// returns true if the GC was invoked, otherwise false;
diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/jvm/JvmMemoryTest.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/jvm/JvmMemoryTest.java
index 237af118..553c787a 100644
--- a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/jvm/JvmMemoryTest.java
+++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/jvm/JvmMemoryTest.java
@@ -23,61 +23,35 @@
import java.io.IOException;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.TestLibraries;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.testng.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.asset.EmptyAsset;
-import org.jboss.shrinkwrap.api.asset.StringAsset;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.eclipse.microprofile.telemetry.metrics.tck.shared.BaseMetricsTest;
import org.testng.annotations.Test;
-import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.sdk.metrics.data.MetricDataType;
-import jakarta.inject.Inject;
-
-public class JvmMemoryTest extends Arquillian {
-
- @Inject
- OpenTelemetry openTelemetry;
-
- @Deployment
- public static WebArchive createTestArchive() {
- return ShrinkWrap.create(WebArchive.class)
- .addClasses(MetricsReader.class)
- .addAsLibrary(TestLibraries.AWAITILITY_LIB)
- .addAsLibrary(TestLibraries.COMMONS_IO_LIB)
- .addAsResource(
- new StringAsset(
- "otel.sdk.disabled=false\notel.metrics.exporter=logging\notel.logs.exporter=none\notel.traces.exporter=none\notel.metric.export.interval=3000"),
- "META-INF/microprofile-config.properties")
- .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
- }
+public class JvmMemoryTest extends BaseMetricsTest {
@Test
void testJvmMemoryUsedMetric() throws IOException {
- MetricsReader.assertLogMessage("jvm.memory.used", "Measure of memory used.", "By",
- MetricDataType.LONG_SUM.toString());
+ assertMetric("jvm.memory.used", MetricDataType.LONG_SUM,
+ "Measure of memory used.", "By");
}
@Test
void testJvmMemoryCommittedMetric() throws IOException {
- MetricsReader.assertLogMessage("jvm.memory.committed", "Measure of memory committed.", "By",
- MetricDataType.LONG_SUM.toString());
+ assertMetric("jvm.memory.committed", MetricDataType.LONG_SUM,
+ "Measure of memory committed.", "By");
}
@Test
void testMemoryLimitMetric() throws IOException {
- MetricsReader.assertLogMessage("jvm.memory.limit", "Measure of max obtainable memory.", "By",
- MetricDataType.LONG_SUM.toString());
+ assertMetric("jvm.memory.limit", MetricDataType.LONG_SUM,
+ "Measure of max obtainable memory.", "By");
}
@Test
void testMemoryUsedAfterLastGcMetric() throws IOException {
- MetricsReader.assertLogMessage("jvm.memory.used_after_last_gc",
+ assertMetric("jvm.memory.used_after_last_gc", MetricDataType.LONG_SUM,
"Measure of memory used, as measured after the most recent garbage collection event on this pool.",
- "By",
- MetricDataType.LONG_SUM.toString());
+ "By");
}
}
diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/jvm/JvmThreadTest.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/jvm/JvmThreadTest.java
index 1d265910..ec404600 100644
--- a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/jvm/JvmThreadTest.java
+++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/jvm/JvmThreadTest.java
@@ -23,42 +23,16 @@
import java.io.IOException;
-import org.eclipse.microprofile.telemetry.metrics.tck.application.TestLibraries;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.testng.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.asset.EmptyAsset;
-import org.jboss.shrinkwrap.api.asset.StringAsset;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.eclipse.microprofile.telemetry.metrics.tck.shared.BaseMetricsTest;
import org.testng.annotations.Test;
-import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.sdk.metrics.data.MetricDataType;
-import jakarta.inject.Inject;
-
-public class JvmThreadTest extends Arquillian {
-
- @Inject
- OpenTelemetry openTelemetry;
-
- @Deployment
- public static WebArchive createTestArchive() {
- return ShrinkWrap.create(WebArchive.class)
- .addClasses(MetricsReader.class)
- .addAsLibrary(TestLibraries.AWAITILITY_LIB)
- .addAsLibrary(TestLibraries.COMMONS_IO_LIB)
- .addAsResource(
- new StringAsset(
- "otel.sdk.disabled=false\notel.metrics.exporter=logging\notel.logs.exporter=none\notel.traces.exporter=none\notel.metric.export.interval=3000"),
- "META-INF/microprofile-config.properties")
- .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
- }
+public class JvmThreadTest extends BaseMetricsTest {
@Test
void testThreadCountMetric() throws IOException {
- MetricsReader.assertLogMessagePattern(
- "name=jvm\\.thread\\.count, description=Number of executing(.*) threads(.*), unit=\\{thread\\}, type=" +
- MetricDataType.LONG_SUM.toString());
+ assertMetric("jvm.thread.count", MetricDataType.LONG_SUM,
+ "Number of executing", "{thread}");
}
}
diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/jvm/MetricsReader.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/jvm/MetricsReader.java
deleted file mode 100644
index 5305c097..00000000
--- a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/jvm/MetricsReader.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- **********************************************************************
- * Copyright (c) 2024 Contributors to the Eclipse Foundation
- *
- * See the NOTICES file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * Licensed 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.
- *
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-package org.eclipse.microprofile.telemetry.metrics.tck.jvm;
-
-import static java.util.concurrent.TimeUnit.SECONDS;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.commons.io.input.Tailer;
-import org.apache.commons.io.input.TailerListenerAdapter;
-import org.awaitility.Awaitility;
-import org.testng.Assert;
-
-public class MetricsReader {
-
- private static final String logFilePath = System.getProperty("mptelemetry.tck.log.file.path");
-
- /**
- * This method asserts that a log line matching the following format
- *
- * "name=, description=, unit=, type="
- *
- * Can be found in the log file pointed to by the system property mptelemetry.tck.log.file.path. It will wait for up
- * to fifteen seconds for the log to appear.
- *
- * @param metricName
- * The name of the metric we expect to find in the logs
- * @param metricDescription
- * The description of the metric we expect to find in the logs
- * @param metricUnit
- * The unit of the metric we expect to find in the logs
- * @param metricType
- * The type of the metric we expect to find in the logs
- */
- public static void assertLogMessage(String metricName, String metricDescription, String metricUnit,
- String metricType) {
-
- String searchString = "name=" + metricName + ", description=" + metricDescription + ", unit=" + metricUnit
- + ", type=" + metricType;
-
- ExecutorService es = Executors.newFixedThreadPool(1);
-
- LogFileTailerAdaptor logFileTailerAdaptor =
- new LogFileTailerAdaptor(searchString);
-
- Tailer tailer = Tailer.builder()
- .setStartThread(true)
- .setPath(logFilePath)
- .setExecutorService(es)
- .setReOpen(false)
- .setTailerListener(logFileTailerAdaptor)
- .setTailFromEnd(false)
- .get();
-
- try (tailer) {
- Awaitility.await().atMost(15, SECONDS)
- .untilAsserted(() -> Assert.assertTrue(logFileTailerAdaptor.foundMetric(),
- "Did not find " + searchString + " in logfile: " + logFilePath));
- }
- }
-
- /**
- * This method asserts that a log line matching the following format
- *
- * "searchPattern="
- *
- * Can be found in the log file pointed to by the system property mptelemetry.tck.log.file.path. It will wait for up
- * to fifteen seconds for the log to appear.
- *
- * @param searchPattern
- * The pattern to search for in the log file
- */
- public static void assertLogMessagePattern(String searchPattern) {
-
- ExecutorService es = Executors.newFixedThreadPool(1);
-
- LogFileTailerMatcherAdaptor logFileTailerAdaptor =
- new LogFileTailerMatcherAdaptor(searchPattern);
-
- Tailer tailer = Tailer.builder()
- .setStartThread(true)
- .setPath(logFilePath)
- .setExecutorService(es)
- .setReOpen(false)
- .setTailerListener(logFileTailerAdaptor)
- .setTailFromEnd(false)
- .get();
-
- try (tailer) {
- Awaitility.await().atMost(15, SECONDS)
- .untilAsserted(() -> Assert.assertTrue(logFileTailerAdaptor.foundMetric(),
- "Did not find " + searchPattern + " in logfile: " + logFilePath));
- }
- }
-
- private static class LogFileTailerAdaptor extends TailerListenerAdapter {
-
- private final String searchString;
- private boolean foundMetric = false;
- private Tailer tailer = null;
-
- public LogFileTailerAdaptor(String searchString) {
- this.searchString = searchString;
- }
-
- public void init(Tailer tailer) {
- this.tailer = tailer;
- }
-
- public void handle(String line) {
- if (line.contains(searchString)) {
- foundMetric = true;
- tailer.close();
- }
- }
-
- public boolean foundMetric() {
- return foundMetric;
- }
- }
-
- private static class LogFileTailerMatcherAdaptor extends TailerListenerAdapter {
-
- private final Pattern pattern;
- private boolean foundMetric = false;
- private Tailer tailer = null;
-
- public LogFileTailerMatcherAdaptor(String searchString) {
- this.pattern = Pattern.compile(searchString);
- }
-
- public void init(Tailer tailer) {
- this.tailer = tailer;
- }
-
- public void handle(String line) {
- Matcher matcher = pattern.matcher(line);
- if (matcher.find()) {
- foundMetric = true;
- tailer.close();
- }
- }
-
- public boolean foundMetric() {
- return foundMetric;
- }
- }
-
-}
diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/shared/BaseMetricsTest.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/shared/BaseMetricsTest.java
new file mode 100644
index 00000000..eea89fad
--- /dev/null
+++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/shared/BaseMetricsTest.java
@@ -0,0 +1,83 @@
+/*
+ **********************************************************************
+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICES file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * Licensed 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+package org.eclipse.microprofile.telemetry.metrics.tck.shared;
+
+import org.eclipse.microprofile.telemetry.metrics.tck.exporter.InMemoryMetricExporter;
+import org.eclipse.microprofile.telemetry.metrics.tck.exporter.InMemoryMetricExporterProvider;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.testng.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+
+import io.opentelemetry.api.metrics.Meter;
+import io.opentelemetry.sdk.autoconfigure.spi.metrics.ConfigurableMetricExporterProvider;
+import io.opentelemetry.sdk.metrics.data.MetricData;
+import io.opentelemetry.sdk.metrics.data.MetricDataType;
+import jakarta.inject.Inject;
+
+public class BaseMetricsTest extends Arquillian {
+ @Inject
+ protected Meter sdkMeter;
+
+ @Inject
+ protected InMemoryMetricExporter metricExporter;
+
+ @Deployment
+ public static WebArchive createTestArchive() {
+ return ShrinkWrap.create(WebArchive.class)
+ .addClasses(BaseMetricsTest.class,
+ BasicHttpClient.class,
+ TestUtils.class,
+ InMemoryMetricExporter.class,
+ InMemoryMetricExporterProvider.class)
+ .addAsLibrary(TestLibraries.AWAITILITY_LIB)
+ .addAsServiceProvider(ConfigurableMetricExporterProvider.class, InMemoryMetricExporterProvider.class)
+ .addAsResource(new StringAsset(
+ "otel.sdk.disabled=false\notel.metrics.exporter=in-memory\notel.logs.exporter=none\notel.traces.exporter=none\n"
+ +
+ "otel.metric.export.interval=3000"),
+ "META-INF/microprofile-config.properties")
+ .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+ }
+
+ @BeforeMethod
+ void setUp() {
+ if (metricExporter != null) {
+ metricExporter.reset();
+ }
+ }
+
+ protected MetricData assertMetric(String name, MetricDataType type, String description, String unit) {
+ MetricData metric = metricExporter.getMetricData(name).get(0);
+
+ Assert.assertEquals(metric.getType(), type);
+ Assert.assertTrue(metric.getDescription().contains(description));
+ Assert.assertEquals(metric.getUnit(), unit);
+
+ return metric;
+ }
+
+}
diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/BasicHttpClient.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/shared/BasicHttpClient.java
similarity index 98%
rename from tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/BasicHttpClient.java
rename to tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/shared/BasicHttpClient.java
index 87db538d..d1cc1b3e 100644
--- a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/BasicHttpClient.java
+++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/shared/BasicHttpClient.java
@@ -17,7 +17,7 @@
* limitations under the License.
*
*/
-package org.eclipse.microprofile.telemetry.metrics.tck.application;
+package org.eclipse.microprofile.telemetry.metrics.tck.shared;
import java.io.BufferedReader;
import java.io.InputStreamReader;
@@ -108,4 +108,4 @@ public String getResponseMessage(String path) {
}
}
-}
\ No newline at end of file
+}
diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/ConfigAsset.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/shared/ConfigAsset.java
similarity index 96%
rename from tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/ConfigAsset.java
rename to tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/shared/ConfigAsset.java
index be0dda19..f488056b 100644
--- a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/ConfigAsset.java
+++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/shared/ConfigAsset.java
@@ -17,7 +17,7 @@
* limitations under the License.
*
*/
-package org.eclipse.microprofile.telemetry.metrics.tck.application;
+package org.eclipse.microprofile.telemetry.metrics.tck.shared;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/TestLibraries.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/shared/TestLibraries.java
similarity index 82%
rename from tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/TestLibraries.java
rename to tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/shared/TestLibraries.java
index 5f8b0752..4a94ada1 100644
--- a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/TestLibraries.java
+++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/shared/TestLibraries.java
@@ -17,7 +17,7 @@
* limitations under the License.
*
*/
-package org.eclipse.microprofile.telemetry.metrics.tck.application;
+package org.eclipse.microprofile.telemetry.metrics.tck.shared;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
@@ -27,9 +27,6 @@ public class TestLibraries {
public static final JavaArchive AWAITILITY_LIB = ShrinkWrap.create(JavaArchive.class, "awaitility.jar")
.addPackages(true, "org.awaitility", "org.hamcrest");
- public static final JavaArchive COMMONS_IO_LIB = ShrinkWrap.create(JavaArchive.class, "commons-io.jar")
- .addPackages(true, "org.apache.commons");
-
private TestLibraries() {
}
}
diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/TestUtils.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/shared/TestUtils.java
similarity index 92%
rename from tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/TestUtils.java
rename to tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/shared/TestUtils.java
index a9ad10fb..fc517aee 100644
--- a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/TestUtils.java
+++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/shared/TestUtils.java
@@ -17,7 +17,7 @@
* limitations under the License.
*
*/
-package org.eclipse.microprofile.telemetry.metrics.tck.application;
+package org.eclipse.microprofile.telemetry.metrics.tck.shared;
import java.util.Map;
import java.util.stream.Collectors;
@@ -25,6 +25,8 @@
import io.opentelemetry.api.common.AttributeKey;
public class TestUtils {
+ private TestUtils() {
+ }
public static String mapToString(Map, ?> map) {
return (String) map.keySet().stream()
diff --git a/tck/pom.xml b/tck/pom.xml
index 4a60775e..f1d54cba 100644
--- a/tck/pom.xml
+++ b/tck/pom.xml
@@ -19,11 +19,11 @@
org.eclipse.microprofile.telemetry
microprofile-telemetry-parent
- 2.1-SNAPSHOT
+ 2.0.2-SNAPSHOT
-
+
microprofile-telemetry-tck-parent
- 2.1-SNAPSHOT
+ 2.0.2-SNAPSHOT
pom
MicroProfile Telemetry TCK
diff --git a/tck/tracing/pom.xml b/tck/tracing/pom.xml
index 13b40673..69f5d280 100644
--- a/tck/tracing/pom.xml
+++ b/tck/tracing/pom.xml
@@ -19,7 +19,7 @@
org.eclipse.microprofile.telemetry
microprofile-telemetry-tck-parent
- 2.1-SNAPSHOT
+ 2.0.2-SNAPSHOT
microprofile-telemetry-tracing-tck
@@ -33,7 +33,7 @@
org.eclipse.microprofile.rest.client
microprofile-rest-client-api
-
+
jakarta.enterprise
jakarta.enterprise.cdi-api
@@ -81,8 +81,8 @@
org.awaitility
awaitility
-
+
-
+