Test nested CLIENT span suppression in library instrumentations (#3970)
This commit is contained in:
parent
79f4351e5c
commit
ab9c688e7a
|
@ -19,10 +19,4 @@ class ApacheClientHostAbsoluteUriRequestContextTest extends AbstractApacheClient
|
||||||
.build()
|
.build()
|
||||||
return builder.build()
|
return builder.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
// library instrumentation doesn't have a good way of suppressing nested CLIENT spans yet
|
|
||||||
@Override
|
|
||||||
boolean testWithClientParent() {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,4 @@ class ApacheClientHostAbsoluteUriRequestTest extends AbstractApacheClientHostAbs
|
||||||
.build()
|
.build()
|
||||||
return builder.build()
|
return builder.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
// library instrumentation doesn't have a good way of suppressing nested CLIENT spans yet
|
|
||||||
@Override
|
|
||||||
boolean testWithClientParent() {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,4 @@ class ApacheClientHostRequestContextTest extends AbstractApacheClientHostRequest
|
||||||
.build()
|
.build()
|
||||||
return builder.build()
|
return builder.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
// library instrumentation doesn't have a good way of suppressing nested CLIENT spans yet
|
|
||||||
@Override
|
|
||||||
boolean testWithClientParent() {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,4 @@ class ApacheClientHostRequestTest extends AbstractApacheClientHostRequestTest im
|
||||||
.build()
|
.build()
|
||||||
return builder.build()
|
return builder.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
// library instrumentation doesn't have a good way of suppressing nested CLIENT spans yet
|
|
||||||
@Override
|
|
||||||
boolean testWithClientParent() {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,4 @@ class ApacheClientUriRequestContextTest extends AbstractApacheClientUriRequestCo
|
||||||
.build()
|
.build()
|
||||||
return builder.build()
|
return builder.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
// library instrumentation doesn't have a good way of suppressing nested CLIENT spans yet
|
|
||||||
@Override
|
|
||||||
boolean testWithClientParent() {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,4 @@ class ApacheClientUriRequestTest extends AbstractApacheClientUriRequestTest impl
|
||||||
.build()
|
.build()
|
||||||
return builder.build()
|
return builder.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
// library instrumentation doesn't have a good way of suppressing nested CLIENT spans yet
|
|
||||||
@Override
|
|
||||||
boolean testWithClientParent() {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,13 +12,6 @@ import org.eclipse.jetty.util.ssl.SslContextFactory
|
||||||
|
|
||||||
class JettyHttpClient9LibraryTest extends AbstractJettyClient9Test implements LibraryTestTrait {
|
class JettyHttpClient9LibraryTest extends AbstractJettyClient9Test implements LibraryTestTrait {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
boolean testWithClientParent() {
|
|
||||||
//The client parent test does not work well in the context of library only tests.
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
HttpClient createStandardClient() {
|
HttpClient createStandardClient() {
|
||||||
JettyClientTracingBuilder jettyClientTracingBuilder = new JettyClientTracingBuilder(getOpenTelemetry())
|
JettyClientTracingBuilder jettyClientTracingBuilder = new JettyClientTracingBuilder(getOpenTelemetry())
|
||||||
|
|
|
@ -16,11 +16,4 @@ class OkHttp3Test extends AbstractOkHttp3Test implements LibraryTestTrait {
|
||||||
Call.Factory createCallFactory(OkHttpClient.Builder clientBuilder) {
|
Call.Factory createCallFactory(OkHttpClient.Builder clientBuilder) {
|
||||||
return OkHttpTracing.create(getOpenTelemetry()).newCallFactory(clientBuilder.build())
|
return OkHttpTracing.create(getOpenTelemetry()).newCallFactory(clientBuilder.build())
|
||||||
}
|
}
|
||||||
|
|
||||||
// library instrumentation doesn't have a good way of suppressing nested CLIENT spans yet
|
|
||||||
@Override
|
|
||||||
boolean testWithClientParent() {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,12 +63,6 @@ class SpringWebInstrumentationTest extends HttpClientTest<HttpEntity<String>> im
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
// library instrumentation doesn't have a good way of suppressing nested CLIENT spans yet
|
|
||||||
@Override
|
|
||||||
boolean testWithClientParent() {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
Set<AttributeKey<?>> httpAttributes(URI uri) {
|
Set<AttributeKey<?>> httpAttributes(URI uri) {
|
||||||
def attributes = super.httpAttributes(uri)
|
def attributes = super.httpAttributes(uri)
|
||||||
|
|
|
@ -12,7 +12,6 @@ import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
||||||
import io.opentelemetry.api.common.AttributeKey;
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.trace.Span;
|
import io.opentelemetry.api.trace.Span;
|
||||||
import io.opentelemetry.api.trace.SpanKind;
|
import io.opentelemetry.api.trace.SpanKind;
|
||||||
import io.opentelemetry.extension.annotations.WithSpan;
|
|
||||||
import io.opentelemetry.instrumentation.test.utils.PortUtils;
|
import io.opentelemetry.instrumentation.test.utils.PortUtils;
|
||||||
import io.opentelemetry.instrumentation.testing.InstrumentationTestRunner;
|
import io.opentelemetry.instrumentation.testing.InstrumentationTestRunner;
|
||||||
import io.opentelemetry.sdk.testing.assertj.SpanDataAssert;
|
import io.opentelemetry.sdk.testing.assertj.SpanDataAssert;
|
||||||
|
@ -29,7 +28,6 @@ import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.Callable;
|
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
|
@ -257,11 +255,13 @@ public abstract class AbstractHttpClientTest<REQUEST> {
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(strings = {"PUT", "POST"})
|
@ValueSource(strings = {"PUT", "POST"})
|
||||||
void shouldSuppressNestedClientSpanIfAlreadyUnderParentClientSpan(String method) {
|
void shouldSuppressNestedClientSpanIfAlreadyUnderParentClientSpan(String method)
|
||||||
|
throws Exception {
|
||||||
assumeTrue(options.testWithClientParent);
|
assumeTrue(options.testWithClientParent);
|
||||||
|
|
||||||
URI uri = resolveAddress("/success");
|
URI uri = resolveAddress("/success");
|
||||||
int responseCode = runUnderParentClientSpan(() -> doRequest(method, uri));
|
int responseCode =
|
||||||
|
testing.runWithClientSpan("parent-client-span", () -> doRequest(method, uri));
|
||||||
|
|
||||||
assertThat(responseCode).isEqualTo(200);
|
assertThat(responseCode).isEqualTo(200);
|
||||||
|
|
||||||
|
@ -1137,15 +1137,4 @@ public abstract class AbstractHttpClientTest<REQUEST> {
|
||||||
this.testing = testing;
|
this.testing = testing;
|
||||||
this.server = server;
|
this.server = server;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Must create span within agent using annotation until
|
|
||||||
// https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/1726
|
|
||||||
@WithSpan(value = "parent-client-span", kind = SpanKind.CLIENT)
|
|
||||||
private static <T> T runUnderParentClientSpan(Callable<T> r) {
|
|
||||||
try {
|
|
||||||
return r.call();
|
|
||||||
} catch (Throwable t) {
|
|
||||||
throw new AssertionError(t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue