Add AgentForTestingTest.exportAndRetrieveMetrics() (#13414)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Jean Bisutti <jean.bisutti@gmail.com> Co-authored-by: Steve Rao <raozihao.rzh@alibaba-inc.com> Co-authored-by: Lauri Tulmin <tulmin@gmail.com> Co-authored-by: Lauri Tulmin <ltulmin@splunk.com> Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com> Co-authored-by: otelbot[bot] <197425009+otelbot[bot]@users.noreply.github.com> Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com>
This commit is contained in:
parent
a10eeaea20
commit
f2d0e15555
|
@ -9,6 +9,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||
|
||||
import io.opentelemetry.api.GlobalOpenTelemetry;
|
||||
import io.opentelemetry.javaagent.testing.common.AgentTestingExporterAccess;
|
||||
import io.opentelemetry.sdk.metrics.data.MetricData;
|
||||
import io.opentelemetry.sdk.trace.data.SpanData;
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
@ -27,11 +28,20 @@ class AgentForTestingTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void exportAndRetrieve() {
|
||||
void exportAndRetrieveSpans() {
|
||||
GlobalOpenTelemetry.getTracer("test").spanBuilder("test").startSpan().end();
|
||||
|
||||
List<SpanData> spans = AgentTestingExporterAccess.getExportedSpans();
|
||||
assertEquals(1, spans.size());
|
||||
assertEquals("test", spans.get(0).getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void exportAndRetrieveMetrics() {
|
||||
GlobalOpenTelemetry.getMeter("test").upDownCounterBuilder("test").build().add(1);
|
||||
|
||||
List<MetricData> metrics = AgentTestingExporterAccess.getExportedMetrics();
|
||||
assertEquals(1, metrics.size());
|
||||
assertEquals("test", metrics.get(0).getName());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue