diff --git a/pom.xml b/pom.xml index e83a53b6..e3c3ea65 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ 2022 - 1.29.0 + 1.32.0 3.0.1 3.1 4.2.0 diff --git a/spec/pom.xml b/spec/pom.xml index 51e1692b..f70b2fc4 100644 --- a/spec/pom.xml +++ b/spec/pom.xml @@ -19,7 +19,7 @@ org.eclipse.microprofile.telemetry microprofile-telemetry-parent - 1.2-SNAPSHOT + 2.0-SNAPSHOT microprofile-telemetry-spec diff --git a/tck/metrics/pom.xml b/tck/metrics/pom.xml index ae89992c..d0263b3f 100644 --- a/tck/metrics/pom.xml +++ b/tck/metrics/pom.xml @@ -45,6 +45,10 @@ io.opentelemetry opentelemetry-sdk + + + io.opentelemetry + opentelemetry-sdk-common io.opentelemetry @@ -89,12 +93,6 @@ awaitility ${version.awaitility} - - - org.eclipse.microprofile.telemetry - microprofile-telemetry-tracing-tck - 1.2-SNAPSHOT - diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/DoubleCounterTest.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/DoubleCounterTest.java new file mode 100644 index 00000000..b7339cfb --- /dev/null +++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/DoubleCounterTest.java @@ -0,0 +1,100 @@ +/* + ********************************************************************** + * 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.cdi; + +import org.eclipse.microprofile.telemetry.metrics.tck.TestLibraries; +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 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"; + + @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.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 { + DoubleCounter doubleCounter = + sdkMeter + .counterBuilder(counterName) + .ofDoubles() + .setDescription(counterDescription) + .setUnit(counterUnit) + .build(); + Assert.assertNotNull(doubleCounter); + doubleCounter.add(10.1, Attributes.empty()); + MetricData metric = metricExporter.getMetricData((MetricDataType.DOUBLE_SUM)); + Assert.assertEquals(metric.getName(), counterName); + Assert.assertEquals(metric.getDescription(), counterDescription); + Assert.assertEquals(metric.getUnit(), counterUnit); + + Assert.assertEquals(metric.getDoubleSumData() + .getPoints() + .stream() + .findFirst() + .get() + .getValue(), 10.1); + } + +} diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/DoubleGaugeTest.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/DoubleGaugeTest.java new file mode 100644 index 00000000..67d934d8 --- /dev/null +++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/DoubleGaugeTest.java @@ -0,0 +1,99 @@ +/* + ********************************************************************** + * 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.cdi; + +import org.eclipse.microprofile.telemetry.metrics.tck.TestLibraries; +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 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.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 testDoubleGauge() throws InterruptedException { + Assert.assertNotNull( + sdkMeter + .gaugeBuilder(gaugeName) + .setDescription(gaugeDescription) + .setUnit("ms") + .buildWithCallback(measurement -> { + measurement.record(1, Attributes.empty()); + })); + + MetricData metric = metricExporter.getMetricData((MetricDataType.DOUBLE_GAUGE)); + Assert.assertEquals(metric.getName(), gaugeName); + Assert.assertEquals(metric.getDescription(), gaugeDescription); + Assert.assertEquals(metric.getUnit(), gaugeUnit); + + Assert.assertEquals(metric.getDoubleGaugeData() + .getPoints() + .stream() + .findFirst() + .get() + .getValue(), 1); + } + +} diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/DoubleHistogramTest.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/DoubleHistogramTest.java new file mode 100644 index 00000000..575105bb --- /dev/null +++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/DoubleHistogramTest.java @@ -0,0 +1,98 @@ +/* + ********************************************************************** + * 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.cdi; + +import org.eclipse.microprofile.telemetry.metrics.tck.TestLibraries; +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 org.testng.annotations.Test; + +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 { + + private static final String histogramName = "testDoubleHistogram"; + private static final String histogramDescription = "Testing double histogram"; + private static final String histogramUnit = "Metric Tonnes"; + + @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.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 { + DoubleHistogram doubleHistogram = + sdkMeter + .histogramBuilder(histogramName) + .setDescription(histogramDescription) + .setUnit(histogramUnit) + .build(); + Assert.assertNotNull(doubleHistogram); + doubleHistogram.record(10); + MetricData metric = metricExporter.getMetricData((MetricDataType.HISTOGRAM)); + Assert.assertEquals(metric.getName(), histogramName); + Assert.assertEquals(metric.getDescription(), histogramDescription); + Assert.assertEquals(metric.getUnit(), histogramUnit); + + Assert.assertEquals(metric.getHistogramData() + .getPoints() + .stream() + .findFirst() + .get() + .getSum(), 10); + } +} diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/DoubleUpDownCounterTest.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/DoubleUpDownCounterTest.java new file mode 100644 index 00000000..f882c07d --- /dev/null +++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/DoubleUpDownCounterTest.java @@ -0,0 +1,101 @@ +/* + ********************************************************************** + * 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.cdi; + +import org.eclipse.microprofile.telemetry.metrics.tck.TestLibraries; +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 org.testng.annotations.Test; + +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 { + + private static final String counterName = "testDoubleUpDownCounter"; + private static final String counterDescription = "Testing double up down counter"; + private static final String counterUnit = "Metric Tonnes"; + + @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.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 { + DoubleUpDownCounter doubleUpDownCounter = + sdkMeter + .upDownCounterBuilder(counterName) + .ofDoubles() + .setDescription(counterDescription) + .setUnit(counterUnit) + .build(); + Assert.assertNotNull(doubleUpDownCounter); + doubleUpDownCounter.add(-10); + + MetricData metric = metricExporter.getMetricData((MetricDataType.DOUBLE_SUM)); + Assert.assertEquals(metric.getName(), counterName); + Assert.assertEquals(metric.getDescription(), counterDescription); + Assert.assertEquals(metric.getUnit(), counterUnit); + + Assert.assertEquals(metric.getDoubleSumData() + .getPoints() + .stream() + .findFirst() + .get() + .getValue(), -10); + } + +} diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/LongCounterTest.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/LongCounterTest.java new file mode 100644 index 00000000..be56f8c9 --- /dev/null +++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/LongCounterTest.java @@ -0,0 +1,101 @@ +/* + ********************************************************************** + * 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.cdi; + +import org.eclipse.microprofile.telemetry.metrics.tck.TestLibraries; +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 org.testng.annotations.Test; + +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 { + + private static final String counterName = "testLongCounter"; + private static final String counterDescription = "Testing long counter"; + private static final String counterUnit = "Metric Tonnes"; + + @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.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 { + LongCounter longCounter = + sdkMeter + .counterBuilder(counterName) + .setDescription(counterDescription) + .setUnit(counterUnit) + .build(); + Assert.assertNotNull(longCounter); + longCounter.add(12); + longCounter.add(12); + + MetricData metric = metricExporter.getMetricData((MetricDataType.LONG_SUM)); + Assert.assertEquals(metric.getName(), counterName); + Assert.assertEquals(metric.getDescription(), counterDescription); + Assert.assertEquals(metric.getUnit(), counterUnit); + + Assert.assertEquals(metric.getLongSumData() + .getPoints() + .stream() + .findFirst() + .get() + .getValue(), 24); + } + +} diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/LongGaugeTest.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/LongGaugeTest.java new file mode 100644 index 00000000..38ac7a06 --- /dev/null +++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/LongGaugeTest.java @@ -0,0 +1,99 @@ +/* + ********************************************************************** + * 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.cdi; + +import org.eclipse.microprofile.telemetry.metrics.tck.TestLibraries; +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 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.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 testLongGauge() throws InterruptedException { + Assert.assertNotNull( + sdkMeter + .gaugeBuilder(gaugeName) + .setDescription(gaugeDescription) + .setUnit("ms") + .buildWithCallback(measurement -> { + measurement.record(1, Attributes.empty()); + })); + + MetricData metric = metricExporter.getMetricData((MetricDataType.LONG_GAUGE)); + Assert.assertEquals(metric.getName(), gaugeName); + Assert.assertEquals(metric.getDescription(), gaugeDescription); + Assert.assertEquals(metric.getUnit(), gaugeUnit); + + Assert.assertEquals(metric.getLongGaugeData() + .getPoints() + .stream() + .findFirst() + .get() + .getValue(), 1); + } + +} diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/LongHistogramTest.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/LongHistogramTest.java new file mode 100644 index 00000000..d42313a4 --- /dev/null +++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/LongHistogramTest.java @@ -0,0 +1,100 @@ +/* + ********************************************************************** + * 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.cdi; + +import org.eclipse.microprofile.telemetry.metrics.tck.TestLibraries; +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 org.testng.annotations.Test; + +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"; + + @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.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 { + LongHistogram longHistogram = + sdkMeter + .histogramBuilder(histogramName) + .ofLongs() + .setDescription(histogramDescription) + .setUnit(histogramUnit) + .build(); + Assert.assertNotNull(longHistogram); + longHistogram.record(10); + MetricData metric = metricExporter.getMetricData((MetricDataType.HISTOGRAM)); + Assert.assertEquals(metric.getName(), histogramName); + Assert.assertEquals(metric.getDescription(), histogramDescription); + Assert.assertEquals(metric.getUnit(), histogramUnit); + + Assert.assertEquals(metric.getHistogramData() + .getPoints() + .stream() + .findFirst() + .get() + .getSum(), 10); + } + +} diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/LongUpDownCounterTest.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/LongUpDownCounterTest.java new file mode 100644 index 00000000..b3cdd0f9 --- /dev/null +++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/LongUpDownCounterTest.java @@ -0,0 +1,100 @@ +/* + ********************************************************************** + * 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.cdi; + +import org.eclipse.microprofile.telemetry.metrics.tck.TestLibraries; +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 org.testng.annotations.Test; + +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"; + + @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.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 { + LongUpDownCounter longUpDownCounter = + sdkMeter + .upDownCounterBuilder(counterName) + .setDescription(counterDescription) + .setUnit(counterUnit) + .build(); + Assert.assertNotNull(longUpDownCounter); + longUpDownCounter.add(-10); + + MetricData metric = metricExporter.getMetricData((MetricDataType.LONG_SUM)); + Assert.assertEquals(metric.getName(), counterName); + Assert.assertEquals(metric.getDescription(), counterDescription); + Assert.assertEquals(metric.getUnit(), counterUnit); + + Assert.assertEquals(metric.getLongSumData() + .getPoints() + .stream() + .findFirst() + .get() + .getValue(), -10); + } + +} diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/MeterBeanTest.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/MeterBeanTest.java deleted file mode 100644 index 44b38a85..00000000 --- a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/MeterBeanTest.java +++ /dev/null @@ -1,71 +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.cdi; - -import org.eclipse.microprofile.telemetry.metrics.tck.ConfigAsset; -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.spec.WebArchive; -import org.testng.Assert; -import org.testng.annotations.Test; - -import io.opentelemetry.api.metrics.LongCounter; -import io.opentelemetry.api.metrics.Meter; -import jakarta.inject.Inject; - -public class MeterBeanTest extends Arquillian { - - @Deployment - public static WebArchive createTestArchive() { - ConfigAsset config = new ConfigAsset().add(ConfigAsset.SDK_DISABLED, "false"); - - return ShrinkWrap.create(WebArchive.class) - .addAsResource(EmptyAsset.INSTANCE, "META-INF/beans.xml") - .addAsResource(config, "META-INF/microprofile-config.properties"); - } - - @Inject - private Meter sdkMeter; - - @Test - void testLongCounter() { - LongCounter longCounter = - sdkMeter - .counterBuilder("testLongCounter") - .setDescription("My very own counter") - .setUnit("metric tonnes") - .build(); - Assert.assertNotNull(longCounter); - - // Note: We no longer get the same instrument instance as these instances are lightweight - /* - * objects backed by storage now. Here we just make sure it doesn't log a warning. sdkMeter - * .counterBuilder("testLongCounter") .setDescription("My very own counter") .setUnit("metric tonnes") .build(); - * assertThat(metricStorageLogs.getEvents()).isEmpty(); - * - * sdkMeter.counterBuilder("testLongCounter").build(); - * metricStorageLogs.assertContains("Found duplicate metric definition"); - */ - } -} diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/exporter/InMemoryMetricExporter.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/exporter/InMemoryMetricExporter.java index 43d65d0f..bb3bb14d 100644 --- a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/exporter/InMemoryMetricExporter.java +++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/exporter/InMemoryMetricExporter.java @@ -20,94 +20,107 @@ package org.eclipse.microprofile.telemetry.metrics.tck.exporter; -import static java.util.Comparator.comparingLong; import static java.util.concurrent.TimeUnit.SECONDS; -import static java.util.function.Predicate.not; import java.util.Collection; import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; +import java.util.Queue; +import java.util.concurrent.ConcurrentLinkedQueue; import java.util.stream.Collectors; import org.awaitility.Awaitility; import org.testng.Assert; import io.opentelemetry.sdk.common.CompletableResultCode; +import io.opentelemetry.sdk.metrics.InstrumentType; +import io.opentelemetry.sdk.metrics.data.AggregationTemporality; +import io.opentelemetry.sdk.metrics.data.MetricData; +import io.opentelemetry.sdk.metrics.data.MetricDataType; import io.opentelemetry.sdk.metrics.export.MetricExporter; -import io.opentelemetry.semconv.metrics.attributes.SemanticAttributes; import jakarta.enterprise.context.ApplicationScoped; @ApplicationScoped public class InMemoryMetricExporter implements MetricExporter { + + private final Queue finishedMetricItems = new ConcurrentLinkedQueue<>(); + private final AggregationTemporality aggregationTemporality; private boolean isStopped = false; - private final List finishedMetricItems = new CopyOnWriteArrayList<>(); + + public InMemoryMetricExporter() { + aggregationTemporality = AggregationTemporality.DELTA; + } /** - * Return the default aggregation for the {@link InstrumentType}. + * Returns a {@code List} of the finished {@code Metric}s, represented by {@code MetricData}. * - * @see DefaultAggregationSelector#getDefaultAggregation(InstrumentType) - * @since 1.16.0 + * @return a {@code List} of the finished {@code Metric}s. */ - @Override - default Aggregation getDefaultAggregation(InstrumentType instrumentType) { - return Aggregation.defaultAggregation(); + public List getFinishedMetricItems(int itemCount) { + assertItemCount(itemCount); + return finishedMetricItems.stream() + .collect(Collectors.toList()); + } + + public void assertItemCount(int itemCount) { + Awaitility.await().pollDelay(3, SECONDS).atMost(10, SECONDS) + .untilAsserted(() -> Assert.assertEquals(finishedMetricItems.size(), itemCount)); + } + + public MetricData getMetricData(MetricDataType dataType) { + return getFinishedMetricItems(1).stream().filter(metric -> metric.getType() == dataType).findFirst() + .orElseThrow(() -> new IllegalStateException("No metric found with type " + dataType)); } /** - * Returns the memory mode used by this exporter's associated reader. + * Clears the internal {@code List} of finished {@code Metric}s. * - * @return The {@link MemoryMode} used by this exporter's associated reader - * @since 1.31.0 + *

+ * Does not reset the state of this exporter if already shutdown. */ - default MemoryMode getMemoryMode() { - return IMMUTABLE_DATA; + public void reset() { + finishedMetricItems.clear(); + } + + @Override + public AggregationTemporality getAggregationTemporality(InstrumentType instrumentType) { + return aggregationTemporality; } /** - * Exports the {@code metrics}. The caller (i.e. {@link PeriodicMetricReader} will not call export until the - * previous call completes. + * Exports the collection of {@code Metric}s into the inmemory queue. * - * @param metrics - * the metrics to export. - * @return the result of the export, which is often an asynchronous operation. + *

+ * If this is called after {@code shutdown}, this will return {@code ResultCode.FAILURE}. */ @Override public CompletableResultCode export(Collection metrics) { if (isStopped) { return CompletableResultCode.ofFailure(); } - metrics.stream() - .filter(not(InMemoryMetricExporter::isArquillianMetric)) - .forEach(finishedMetricItems::add); + finishedMetricItems.addAll(metrics); return CompletableResultCode.ofSuccess(); } + /** - * A hint that any metrics previously {@link #export(Collection)}ed should be completed. + * The InMemory exporter does not batch metrics, so this method will immediately return with success. * - * @return the result of the flush, which is often an asynchronous operation. + * @return always Success */ @Override public CompletableResultCode flush() { return CompletableResultCode.ofSuccess(); } /** - * Shuts down the exporter. + * Clears the internal {@code List} of finished {@code Metric}s. * *

- * Called when {@link PeriodicMetricReader#shutdown()} of the associated reader is called. - * - * @return a {@link CompletableResultCode} which is completed when shutdown completes. + * Any subsequent call to export() function on this MetricExporter, will return {@code + * CompletableResultCode.ofFailure()} */ @Override public CompletableResultCode shutdown() { - finishedMetricItems.clear(); isStopped = true; + finishedMetricItems.clear(); return CompletableResultCode.ofSuccess(); } - - /** Closes this {@link MetricExporter}, releasing any resources. */ - @Override - default void close() { - shutdown().join(10, TimeUnit.SECONDS); - } } diff --git a/tck/pom.xml b/tck/pom.xml index 930914f0..b4add963 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -23,7 +23,7 @@ microprofile-telemetry-tck-parent - 1.2-SNAPSHOT + 2.0-SNAPSHOT pom MicroProfile Telemetry TCK diff --git a/tck/tracing/pom.xml b/tck/tracing/pom.xml index 9bab5487..5da1a3f6 100644 --- a/tck/tracing/pom.xml +++ b/tck/tracing/pom.xml @@ -19,14 +19,12 @@ org.eclipse.microprofile.telemetry microprofile-telemetry-tck-parent - 1.2-SNAPSHOT + 2.0-SNAPSHOT microprofile-telemetry-tracing-tck MicroProfile Telemetry Tracing TCK - - org.eclipse.microprofile.config @@ -64,6 +62,7 @@ io.opentelemetry opentelemetry-semconv + 1.30.1-alpha org.testng diff --git a/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/async/JaxRsClientAsyncTest.java b/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/async/JaxRsClientAsyncTest.java index 37912602..26e09d25 100644 --- a/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/async/JaxRsClientAsyncTest.java +++ b/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/async/JaxRsClientAsyncTest.java @@ -60,6 +60,7 @@ public static WebArchive createDeployment() { ConfigAsset config = new ConfigAsset() .add("otel.bsp.schedule.delay", "100") .add("otel.sdk.disabled", "false") + .add("otel.metrics.exporter", "none") .add("otel.traces.exporter", "in-memory"); return ShrinkWrap.create(WebArchive.class) diff --git a/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/async/JaxRsServerAsyncTest.java b/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/async/JaxRsServerAsyncTest.java index e3bce087..20f91d78 100644 --- a/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/async/JaxRsServerAsyncTest.java +++ b/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/async/JaxRsServerAsyncTest.java @@ -63,6 +63,7 @@ public static WebArchive createDeployment() { ConfigAsset config = new ConfigAsset() .add("otel.bsp.schedule.delay", "100") .add("otel.sdk.disabled", "false") + .add("otel.metrics.exporter", "none") .add("otel.traces.exporter", "in-memory"); return ShrinkWrap.create(WebArchive.class) diff --git a/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/async/MpRestClientAsyncTest.java b/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/async/MpRestClientAsyncTest.java index 4dea18ed..7c921274 100644 --- a/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/async/MpRestClientAsyncTest.java +++ b/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/async/MpRestClientAsyncTest.java @@ -60,6 +60,7 @@ public static WebArchive createDeployment() { ConfigAsset config = new ConfigAsset() .add("otel.bsp.schedule.delay", "100") .add("otel.sdk.disabled", "false") + .add("otel.metrics.exporter", "none") .add("otel.traces.exporter", "in-memory"); return ShrinkWrap.create(WebArchive.class) diff --git a/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/rest/JaegerPropagationTest.java b/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/rest/JaegerPropagationTest.java index 72bcc977..e15f2939 100644 --- a/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/rest/JaegerPropagationTest.java +++ b/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/rest/JaegerPropagationTest.java @@ -65,7 +65,7 @@ public static WebArchive createDeployment() { .addAsServiceProvider(ConfigurableSpanExporterProvider.class, InMemorySpanExporterProvider.class) .addAsResource( new StringAsset( - "otel.sdk.disabled=false\notel.traces.exporter=in-memory\notel.propagators=jaeger"), + "otel.sdk.disabled=false\notel.traces.exporter=in-memory\notel.metrics.exporter=none\notel.propagators=jaeger"), "META-INF/microprofile-config.properties") .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); } diff --git a/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/rest/PropagatorSpiTest.java b/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/rest/PropagatorSpiTest.java index 6f4dfd0e..fd519419 100644 --- a/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/rest/PropagatorSpiTest.java +++ b/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/rest/PropagatorSpiTest.java @@ -73,7 +73,7 @@ public static WebArchive createDeployment() { .addAsLibrary(TestLibraries.AWAITILITY_LIB) .addAsResource( new StringAsset("otel.sdk.disabled=false\notel.propagators=" + TestPropagatorProvider.NAME - + "\notel.traces.exporter=in-memory"), + + "\notel.traces.exporter=in-memory\notel.metrics.exporter=none"), "META-INF/microprofile-config.properties") .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); diff --git a/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/rest/RestClientSpanDefaultTest.java b/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/rest/RestClientSpanDefaultTest.java index a67dffc1..64f7d3f4 100644 --- a/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/rest/RestClientSpanDefaultTest.java +++ b/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/rest/RestClientSpanDefaultTest.java @@ -69,7 +69,7 @@ public static WebArchive createDeployment() { .addClasses(InMemorySpanExporter.class, InMemorySpanExporterProvider.class) .addAsLibrary(TestLibraries.AWAITILITY_LIB) .addAsServiceProvider(ConfigurableSpanExporterProvider.class, InMemorySpanExporterProvider.class) - .addAsResource(new StringAsset("otel.traces.exporter=in-memory"), + .addAsResource(new StringAsset("otel.traces.exporter=in-memory\notel.metrics.exporter=none"), "META-INF/microprofile-config.properties") .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); } diff --git a/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/rest/RestClientSpanDisabledTest.java b/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/rest/RestClientSpanDisabledTest.java index 3fb3de81..62b660e4 100644 --- a/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/rest/RestClientSpanDisabledTest.java +++ b/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/rest/RestClientSpanDisabledTest.java @@ -69,7 +69,9 @@ public static WebArchive createDeployment() { .addClasses(InMemorySpanExporter.class, InMemorySpanExporterProvider.class) .addAsLibrary(TestLibraries.AWAITILITY_LIB) .addAsServiceProvider(ConfigurableSpanExporterProvider.class, InMemorySpanExporterProvider.class) - .addAsResource(new StringAsset("otel.sdk.disabled=true\notel.traces.exporter=in-memory"), + .addAsResource( + new StringAsset( + "otel.sdk.disabled=true\notel.traces.exporter=in-memory\notel.metrics.exporter=none"), "META-INF/microprofile-config.properties") .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); } diff --git a/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/rest/RestClientSpanTest.java b/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/rest/RestClientSpanTest.java index a0f3e2e8..065aa654 100644 --- a/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/rest/RestClientSpanTest.java +++ b/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/rest/RestClientSpanTest.java @@ -88,7 +88,9 @@ public static WebArchive createDeployment() { .addClasses(InMemorySpanExporter.class, InMemorySpanExporterProvider.class) .addAsLibrary(TestLibraries.AWAITILITY_LIB) .addAsServiceProvider(ConfigurableSpanExporterProvider.class, InMemorySpanExporterProvider.class) - .addAsResource(new StringAsset("otel.sdk.disabled=false\notel.traces.exporter=in-memory"), + .addAsResource( + new StringAsset( + "otel.sdk.disabled=false\notel.traces.exporter=in-memory\notel.metrics.exporter=none"), "META-INF/microprofile-config.properties") .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); } diff --git a/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/rest/RestSpanDefaultTest.java b/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/rest/RestSpanDefaultTest.java index a020b55e..b0e7dd6a 100644 --- a/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/rest/RestSpanDefaultTest.java +++ b/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/rest/RestSpanDefaultTest.java @@ -55,7 +55,7 @@ public static WebArchive createDeployment() { .addClasses(InMemorySpanExporter.class, InMemorySpanExporterProvider.class, BasicHttpClient.class) .addAsLibrary(TestLibraries.AWAITILITY_LIB) .addAsServiceProvider(ConfigurableSpanExporterProvider.class, InMemorySpanExporterProvider.class) - .addAsResource(new StringAsset("otel.traces.exporter=in-memory"), + .addAsResource(new StringAsset("otel.traces.exporter=in-memory\notel.metrics.exporter=none"), "META-INF/microprofile-config.properties") .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); } diff --git a/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/rest/RestSpanDisabledTest.java b/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/rest/RestSpanDisabledTest.java index 557433e9..447562a5 100644 --- a/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/rest/RestSpanDisabledTest.java +++ b/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/rest/RestSpanDisabledTest.java @@ -55,7 +55,9 @@ public static WebArchive createDeployment() { .addClasses(InMemorySpanExporter.class, InMemorySpanExporterProvider.class, BasicHttpClient.class) .addAsLibrary(TestLibraries.AWAITILITY_LIB) .addAsServiceProvider(ConfigurableSpanExporterProvider.class, InMemorySpanExporterProvider.class) - .addAsResource(new StringAsset("otel.sdk.disabled=true\notel.traces.exporter=in-memory"), + .addAsResource( + new StringAsset( + "otel.sdk.disabled=true\notel.traces.exporter=in-memory\notel.metrics.exporter=none"), "META-INF/microprofile-config.properties") .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); } diff --git a/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/rest/RestSpanTest.java b/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/rest/RestSpanTest.java index dedb99c1..9e8c9f6c 100644 --- a/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/rest/RestSpanTest.java +++ b/tck/tracing/src/main/java/org/eclipse/microprofile/telemetry/tracing/tck/rest/RestSpanTest.java @@ -78,6 +78,7 @@ public static WebArchive createDeployment() { .add("otel.service.name", TEST_SERVICE_NAME) .add("otel.resource.attributes", SERVICE_VERSION.getKey() + "=" + TEST_SERVICE_VERSION) .add("otel.sdk.disabled", "false") + .add("otel.metrics.exporter", "none") .add("otel.traces.exporter", "in-memory"); return ShrinkWrap.create(WebArchive.class)