From 0a8ed04b6336ceb08a7d3023ee0b0b6db98071bd Mon Sep 17 00:00:00 2001 From: yasmin-aumeeruddy Date: Mon, 15 Jan 2024 10:25:24 +0000 Subject: [PATCH] Test meter injection and required metrics in tck --- pom.xml | 2 +- tck/metrics/pom.xml | 6 +- .../telemetry/metrics/tck/ConfigAsset.java | 53 ++++++++ .../telemetry/metrics/tck/TestLibraries.java | 32 +++++ .../metrics/tck/cdi/DoubleCounterTest.java | 100 ++++++++++++++ .../metrics/tck/cdi/DoubleGaugeTest.java | 99 ++++++++++++++ .../metrics/tck/cdi/DoubleHistogramTest.java | 98 ++++++++++++++ .../tck/cdi/DoubleUpDownCounterTest.java | 101 ++++++++++++++ .../metrics/tck/cdi/LongCounterTest.java | 101 ++++++++++++++ .../metrics/tck/cdi/LongGaugeTest.java | 100 ++++++++++++++ .../metrics/tck/cdi/LongHistogramTest.java | 100 ++++++++++++++ .../tck/cdi/LongUpDownCounterTest.java | 100 ++++++++++++++ .../tck/exporter/InMemoryMetricExporter.java | 126 ++++++++++++++++++ .../InMemoryMetricExporterProvider.java | 37 +++++ tck/tracing/pom.xml | 3 +- .../tck/async/JaxRsClientAsyncTest.java | 1 + .../tck/async/JaxRsServerAsyncTest.java | 1 + .../tck/async/MpRestClientAsyncTest.java | 1 + .../tck/rest/JaegerPropagationTest.java | 2 +- .../tracing/tck/rest/PropagatorSpiTest.java | 2 +- .../tck/rest/RestClientSpanDefaultTest.java | 2 +- .../tck/rest/RestClientSpanDisabledTest.java | 4 +- .../tracing/tck/rest/RestClientSpanTest.java | 4 +- .../tracing/tck/rest/RestSpanDefaultTest.java | 2 +- .../tck/rest/RestSpanDisabledTest.java | 4 +- .../tracing/tck/rest/RestSpanTest.java | 1 + 26 files changed, 1071 insertions(+), 11 deletions(-) create mode 100644 tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/ConfigAsset.java create mode 100644 tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/TestLibraries.java create mode 100644 tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/DoubleCounterTest.java create mode 100644 tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/DoubleGaugeTest.java create mode 100644 tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/DoubleHistogramTest.java create mode 100644 tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/DoubleUpDownCounterTest.java create mode 100644 tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/LongCounterTest.java create mode 100644 tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/LongGaugeTest.java create mode 100644 tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/LongHistogramTest.java create mode 100644 tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/LongUpDownCounterTest.java create mode 100644 tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/exporter/InMemoryMetricExporter.java create mode 100644 tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/exporter/InMemoryMetricExporterProvider.java 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/tck/metrics/pom.xml b/tck/metrics/pom.xml index 30e6397b..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 @@ -62,6 +66,7 @@ io.opentelemetry opentelemetry-semconv + 1.30.1-alpha org.testng @@ -88,7 +93,6 @@ awaitility ${version.awaitility} - diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/ConfigAsset.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/ConfigAsset.java new file mode 100644 index 00000000..7555689f --- /dev/null +++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/ConfigAsset.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2022-2023 Contributors to the Eclipse Foundation + * + * See the NOTICE 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. + * + */ +package org.eclipse.microprofile.telemetry.metrics.tck; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +import org.jboss.shrinkwrap.api.asset.Asset; + +public class ConfigAsset implements Asset { + + public static final String SDK_DISABLED = "otel.sdk.disabled"; + + private Properties properties = new Properties(); + + @Override + public InputStream openStream() { + try { + ByteArrayOutputStream os = new ByteArrayOutputStream(); + properties.store(os, null); + return new ByteArrayInputStream(os.toByteArray()); + } catch (IOException e) { + // Shouldn't happen since we're only using in memory streams + throw new RuntimeException("Unexpected error saving properties", e); + } + } + + public ConfigAsset add(String key, String value) { + properties.put(key, value); + return this; + } + +} diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/TestLibraries.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/TestLibraries.java new file mode 100644 index 00000000..86bf368d --- /dev/null +++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/TestLibraries.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Contributors to the Eclipse Foundation + * + * See the NOTICE 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. + * + */ +package org.eclipse.microprofile.telemetry.metrics.tck; + +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.spec.JavaArchive; + +public class TestLibraries { + + public static final JavaArchive AWAITILITY_LIB = ShrinkWrap.create(JavaArchive.class, "awaitility.jar") + .addPackages(true, "org.awaitility", "org.hamcrest"); + + private TestLibraries() { + } +} 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..bc9fa309 --- /dev/null +++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/LongGaugeTest.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.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) + .ofLongs() + .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/exporter/InMemoryMetricExporter.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/exporter/InMemoryMetricExporter.java new file mode 100644 index 00000000..bb3bb14d --- /dev/null +++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/exporter/InMemoryMetricExporter.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2024 Contributors to the Eclipse Foundation + * + * See the NOTICE 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. + * + */ + +package org.eclipse.microprofile.telemetry.metrics.tck.exporter; + +import static java.util.concurrent.TimeUnit.SECONDS; + +import java.util.Collection; +import java.util.List; +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 jakarta.enterprise.context.ApplicationScoped; + +@ApplicationScoped +public class InMemoryMetricExporter implements MetricExporter { + + private final Queue finishedMetricItems = new ConcurrentLinkedQueue<>(); + private final AggregationTemporality aggregationTemporality; + private boolean isStopped = false; + + public InMemoryMetricExporter() { + aggregationTemporality = AggregationTemporality.DELTA; + } + + /** + * Returns a {@code List} of the finished {@code Metric}s, represented by {@code MetricData}. + * + * @return a {@code List} of the finished {@code Metric}s. + */ + 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)); + } + + /** + * Clears the internal {@code List} of finished {@code Metric}s. + * + *

+ * Does not reset the state of this exporter if already shutdown. + */ + public void reset() { + finishedMetricItems.clear(); + } + + @Override + public AggregationTemporality getAggregationTemporality(InstrumentType instrumentType) { + return aggregationTemporality; + } + + /** + * Exports the collection of {@code Metric}s into the inmemory queue. + * + *

+ * If this is called after {@code shutdown}, this will return {@code ResultCode.FAILURE}. + */ + @Override + public CompletableResultCode export(Collection metrics) { + if (isStopped) { + return CompletableResultCode.ofFailure(); + } + finishedMetricItems.addAll(metrics); + return CompletableResultCode.ofSuccess(); + } + + /** + * The InMemory exporter does not batch metrics, so this method will immediately return with success. + * + * @return always Success + */ + @Override + public CompletableResultCode flush() { + return CompletableResultCode.ofSuccess(); + } + /** + * Clears the internal {@code List} of finished {@code Metric}s. + * + *

+ * Any subsequent call to export() function on this MetricExporter, will return {@code + * CompletableResultCode.ofFailure()} + */ + @Override + public CompletableResultCode shutdown() { + isStopped = true; + finishedMetricItems.clear(); + return CompletableResultCode.ofSuccess(); + } +} diff --git a/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/exporter/InMemoryMetricExporterProvider.java b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/exporter/InMemoryMetricExporterProvider.java new file mode 100644 index 00000000..95e1cf95 --- /dev/null +++ b/tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/exporter/InMemoryMetricExporterProvider.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 Contributors to the Eclipse Foundation + * + * See the NOTICE 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. + * + */ +package org.eclipse.microprofile.telemetry.metrics.tck.exporter; + +import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; +import io.opentelemetry.sdk.autoconfigure.spi.metrics.ConfigurableMetricExporterProvider; +import io.opentelemetry.sdk.metrics.export.MetricExporter; +import jakarta.enterprise.inject.spi.CDI; + +public class InMemoryMetricExporterProvider implements ConfigurableMetricExporterProvider { + @Override + public MetricExporter createExporter(final ConfigProperties config) { + return CDI.current().select(InMemoryMetricExporter.class).get(); + } + + @Override + public String getName() { + return "in-memory"; + } +} diff --git a/tck/tracing/pom.xml b/tck/tracing/pom.xml index 9bab5487..081b7c7b 100644 --- a/tck/tracing/pom.xml +++ b/tck/tracing/pom.xml @@ -25,8 +25,6 @@ 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)