use of co.elastic.apm.api.Span in project apm-agent-java by elastic.
the class SpanInstrumentationTest method testScope.
@Test
void testScope() {
Span span = transaction.startSpan();
assertThat(ElasticApm.currentSpan().getId()).isNotEqualTo(span.getId());
try (final Scope scope = span.activate()) {
assertThat(ElasticApm.currentSpan().getId()).isEqualTo(span.getId());
ElasticApm.currentSpan().startSpan().end();
}
span.end();
transaction.end();
assertThat(reporter.getSpans()).hasSize(2);
assertThat(reporter.getTransactions()).hasSize(1);
assertThat(reporter.getSpans().get(0).isChildOf(reporter.getSpans().get(1))).isTrue();
assertThat(reporter.getSpans().get(1).isChildOf(reporter.getFirstTransaction())).isTrue();
}
use of co.elastic.apm.api.Span in project apm-agent-java by elastic.
the class SpanInstrumentationTest method testLegacyAPIs.
@Test
@SuppressWarnings("deprecation")
void testLegacyAPIs() {
reporter.disableCheckStrictSpanType();
Span span = transaction.createSpan();
span.setType("foo.bar.baz");
endSpan(span);
co.elastic.apm.agent.impl.transaction.Span internalSpan = reporter.getFirstSpan();
assertThat(internalSpan.getType()).isEqualTo("foo");
assertThat(internalSpan.getSubtype()).isEqualTo("bar");
assertThat(internalSpan.getAction()).isEqualTo("baz");
}
use of co.elastic.apm.api.Span in project apm-agent-java by elastic.
the class SpanInstrumentationTest method testTypes.
@Test
void testTypes() {
reporter.disableCheckStrictSpanType();
Span span = transaction.startSpan("foo", "bar", "baz");
endSpan(span);
co.elastic.apm.agent.impl.transaction.Span internalSpan = reporter.getFirstSpan();
assertThat(internalSpan.getType()).isEqualTo("foo");
assertThat(internalSpan.getSubtype()).isEqualTo("bar");
assertThat(internalSpan.getAction()).isEqualTo("baz");
}
use of co.elastic.apm.api.Span in project apm-agent-java by elastic.
the class SpanInstrumentationTest method testTraceHeaders.
@Test
void testTraceHeaders() {
Span span = transaction.startSpan();
assertContainsTracingHeaders(span);
assertContainsTracingHeaders(transaction);
span.end();
}
use of co.elastic.apm.api.Span in project apm-agent-java by elastic.
the class SpanInstrumentationTest method testExitSpanFromNonExitSpan.
@Test
void testExitSpanFromNonExitSpan() {
reporter.disableCheckStrictSpanType();
reporter.disableCheckDestinationAddress();
Span parent = transaction.startSpan("foo", "bar", "baz");
Span span = parent.startExitSpan("foo", "bar", "baz");
endSpan(span);
co.elastic.apm.agent.impl.transaction.Span internalSpan = reporter.getFirstSpan();
// relying on auto-inference of context.destination.service.resource
assertThat(internalSpan.getContext().getServiceTarget()).hasDestinationResource("bar");
}
Aggregations