Skip to content

Commit

Permalink
Test metrc attributes in tck
Browse files Browse the repository at this point in the history
  • Loading branch information
yasmin-aumeeruddy committed Feb 26, 2024
1 parent 96ade9b commit a7f705f
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
**********************************************************************/
package org.eclipse.microprofile.telemetry.metrics.tck.cdi;

import java.util.List;

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;
Expand All @@ -34,6 +36,7 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.metrics.LongHistogram;
import io.opentelemetry.api.metrics.Meter;
import io.opentelemetry.sdk.autoconfigure.spi.metrics.ConfigurableMetricExporterProvider;
Expand All @@ -47,8 +50,8 @@ public class LongHistogramTest extends Arquillian {
private static final String histogramDescription = "Testing long histogram";
private static final String histogramUnit = "Metric Tonnes";

private static final double DOUBLE_WITH_ATTRIBUTES = 20;
private static final double DOUBLE_WITHOUT_ATTRIBUTES = 10;
private static final long LONG_WITH_ATTRIBUTES = 20;
private static final long LONG_WITHOUT_ATTRIBUTES = 10;

@Deployment
public static WebArchive createTestArchive() {
Expand Down Expand Up @@ -86,8 +89,11 @@ void testLongHistogram() throws InterruptedException {
.setUnit(histogramUnit)
.build();
Assert.assertNotNull(longHistogram);
longHistogram.record(10, Attributes.empty());
longHistogram.record(10, Attributes.builder().put("K", "V").build());
longHistogram.record(LONG_WITH_ATTRIBUTES, Attributes.empty());
longHistogram.record(LONG_WITHOUT_ATTRIBUTES, Attributes.builder().put("K", "V").build());

List<MetricData> metrics = metricExporter.getMetricData((MetricDataType.DOUBLE_SUM));

MetricData metric = metricExporter.getMetricData((MetricDataType.HISTOGRAM)).get(0);
Assert.assertEquals(metric.getName(), histogramName);
Assert.assertEquals(metric.getDescription(), histogramDescription);
Expand Down

0 comments on commit a7f705f

Please sign in to comment.