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 @@ -10,10 +10,12 @@
import com.google.auto.service.AutoService;
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.internal.ExperimentalInstrumentationModule;
import java.util.List;

@AutoService(InstrumentationModule.class)
public class CassandraInstrumentationModule extends InstrumentationModule {
public class CassandraInstrumentationModule extends InstrumentationModule
implements ExperimentalInstrumentationModule {
public CassandraInstrumentationModule() {
super("cassandra", "cassandra-3.0");
}
Expand All @@ -22,4 +24,9 @@ public CassandraInstrumentationModule() {
public List<TypeInstrumentation> typeInstrumentations() {
return singletonList(new CassandraManagerInstrumentation());
}

@Override
public boolean isIndyReady() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.asm.Advice.AssignReturned;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;

Expand Down Expand Up @@ -42,13 +43,14 @@ public static class NewSessionAdvice {
*
* @param session The fresh session to patch. This session is replaced with new session
*/
@AssignReturned.ToReturned
@Advice.OnMethodExit(suppress = Throwable.class)
public static void injectTracingSession(@Advice.Return(readOnly = false) Session session) {
public static Session injectTracingSession(@Advice.Return Session session) {
// This should cover ours and OT's TracingSession
if (session.getClass().getName().endsWith("cassandra.TracingSession")) {
return;
return session;
}
session = new TracingSession(session);
return new TracingSession(session);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
import com.google.auto.service.AutoService;
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.internal.ExperimentalInstrumentationModule;
import java.util.List;
import net.bytebuddy.matcher.ElementMatcher;

@AutoService(InstrumentationModule.class)
public class CassandraClientInstrumentationModule extends InstrumentationModule {
public class CassandraClientInstrumentationModule extends InstrumentationModule
implements ExperimentalInstrumentationModule {

public CassandraClientInstrumentationModule() {
super("cassandra", "cassandra-4.0");
Expand All @@ -32,4 +34,9 @@ public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
// new public interface introduced in version 4.4
return not(hasClassesNamed("com.datastax.dse.driver.api.core.cql.reactive.ReactiveSession"));
}

@Override
public boolean isIndyReady() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
import java.util.concurrent.CompletionStage;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.asm.Advice.AssignReturned;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;

Expand Down Expand Up @@ -44,10 +45,10 @@ public static class BuildAdvice {
* @param stage The fresh CompletionStage to patch. This stage produces session which is
* replaced with new session
*/
@AssignReturned.ToReturned
@Advice.OnMethodExit(suppress = Throwable.class)
public static void injectTracingSession(
@Advice.Return(readOnly = false) CompletionStage<?> stage) {
stage = stage.thenApply(new CompletionStageFunction());
public static CompletionStage<?> injectTracingSession(@Advice.Return CompletionStage<?> stage) {
return stage.thenApply(new CompletionStageFunction());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
import com.google.auto.service.AutoService;
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.internal.ExperimentalInstrumentationModule;
import java.util.List;
import net.bytebuddy.matcher.ElementMatcher;

@AutoService(InstrumentationModule.class)
public class CassandraClientInstrumentationModule extends InstrumentationModule {
public class CassandraClientInstrumentationModule extends InstrumentationModule
implements ExperimentalInstrumentationModule {

public CassandraClientInstrumentationModule() {
super("cassandra", "cassandra-4.4");
Expand All @@ -31,4 +33,9 @@ public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
// new public interface introduced in version 4.4
return hasClassesNamed("com.datastax.dse.driver.api.core.cql.reactive.ReactiveSession");
}

@Override
public boolean isIndyReady() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
import java.util.concurrent.CompletionStage;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.asm.Advice.AssignReturned;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;

Expand Down Expand Up @@ -44,10 +45,10 @@ public static class BuildAdvice {
* @param stage The fresh CompletionStage to patch. This stage produces session which is
* replaced with new session
*/
@AssignReturned.ToReturned
@Advice.OnMethodExit(suppress = Throwable.class)
public static void injectTracingSession(
@Advice.Return(readOnly = false) CompletionStage<?> stage) {
stage = stage.thenApply(new CompletionStageFunction());
public static CompletionStage<?> injectTracingSession(@Advice.Return CompletionStage<?> stage) {
return stage.thenApply(new CompletionStageFunction());
}
}
}