Skip to content

Commit f2d386b

Browse files
committed
merge
2 parents e624439 + 55d7aed commit f2d386b

File tree

53 files changed

+746
-121
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+746
-121
lines changed

conventions/build.gradle.kts

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ dependencies {
6363
implementation("org.owasp:dependency-check-gradle:9.0.9")
6464
implementation("ru.vyarus:gradle-animalsniffer-plugin:1.7.1")
6565
// When updating, also update dependencyManagement/build.gradle.kts
66-
implementation("net.bytebuddy:byte-buddy-gradle-plugin:1.14.11")
66+
implementation("net.bytebuddy:byte-buddy-gradle-plugin:1.14.12")
6767
implementation("gradle.plugin.io.morethan.jmhreport:gradle-jmh-report:0.9.0")
6868
implementation("me.champeau.jmh:jmh-gradle-plugin:0.7.2")
6969
implementation("net.ltgt.gradle:gradle-errorprone-plugin:3.1.0")
70-
implementation("net.ltgt.gradle:gradle-nullaway-plugin:1.6.0")
70+
implementation("net.ltgt.gradle:gradle-nullaway-plugin:2.0.0")
7171
implementation("me.champeau.gradle:japicmp-gradle-plugin:0.4.2")
7272

7373
testImplementation(enforcedPlatform("org.junit:junit-bom:5.10.2"))

conventions/src/main/kotlin/otel.java-conventions.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ abstract class NettyAlignmentRule : ComponentMetadataRule {
122122
with(ctx.details) {
123123
if (id.group == "io.netty" && id.name != "netty") {
124124
if (id.version.startsWith("4.1.")) {
125-
belongsTo("io.netty:netty-bom:4.1.106.Final", false)
125+
belongsTo("io.netty:netty-bom:4.1.107.Final", false)
126126
} else if (id.version.startsWith("4.0.")) {
127127
belongsTo("io.netty:netty-bom:4.0.56.Final", false)
128128
}

dependencyManagement/build.gradle.kts

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ val DEPENDENCY_BOMS = listOf(
4040
val autoServiceVersion = "1.1.1"
4141
val autoValueVersion = "1.10.4"
4242
val errorProneVersion = "2.24.1"
43-
val byteBuddyVersion = "1.14.11"
43+
val byteBuddyVersion = "1.14.12"
4444
val asmVersion = "9.6"
4545
val jmhVersion = "1.37"
4646
val mockitoVersion = "4.11.0"
@@ -84,7 +84,7 @@ val DEPENDENCIES = listOf(
8484
"com.github.stefanbirkner:system-lambda:1.2.1",
8585
"com.github.stefanbirkner:system-rules:1.19.0",
8686
"uk.org.webcompere:system-stubs-jupiter:2.0.3",
87-
"com.uber.nullaway:nullaway:0.10.22",
87+
"com.uber.nullaway:nullaway:0.10.23",
8888
"commons-beanutils:commons-beanutils:1.9.4",
8989
"commons-cli:commons-cli:1.6.0",
9090
"commons-codec:commons-codec:1.16.1",

examples/distro/smoke-tests/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ plugins {
55
dependencies {
66
testImplementation("org.testcontainers:testcontainers:1.19.5")
77
testImplementation("com.fasterxml.jackson.core:jackson-databind:2.16.1")
8-
testImplementation("com.google.protobuf:protobuf-java-util:3.25.2")
8+
testImplementation("com.google.protobuf:protobuf-java-util:3.25.3")
99
testImplementation("com.squareup.okhttp3:okhttp:4.12.0")
1010
testImplementation("io.opentelemetry.proto:opentelemetry-proto:1.0.0-alpha")
1111
testImplementation("io.opentelemetry:opentelemetry-api")
1212

13-
testImplementation("ch.qos.logback:logback-classic:1.4.14")
13+
testImplementation("ch.qos.logback:logback-classic:1.5.0")
1414
}
1515

1616
tasks.test {

examples/extension/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,14 @@ dependencies {
101101
//All dependencies below are only for tests
102102
testImplementation("org.testcontainers:testcontainers:1.19.5")
103103
testImplementation("com.fasterxml.jackson.core:jackson-databind:2.16.1")
104-
testImplementation("com.google.protobuf:protobuf-java-util:3.25.2")
104+
testImplementation("com.google.protobuf:protobuf-java-util:3.25.3")
105105
testImplementation("com.squareup.okhttp3:okhttp:4.12.0")
106106
testImplementation("io.opentelemetry:opentelemetry-api")
107107
testImplementation("io.opentelemetry.proto:opentelemetry-proto:1.0.0-alpha")
108108

109109
testImplementation("org.junit.jupiter:junit-jupiter-api:${versions.junit}")
110110
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${versions.junit}")
111-
testRuntimeOnly("ch.qos.logback:logback-classic:1.4.14")
111+
testRuntimeOnly("ch.qos.logback:logback-classic:1.5.0")
112112

113113
//Otel Java instrumentation that we use and extend during integration tests
114114
otel("io.opentelemetry.javaagent:opentelemetry-javaagent:${versions.opentelemetryJavaagent}")

gradle-plugins/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ configurations.named("compileOnly") {
2424
extendsFrom(bbGradlePlugin)
2525
}
2626

27-
val byteBuddyVersion = "1.14.11"
27+
val byteBuddyVersion = "1.14.12"
2828
val aetherVersion = "1.1.0"
2929

3030
dependencies {

gradle-plugins/src/main/kotlin/io/opentelemetry/javaagent/muzzle/AcceptableVersions.kt

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class AcceptableVersions(private val skipVersions: Collection<String>) :
3333
|| versionString.contains("public_draft")
3434
|| versionString.contains("snapshot")
3535
|| versionString.contains("test")
36+
|| versionString.startsWith("0.0.0-")
3637
|| GIT_SHA_PATTERN.matches(versionString)
3738
|| DATETIME_PATTERN.matches(versionString)
3839
return !draftVersion

instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpServerRoute.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import io.opentelemetry.instrumentation.api.instrumenter.ContextCustomizer;
1111
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
1212
import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder;
13-
import io.opentelemetry.instrumentation.api.instrumenter.LocalRootSpan;
1413
import io.opentelemetry.instrumentation.api.internal.HttpRouteState;
1514
import javax.annotation.Nullable;
1615

@@ -95,16 +94,17 @@ public static <T, U> void update(
9594
HttpServerRouteBiGetter<T, U> httpRouteGetter,
9695
T arg1,
9796
U arg2) {
98-
Span serverSpan = LocalRootSpan.fromContextOrNull(context);
97+
HttpRouteState httpRouteState = HttpRouteState.fromContextOrNull(context);
98+
if (httpRouteState == null) {
99+
return;
100+
}
101+
Span serverSpan = httpRouteState.getSpan();
99102
// even if the server span is not sampled, we have to continue - we need to compute the
100103
// http.route properly so that it can be captured by the server metrics
101104
if (serverSpan == null) {
102105
return;
103106
}
104-
HttpRouteState httpRouteState = HttpRouteState.fromContextOrNull(context);
105-
if (httpRouteState == null) {
106-
return;
107-
}
107+
108108
// special case for servlet filters, even when we have a route from previous filter see whether
109109
// the new route is better and if so use it instead
110110
boolean onlyIfBetterRoute =

instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpServerRouteTest.java

+23-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import static org.mockito.Mockito.when;
1313

1414
import io.opentelemetry.api.trace.Span;
15+
import io.opentelemetry.api.trace.SpanKind;
1516
import io.opentelemetry.context.Context;
1617
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
1718
import io.opentelemetry.sdk.testing.junit5.OpenTelemetryExtension;
@@ -39,7 +40,7 @@ void setUp() {
3940
HttpServerRoute.builder(getter)
4041
.setKnownMethods(new HashSet<>(singletonList("GET")))
4142
.build())
42-
.buildInstrumenter();
43+
.buildInstrumenter(s -> SpanKind.SERVER);
4344
}
4445

4546
@Test
@@ -61,6 +62,27 @@ void noLocalRootSpan() {
6162
span -> assertThat(span).hasName("parent"), span -> assertThat(span).hasName("test"));
6263
}
6364

65+
@Test
66+
void nonServerRootSpan() {
67+
Instrumenter<String, Void> testInstrumenter =
68+
Instrumenter.<String, Void>builder(testing.getOpenTelemetry(), "test", s -> s)
69+
.addContextCustomizer(
70+
HttpServerRoute.builder(getter)
71+
.setKnownMethods(new HashSet<>(singletonList("GET")))
72+
.build())
73+
.buildInstrumenter(s -> SpanKind.INTERNAL);
74+
75+
Context context = testInstrumenter.start(Context.root(), "test");
76+
assertNull(HttpServerRoute.get(context));
77+
78+
HttpServerRoute.update(context, HttpServerRouteSource.SERVER, "/get/:id");
79+
80+
testInstrumenter.end(context, "test", null, null);
81+
82+
assertNull(HttpServerRoute.get(context));
83+
assertThat(testing.getSpans()).satisfiesExactly(span -> assertThat(span).hasName("test"));
84+
}
85+
6486
@Test
6587
void shouldSetRoute() {
6688
when(getter.getHttpRequestMethod("test")).thenReturn("GET");

instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/Instrumenter.java

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import io.opentelemetry.api.trace.SpanKind;
1212
import io.opentelemetry.api.trace.Tracer;
1313
import io.opentelemetry.context.Context;
14+
import io.opentelemetry.instrumentation.api.internal.HttpRouteState;
1415
import io.opentelemetry.instrumentation.api.internal.InstrumenterAccess;
1516
import io.opentelemetry.instrumentation.api.internal.InstrumenterUtil;
1617
import io.opentelemetry.instrumentation.api.internal.SupportabilityMetrics;
@@ -203,6 +204,9 @@ private Context doStart(Context parentContext, REQUEST request, @Nullable Instan
203204

204205
if (localRoot) {
205206
context = LocalRootSpan.store(context, span);
207+
if (spanKind == SpanKind.SERVER) {
208+
HttpRouteState.updateSpan(context, span);
209+
}
206210
}
207211

208212
return spanSuppressor.storeInContext(context, spanKind, span);

instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/HttpRouteState.java

+24-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package io.opentelemetry.instrumentation.api.internal;
77

8+
import io.opentelemetry.api.trace.Span;
89
import io.opentelemetry.context.Context;
910
import io.opentelemetry.context.ContextKey;
1011
import io.opentelemetry.context.ImplicitContextKeyed;
@@ -24,20 +25,36 @@ public static HttpRouteState fromContextOrNull(Context context) {
2425
return context.get(KEY);
2526
}
2627

28+
public static void updateSpan(Context context, Span span) {
29+
HttpRouteState state = fromContextOrNull(context);
30+
if (state != null) {
31+
state.span = span;
32+
}
33+
}
34+
35+
// this method is used reflectively from InstrumentationApiContextBridging
2736
public static HttpRouteState create(
2837
@Nullable String method, @Nullable String route, int updatedBySourceOrder) {
29-
return new HttpRouteState(method, route, updatedBySourceOrder);
38+
return create(method, route, updatedBySourceOrder, null);
39+
}
40+
41+
// this method is used reflectively from InstrumentationApiContextBridging
42+
public static HttpRouteState create(
43+
@Nullable String method, @Nullable String route, int updatedBySourceOrder, Span span) {
44+
return new HttpRouteState(method, route, updatedBySourceOrder, span);
3045
}
3146

3247
@Nullable private final String method;
3348
@Nullable private volatile String route;
3449
private volatile int updatedBySourceOrder;
50+
@Nullable private volatile Span span;
3551

3652
private HttpRouteState(
37-
@Nullable String method, @Nullable String route, int updatedBySourceOrder) {
53+
@Nullable String method, @Nullable String route, int updatedBySourceOrder, Span span) {
3854
this.method = method;
3955
this.updatedBySourceOrder = updatedBySourceOrder;
4056
this.route = route;
57+
this.span = span;
4158
}
4259

4360
@Override
@@ -59,6 +76,11 @@ public String getRoute() {
5976
return route;
6077
}
6178

79+
@Nullable
80+
public Span getSpan() {
81+
return span;
82+
}
83+
6284
public void update(
6385
@SuppressWarnings("unused")
6486
Context context, // context is used by the javaagent bridge instrumentation

instrumentation/apache-httpclient/apache-httpclient-5.0/javaagent/build.gradle.kts

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ dependencies {
1515
}
1616

1717
tasks {
18+
withType<Test>().configureEach {
19+
systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean)
20+
}
21+
1822
val testStableSemconv by registering(Test::class) {
1923
jvmArgs("-Dotel.semconv-stability.opt-in=http")
2024
}

instrumentation/apache-httpclient/apache-httpclient-5.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v5_0/ApacheHttpClientTest.java

+5
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,11 @@ protected void configure(HttpClientTestOptions.Builder optionsBuilder) {
223223
super.configure(optionsBuilder);
224224
// apparently apache http client does not report the 302 status code?
225225
optionsBuilder.setResponseCodeOnRedirectError(null);
226+
227+
if (Boolean.getBoolean("testLatestDeps")) {
228+
optionsBuilder.disableTestHttps();
229+
optionsBuilder.disableTestRemoteConnection();
230+
}
226231
}
227232
}
228233

instrumentation/grpc-1.6/testing/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcTest.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,10 @@ public void sayHello(
755755
t -> {
756756
// gRPC doesn't appear to propagate server exceptions that are thrown, not onError.
757757
assertThat(t.getStatus().getCode()).isEqualTo(Status.UNKNOWN.getCode());
758-
assertThat(t.getStatus().getDescription()).isNull();
758+
assertThat(t.getStatus().getDescription())
759+
.satisfiesAnyOf(
760+
a -> assertThat(a).isNull(),
761+
a -> assertThat(a).isEqualTo("Application error processing RPC"));
759762
});
760763

761764
testing()

instrumentation/kubernetes-client-7.0/javaagent/build.gradle.kts

+22-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,29 @@ muzzle {
1414
dependencies {
1515
library("io.kubernetes:client-java-api:7.0.0")
1616

17-
implementation(project(":instrumentation:okhttp:okhttp-3.0:javaagent"))
18-
1917
testInstrumentation(project(":instrumentation:okhttp:okhttp-3.0:javaagent"))
18+
19+
latestDepTestLibrary("io.kubernetes:client-java-api:19.+")
20+
}
21+
22+
testing {
23+
suites {
24+
val version20Test by registering(JvmTestSuite::class) {
25+
dependencies {
26+
if (findProperty("testLatestDeps") as Boolean) {
27+
implementation("io.kubernetes:client-java-api:+")
28+
} else {
29+
implementation("io.kubernetes:client-java-api:20.0.0")
30+
}
31+
}
32+
}
33+
}
34+
}
35+
36+
tasks {
37+
check {
38+
dependsOn(testing.suites)
39+
}
2040
}
2141

2242
tasks.withType<Test>().configureEach {

instrumentation/kubernetes-client-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/kubernetesclient/ApiClientInstrumentation.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public ElementMatcher<TypeDescription> typeMatcher() {
3535
@Override
3636
public void transform(TypeTransformer transformer) {
3737
transformer.applyAdviceToMethod(
38-
isPublic().and(named("buildRequest")).and(takesArguments(10)),
38+
isPublic().and(named("buildRequest")).and(takesArguments(10).or(takesArguments(11))),
3939
this.getClass().getName() + "$BuildRequestAdvice");
4040
transformer.applyAdviceToMethod(
4141
isPublic()

instrumentation/kubernetes-client-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/kubernetesclient/KubernetesRequestDigest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public KubernetesVerb getVerb() {
8989
@Override
9090
public String toString() {
9191
if (isNonResourceRequest) {
92-
return verb.value() + ' ' + urlPath;
92+
return (verb != null ? verb.value() + ' ' : "") + urlPath;
9393
}
9494

9595
String groupVersion;

instrumentation/kubernetes-client-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/kubernetesclient/KubernetesResource.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class KubernetesResource {
1212

1313
public static final Pattern CORE_RESOURCE_URL_PATH_PATTERN =
1414
Pattern.compile(
15-
"^/api/v1(/namespaces/(?<namespace>[\\w-]+))?/(?<resource>[\\w-]+)(/(?<name>[\\w-]+))?(/(?<subresource>[\\w-]+))?");
15+
"^/api/v1(/namespaces/(?<namespace>[\\w-]+))?/(?<resource>[\\w-]+)(/(?<name>[\\w-]+))?(/(?<subresource>[\\w-]+))?(/.*)?");
1616

1717
public static final Pattern REGULAR_RESOURCE_URL_PATH_PATTERN =
1818
Pattern.compile(

0 commit comments

Comments
 (0)