Skip to content

Commit 36d5919

Browse files
committed
cross test instrumentations
1 parent 744a301 commit 36d5919

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

instrumentation/ktor/ktor-2.0/javaagent/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ dependencies {
2525
compileOnly("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
2626

2727
testInstrumentation(project(":instrumentation:netty:netty-4.1:javaagent"))
28+
testInstrumentation(project(":instrumentation:ktor:ktor-3.0:javaagent"))
2829

2930
testImplementation(project(":instrumentation:ktor:ktor-2.0:testing"))
3031
testImplementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")

instrumentation/ktor/ktor-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/ktor/v2_0/KtorClientInstrumentationModule.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55

66
package io.opentelemetry.javaagent.instrumentation.ktor.v2_0;
77

8+
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed;
89
import static java.util.Collections.singletonList;
910

1011
import com.google.auto.service.AutoService;
1112
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
1213
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
1314
import java.util.List;
15+
import net.bytebuddy.matcher.ElementMatcher;
1416

1517
@AutoService(InstrumentationModule.class)
1618
public class KtorClientInstrumentationModule extends InstrumentationModule {
@@ -24,6 +26,12 @@ public boolean isHelperClass(String className) {
2426
return className.startsWith("io.opentelemetry.extension.kotlin.");
2527
}
2628

29+
@Override
30+
public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
31+
// removed in ktor 3
32+
return hasClassesNamed("io.ktor.client.engine.HttpClientJvmEngine");
33+
}
34+
2735
@Override
2836
public List<TypeInstrumentation> typeInstrumentations() {
2937
return singletonList(new HttpClientInstrumentation());

instrumentation/ktor/ktor-3.0/javaagent/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ dependencies {
2525
compileOnly("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
2626

2727
testInstrumentation(project(":instrumentation:netty:netty-4.1:javaagent"))
28+
testInstrumentation(project(":instrumentation:ktor:ktor-2.0:javaagent"))
2829

2930
testImplementation(project(":instrumentation:ktor:ktor-3.0:testing"))
3031
testImplementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")

instrumentation/ktor/ktor-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/ktor/v3_0/KtorClientInstrumentationModule.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55

66
package io.opentelemetry.javaagent.instrumentation.ktor.v3_0;
77

8+
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed;
89
import static java.util.Collections.singletonList;
910

1011
import com.google.auto.service.AutoService;
1112
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
1213
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
1314
import java.util.List;
15+
import net.bytebuddy.matcher.ElementMatcher;
1416

1517
@AutoService(InstrumentationModule.class)
1618
public class KtorClientInstrumentationModule extends InstrumentationModule {
@@ -24,6 +26,12 @@ public boolean isHelperClass(String className) {
2426
return className.startsWith("io.opentelemetry.extension.kotlin.");
2527
}
2628

29+
@Override
30+
public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
31+
// added in ktor 3
32+
return hasClassesNamed("io.ktor.client.content.ProgressListener");
33+
}
34+
2735
@Override
2836
public List<TypeInstrumentation> typeInstrumentations() {
2937
return singletonList(new HttpClientInstrumentation());

0 commit comments

Comments
 (0)