Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@ plugins {
}

dependencies {
compileOnly(project(":javaagent-bootstrap"))

testImplementation(project(":javaagent-bootstrap"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void testOurFieldsAndMethodsAreNotVisibleWithReflection() {
void testGeneratedSerialVersionUid() {
// expected value is computed with serialver utility that comes with jdk
assertThat(ObjectStreamClass.lookup(TestClass.class).getSerialVersionUID())
.isEqualTo(-1006206785953990857L);
.isEqualTo(7413560001584957796L);
assertThat(TestClass.class.getDeclaredFields()).isEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import java.io.Serializable;

public class TestClass implements Runnable, Serializable {
class TestClass implements Runnable, Serializable {

@Override
public void run() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ abstract static class AbstractTest extends AbstractJavaHttpClientTest {
protected HttpClient configureHttpClient(HttpClient httpClient) {
return httpClient;
}

@Override
protected boolean hasServicePeerName() {
return true;
}
}

@Nested
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.function.BiConsumer;
import javax.annotation.Nullable;

/**
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
Expand All @@ -30,7 +31,7 @@ public ResponseConsumer(
}

@Override
public void accept(HttpResponse<?> httpResponse, Throwable throwable) {
public void accept(@Nullable HttpResponse<?> httpResponse, @Nullable Throwable throwable) {
instrumenter.end(context, httpRequest, httpResponse, throwable);
}
}
1 change: 1 addition & 0 deletions instrumentation/java-http-client/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ configurations:
type: list
default: ""
- name: otel.instrumentation.common.peer-service-mapping
declarative_name: java.common.peer_service_mapping
description: Used to specify a mapping from host names or IP addresses to peer services.
type: map
default: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package io.opentelemetry.instrumentation.javahttpclient;

import static io.opentelemetry.api.common.AttributeKey.stringKey;
import static io.opentelemetry.instrumentation.testing.junit.service.SemconvServiceStabilityUtil.maybeStablePeerService;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
import static io.opentelemetry.semconv.ErrorAttributes.ERROR_TYPE;
import static io.opentelemetry.semconv.HttpAttributes.HTTP_REQUEST_METHOD;
Expand Down Expand Up @@ -55,6 +56,10 @@ void setUp() {

protected abstract HttpClient configureHttpClient(HttpClient httpClient);

protected boolean hasServicePeerName() {
return false;
}

@Override
public HttpRequest buildRequest(String method, URI uri, Map<String, String> headers) {
HttpRequest.Builder requestBuilder =
Expand Down Expand Up @@ -172,12 +177,15 @@ void cancelRequest() throws InterruptedException {
.hasKind(SpanKind.CLIENT)
.hasParent(trace.getSpan(0))
.hasStatus(StatusData.error())
.hasAttributesSatisfying(
.hasAttributesSatisfyingExactly(
equalTo(URL_FULL, uri.toString()),
equalTo(SERVER_ADDRESS, uri.getHost()),
equalTo(SERVER_PORT, uri.getPort()),
equalTo(HTTP_REQUEST_METHOD, method),
equalTo(ERROR_TYPE, CancellationException.class.getName())),
equalTo(ERROR_TYPE, CancellationException.class.getName()),
equalTo(
maybeStablePeerService(),
hasServicePeerName() ? "test-peer-service" : null)),
span ->
span.hasName("test-http-server")
.hasKind(SpanKind.SERVER)
Expand Down
1 change: 1 addition & 0 deletions instrumentation/java-http-server/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ configurations:
type: list
default: ""
- name: otel.instrumentation.common.peer-service-mapping
declarative_name: java.common.peer_service_mapping
description: Used to specify a mapping from host names or IP addresses to peer services.
type: map
default: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ plugins {
dependencies {
compileOnly(project(":instrumentation:java-util-logging:shaded-stub-for-instrumenting"))

compileOnly(project(":javaagent-bootstrap"))

// ensure no cross interference
testInstrumentation(project(":instrumentation:jboss-logmanager:jboss-logmanager-appender-1.1:javaagent"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.junit.jupiter.params.provider.MethodSource;

class JavaUtilLoggingTest {
private static final boolean isExperimentalAttributesEnabled =
private static final boolean EXPERIMENTAL_ATTRIBUTES =
Boolean.getBoolean("otel.instrumentation.java-util-logging.experimental-log-attributes");

private static final Logger logger = Logger.getLogger("abc");
Expand Down Expand Up @@ -166,14 +166,14 @@ private interface LoggerMethod {
}

private static String experimental(String value) {
if (isExperimentalAttributesEnabled) {
if (EXPERIMENTAL_ATTRIBUTES) {
return value;
}
return null;
}

private static Long experimental(long value) {
if (isExperimentalAttributesEnabled) {
if (EXPERIMENTAL_ATTRIBUTES) {
return value;
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ public int sendRequest(

Response response;
if (proxyMethodName.equals("get_success")) {
response = proxy.get_success(param, isTestServer, requestId);
response = proxy.getSuccess(param, isTestServer, requestId);
} else if (proxyMethodName.equals("post_success")) {
response = proxy.post_success(param, isTestServer, requestId);
response = proxy.postSuccess(param, isTestServer, requestId);
} else if (proxyMethodName.equals("put_success")) {
response = proxy.put_success(param, isTestServer, requestId);
response = proxy.putSuccess(param, isTestServer, requestId);
} else if (proxyMethodName.equals("get_error")) {
response = proxy.get_error(param, isTestServer, requestId);
response = proxy.getError(param, isTestServer, requestId);
} else if (proxyMethodName.equals("get_client_error")) {
response = proxy.get_client_error(param, isTestServer, requestId);
response = proxy.getClientError(param, isTestServer, requestId);
} else {
throw new IllegalArgumentException("Unknown method: " + proxyMethodName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,35 @@
interface ResteasyProxyResource {
@GET
@Path("error")
Response get_error(
Response getError(
@QueryParam("with") String param,
@HeaderParam("is-test-server") String isTestServer,
@HeaderParam("test-request-id") String requestId);

@GET
@Path("client-error")
Response get_client_error(
Response getClientError(
@QueryParam("with") String param,
@HeaderParam("is-test-server") String isTestServer,
@HeaderParam("test-request-id") String requestId);

@GET
@Path("success")
Response get_success(
Response getSuccess(
@QueryParam("with") String param,
@HeaderParam("is-test-server") String isTestServer,
@HeaderParam("test-request-id") String requestId);

@POST
@Path("success")
Response post_success(
Response postSuccess(
@QueryParam("with") String param,
@HeaderParam("is-test-server") String isTestServer,
@HeaderParam("test-request-id") String requestId);

@PUT
@Path("success")
Response put_success(
Response putSuccess(
@QueryParam("with") String param,
@HeaderParam("is-test-server") String isTestServer,
@HeaderParam("test-request-id") String requestId);
Expand Down
Loading