Skip to content

Commit de3d249

Browse files
otelbot[bot]trask
andauthored
Code review sweep (run 25152152525) (#18440)
Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com> Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
1 parent 18b217a commit de3d249

12 files changed

Lines changed: 34 additions & 22 deletions

File tree

instrumentation/internal/internal-lambda/javaagent/build.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,5 @@ plugins {
33
}
44

55
dependencies {
6-
compileOnly(project(":javaagent-bootstrap"))
7-
86
testImplementation(project(":javaagent-bootstrap"))
97
}

instrumentation/internal/internal-reflection/javaagent-integration-tests/src/test/java/io/opentelemetry/javaagent/instrumentation/internal/reflection/ReflectionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void testOurFieldsAndMethodsAreNotVisibleWithReflection() {
4343
void testGeneratedSerialVersionUid() {
4444
// expected value is computed with serialver utility that comes with jdk
4545
assertThat(ObjectStreamClass.lookup(TestClass.class).getSerialVersionUID())
46-
.isEqualTo(-1006206785953990857L);
46+
.isEqualTo(7413560001584957796L);
4747
assertThat(TestClass.class.getDeclaredFields()).isEmpty();
4848
}
4949
}

instrumentation/internal/internal-reflection/javaagent-integration-tests/src/test/java/io/opentelemetry/javaagent/instrumentation/internal/reflection/TestClass.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import java.io.Serializable;
99

10-
public class TestClass implements Runnable, Serializable {
10+
class TestClass implements Runnable, Serializable {
1111

1212
@Override
1313
public void run() {}

instrumentation/java-http-client/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/javahttpclient/JavaHttpClientTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ abstract static class AbstractTest extends AbstractJavaHttpClientTest {
2323
protected HttpClient configureHttpClient(HttpClient httpClient) {
2424
return httpClient;
2525
}
26+
27+
@Override
28+
protected boolean hasServicePeerName() {
29+
return true;
30+
}
2631
}
2732

2833
@Nested

instrumentation/java-http-client/library/src/main/java/io/opentelemetry/instrumentation/javahttpclient/internal/ResponseConsumer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java.net.http.HttpRequest;
1111
import java.net.http.HttpResponse;
1212
import java.util.function.BiConsumer;
13+
import javax.annotation.Nullable;
1314

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

3233
@Override
33-
public void accept(HttpResponse<?> httpResponse, Throwable throwable) {
34+
public void accept(@Nullable HttpResponse<?> httpResponse, @Nullable Throwable throwable) {
3435
instrumenter.end(context, httpRequest, httpResponse, throwable);
3536
}
3637
}

instrumentation/java-http-client/metadata.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ configurations:
2323
type: list
2424
default: ""
2525
- name: otel.instrumentation.common.peer-service-mapping
26+
declarative_name: java.common.peer_service_mapping
2627
description: Used to specify a mapping from host names or IP addresses to peer services.
2728
type: map
2829
default: ""

instrumentation/java-http-client/testing/src/main/java/io/opentelemetry/instrumentation/javahttpclient/AbstractJavaHttpClientTest.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
package io.opentelemetry.instrumentation.javahttpclient;
77

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

5657
protected abstract HttpClient configureHttpClient(HttpClient httpClient);
5758

59+
protected boolean hasServicePeerName() {
60+
return false;
61+
}
62+
5863
@Override
5964
public HttpRequest buildRequest(String method, URI uri, Map<String, String> headers) {
6065
HttpRequest.Builder requestBuilder =
@@ -172,12 +177,15 @@ void cancelRequest() throws InterruptedException {
172177
.hasKind(SpanKind.CLIENT)
173178
.hasParent(trace.getSpan(0))
174179
.hasStatus(StatusData.error())
175-
.hasAttributesSatisfying(
180+
.hasAttributesSatisfyingExactly(
176181
equalTo(URL_FULL, uri.toString()),
177182
equalTo(SERVER_ADDRESS, uri.getHost()),
178183
equalTo(SERVER_PORT, uri.getPort()),
179184
equalTo(HTTP_REQUEST_METHOD, method),
180-
equalTo(ERROR_TYPE, CancellationException.class.getName())),
185+
equalTo(ERROR_TYPE, CancellationException.class.getName()),
186+
equalTo(
187+
maybeStablePeerService(),
188+
hasServicePeerName() ? "test-peer-service" : null)),
181189
span ->
182190
span.hasName("test-http-server")
183191
.hasKind(SpanKind.SERVER)

instrumentation/java-http-server/metadata.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ configurations:
2323
type: list
2424
default: ""
2525
- name: otel.instrumentation.common.peer-service-mapping
26+
declarative_name: java.common.peer_service_mapping
2627
description: Used to specify a mapping from host names or IP addresses to peer services.
2728
type: map
2829
default: ""

instrumentation/java-util-logging/javaagent/build.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ plugins {
55
dependencies {
66
compileOnly(project(":instrumentation:java-util-logging:shaded-stub-for-instrumenting"))
77

8-
compileOnly(project(":javaagent-bootstrap"))
9-
108
// ensure no cross interference
119
testInstrumentation(project(":instrumentation:jboss-logmanager:jboss-logmanager-appender-1.1:javaagent"))
1210
}

instrumentation/java-util-logging/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/jul/JavaUtilLoggingTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import org.junit.jupiter.params.provider.MethodSource;
3333

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

3838
private static final Logger logger = Logger.getLogger("abc");
@@ -166,14 +166,14 @@ private interface LoggerMethod {
166166
}
167167

168168
private static String experimental(String value) {
169-
if (isExperimentalAttributesEnabled) {
169+
if (EXPERIMENTAL_ATTRIBUTES) {
170170
return value;
171171
}
172172
return null;
173173
}
174174

175175
private static Long experimental(long value) {
176-
if (isExperimentalAttributesEnabled) {
176+
if (EXPERIMENTAL_ATTRIBUTES) {
177177
return value;
178178
}
179179
return null;

0 commit comments

Comments
 (0)