Skip to content

Commit 4bb06f2

Browse files
fixes errors
1 parent 613fc79 commit 4bb06f2

File tree

7 files changed

+32
-30
lines changed

7 files changed

+32
-30
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
kotlin version: 2.0.20
2+
error message: The daemon has terminated unexpectedly on startup attempt #1 with error code: 0. The daemon process output:
3+
1. Kotlin compile daemon is ready
4+

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ muzzle {
66
pass {
77
group.set("com.aerospike")
88
module.set("aerospike-client")
9-
versions.set("[7.0.0,)")
9+
versions.set("[4.0.0,)")
1010
assertInverse.set(true)
1111
}
1212
}
1313

1414
dependencies {
15-
implementation("com.aerospike:aerospike-client:7.0.0")
15+
library("com.aerospike:aerospike-client:8.0.0")
1616
implementation("io.opentelemetry:opentelemetry-api-incubator")
1717

1818
compileOnly("com.google.auto.value:auto-value-annotations")
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,14 @@
77

88
import static io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge.currentContext;
99
import static io.opentelemetry.javaagent.instrumentation.aerospike.v7_0.AersopikeSingletons.instrumenter;
10-
import static io.opentelemetry.javaagent.instrumentation.aerospike.v7_0.internal.CustomElementMatcher.argumentOfType;
1110
import static io.opentelemetry.javaagent.instrumentation.aerospike.v7_0.internal.CustomElementMatcher.iterableHasAtLeastOne;
1211
import static net.bytebuddy.matcher.ElementMatchers.hasSuperType;
1312
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
1413
import static net.bytebuddy.matcher.ElementMatchers.named;
1514
import static net.bytebuddy.matcher.ElementMatchers.not;
1615
import static net.bytebuddy.matcher.ElementMatchers.takesGenericArguments;
1716

18-
import com.aerospike.client.AerospikeException;
1917
import com.aerospike.client.Key;
20-
import com.aerospike.client.async.EventLoop;
2118
import io.opentelemetry.context.Context;
2219
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
2320
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
@@ -28,7 +25,8 @@
2825
import net.bytebuddy.description.type.TypeDescription;
2926
import net.bytebuddy.matcher.ElementMatcher;
3027

31-
public class IAerospikeClientInstrumentation implements TypeInstrumentation {
28+
public class AerospikeClientInstrumentation implements TypeInstrumentation {
29+
3230
@Override
3331
public ElementMatcher<TypeDescription> typeMatcher() {
3432
return hasSuperType(named("com.aerospike.client.IAerospikeClient"));
@@ -38,22 +36,22 @@ public ElementMatcher<TypeDescription> typeMatcher() {
3836
public void transform(TypeTransformer transformer) {
3937
transformer.applyAdviceToMethod(
4038
isMethod()
41-
.and(takesGenericArguments(iterableHasAtLeastOne(argumentOfType(Key.class))))
39+
.and(takesGenericArguments(iterableHasAtLeastOne(named("com.aerospike.client.Key"))))
4240
.and(
43-
not(takesGenericArguments(iterableHasAtLeastOne(argumentOfType(EventLoop.class))))),
41+
not(takesGenericArguments(iterableHasAtLeastOne(named("com.aerospike.client.async.EventLoop"))))),
4442
this.getClass().getName() + "$SyncCommandAdvice");
4543

4644
transformer.applyAdviceToMethod(
4745
isMethod()
48-
.and(takesGenericArguments(iterableHasAtLeastOne(argumentOfType(Key.class))))
49-
.and(takesGenericArguments(iterableHasAtLeastOne(argumentOfType(EventLoop.class)))),
46+
.and(takesGenericArguments(iterableHasAtLeastOne(named("com.aerospike.client.Key"))))
47+
.and(takesGenericArguments(iterableHasAtLeastOne(named("com.aerospike.client.async.EventLoop")))),
5048
this.getClass().getName() + "$AsyncCommandAdvice");
5149
}
5250

5351
@SuppressWarnings("unused")
5452
public static class SyncCommandAdvice {
5553

56-
@Advice.OnMethodEnter(suppress = AerospikeException.class)
54+
@Advice.OnMethodEnter(suppress = Throwable.class)
5755
public static void startInstrumentation(
5856
@Advice.Origin("#m") String methodName,
5957
@Advice.AllArguments Object[] args,
@@ -78,20 +76,20 @@ public static void startInstrumentation(
7876
}
7977

8078
@Advice.OnMethodExit(
81-
onThrowable = AerospikeException.class,
82-
suppress = AerospikeException.class)
79+
onThrowable = Throwable.class,
80+
suppress = Throwable.class)
8381
public static void stopInstrumentation(
84-
@Advice.Thrown AerospikeException ae,
82+
@Advice.Thrown Throwable ex,
8583
@Advice.Local("AerospikeContext") AerospikeRequestContext requestContext) {
86-
requestContext.setThrowable(ae);
84+
requestContext.setThrowable(ex);
8785
requestContext.detachAndEnd();
8886
}
8987
}
9088

9189
@SuppressWarnings("unused")
9290
public static class AsyncCommandAdvice {
9391

94-
@Advice.OnMethodEnter(suppress = AerospikeException.class)
92+
@Advice.OnMethodEnter(suppress = Throwable.class)
9593
public static void startInstrumentation(
9694
@Advice.Origin("#m") String methodName,
9795
@Advice.AllArguments Object[] args,
@@ -116,13 +114,13 @@ public static void startInstrumentation(
116114
}
117115

118116
@Advice.OnMethodExit(
119-
onThrowable = AerospikeException.class,
120-
suppress = AerospikeException.class)
117+
onThrowable = Throwable.class,
118+
suppress = Throwable.class)
121119
public static void stopInstrumentaionIfError(
122-
@Advice.Thrown AerospikeException ae,
120+
@Advice.Thrown Throwable ex,
123121
@Advice.Local("AerospikeContext") AerospikeRequestContext requestContext) {
124-
if (ae != null) {
125-
requestContext.setThrowable(ae);
122+
if (ex != null) {
123+
requestContext.setThrowable(ex);
126124
requestContext.detachAndEnd();
127125
}
128126
}

instrumentation/aerospike-client/aerospike-client-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/aerospike/v7_0/AerospikeClientInstrumentationModule.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,18 @@ public AerospikeClientInstrumentationModule() {
2323

2424
@Override
2525
public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
26-
return hasClassesNamed("com.aerospike.client.IAerospikeClient");
26+
return hasClassesNamed("com.aerospike.client.IAerospikeClient").
27+
and(hasClassesNamed("com.aerospike.client.command.Command")).
28+
and(hasClassesNamed("com.aerospike.client.command.SyncCommand")).
29+
and(hasClassesNamed("com.aerospike.client.async.AsyncCommand")).
30+
and(hasClassesNamed("com.aerospike.client.async.EventLoop")).
31+
and(hasClassesNamed("com.aerospike.client.Key"));
2732
}
2833

2934
@Override
3035
public List<TypeInstrumentation> typeInstrumentations() {
3136
return asList(
32-
new IAerospikeClientInstrumentation(),
37+
new AerospikeClientInstrumentation(),
3338
new SyncCommandInstrumentation(),
3439
new AsyncCommandInstrumentation());
3540
}

instrumentation/aerospike-client/aerospike-client-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/aerospike/v7_0/AsyncCommandInstrumentation.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
1212
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
1313
import static net.bytebuddy.matcher.ElementMatchers.named;
14-
import static net.bytebuddy.matcher.ElementMatchers.takesGenericArguments;
14+
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
1515

1616
import com.aerospike.client.AerospikeException;
1717
import com.aerospike.client.cluster.Node;
@@ -48,7 +48,7 @@ public void transform(TypeTransformer transformer) {
4848
isMethod().and(named("onSuccess")), this.getClass().getName() + "$GetOnSuccessAdvice");
4949

5050
transformer.applyAdviceToMethod(
51-
isMethod().and(named("onFailure").and(takesGenericArguments(AerospikeException.class))),
51+
isMethod().and(named("onFailure").and(takesArgument(0, named("com.aerospike.client.AerospikeException")))),
5252
this.getClass().getName() + "$GetOnFailureAdvice");
5353
}
5454

instrumentation/aerospike-client/aerospike-client-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/aerospike/v7_0/internal/CustomElementMatcher.java

-4
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,4 @@ public static ElementMatcher<Iterable<? extends TypeDescription.Generic>> iterab
2626
return false;
2727
};
2828
}
29-
30-
public static ElementMatcher<TypeDescription.Generic> argumentOfType(Class<?> clazz) {
31-
return typeDescription -> typeDescription.asErasure().represents(clazz);
32-
}
3329
}

instrumentation/aerospike-client/aerospike-client-7.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/aerospike/v7_0/AerospikeClientTest.java

-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ static void setupSpec() {
6262
port = 3000;
6363
ClientPolicy clientPolicy = new ClientPolicy();
6464
int eventLoopSize = Runtime.getRuntime().availableProcessors();
65-
System.out.println(eventLoopSize);
6665
EventPolicy eventPolicy = new EventPolicy();
6766
eventPolicy.commandsPerEventLoop = 2;
6867
clientPolicy.eventLoops = new NioEventLoops(eventPolicy, eventLoopSize);

0 commit comments

Comments
 (0)