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 @@ -29,13 +29,9 @@ public List<TypeInstrumentation> typeInstrumentations() {

@Override
public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
return hasClassesNamed(
// added in 4.0
"com.datastax.oss.driver.api.core.CqlSession")
.and(
not(
hasClassesNamed(
// added in 4.4
"com.datastax.dse.driver.api.core.cql.reactive.ReactiveSession")));
// added in 4.0
return hasClassesNamed("com.datastax.oss.driver.api.core.CqlSession")
// added in 4.4
.and(not(hasClassesNamed("com.datastax.dse.driver.api.core.cql.reactive.ReactiveSession")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ muzzle {
pass {
group.set("com.datastax.oss")
module.set("java-driver-core")
versions.set("[4.4,]")
versions.set("[4.4,)")
assertInverse.set(true)
}
pass {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

package io.opentelemetry.javaagent.instrumentation.cassandra.v4_4;

import static io.opentelemetry.javaagent.instrumentation.cassandra.v4_4.CassandraSingletons.telemetry;

import com.datastax.oss.driver.api.core.CqlSession;
import java.util.function.Function;

Expand All @@ -19,6 +21,6 @@ public Object apply(Object session) {
if (session.getClass().getName().endsWith("cassandra4.TracingCqlSession")) {
return session;
}
return CassandraSingletons.telemetry().wrap((CqlSession) session);
return telemetry().wrap((CqlSession) session);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
import io.opentelemetry.javaagent.instrumentation.clickhouse.common.ClickHouseDbRequest;
import io.opentelemetry.javaagent.instrumentation.clickhouse.common.ClickHouseScope;
import javax.annotation.Nullable;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
Expand All @@ -48,8 +49,9 @@ public void transform(TypeTransformer transformer) {
@SuppressWarnings("unused")
public static class ExecuteAndWaitAdvice {
@Advice.OnMethodEnter(suppress = Throwable.class, inline = false)
@Nullable
public static ClickHouseScope onEnter(
@Advice.Argument(0) ClickHouseRequest<?> clickHouseRequest) {
@Advice.Argument(0) @Nullable ClickHouseRequest<?> clickHouseRequest) {

CallDepth callDepth = CallDepth.forClass(ClickHouseClient.class);
if (callDepth.getAndIncrement() > 0 || clickHouseRequest == null) {
Expand All @@ -71,7 +73,8 @@ public static ClickHouseScope onEnter(

@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class, inline = false)
public static void onExit(
@Advice.Thrown Throwable throwable, @Advice.Enter ClickHouseScope scope) {
@Advice.Thrown @Nullable Throwable throwable,
@Advice.Enter @Nullable ClickHouseScope scope) {

CallDepth callDepth = CallDepth.forClass(ClickHouseClient.class);
if (callDepth.decrementAndGet() > 0 || scope == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.opentelemetry.javaagent.instrumentation.clickhouse.common.ClickHouseDbRequest;
import io.opentelemetry.javaagent.instrumentation.clickhouse.common.ClickHouseScope;
import java.util.Map;
import javax.annotation.Nullable;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
Expand All @@ -45,8 +46,9 @@ public void transform(TypeTransformer transformer) {
@SuppressWarnings("unused")
public static class QueryAdvice {
@Advice.OnMethodEnter(suppress = Throwable.class, inline = false)
@Nullable
public static ClickHouseScope onEnter(
@Advice.This Client client, @Advice.Argument(0) String sqlQuery) {
@Advice.This Client client, @Advice.Argument(0) @Nullable String sqlQuery) {
CallDepth callDepth = CallDepth.forClass(Client.class);
if (callDepth.getAndIncrement() > 0 || sqlQuery == null) {
return null;
Expand All @@ -72,7 +74,8 @@ public static ClickHouseScope onEnter(

@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class, inline = false)
public static void onExit(
@Advice.Thrown Throwable throwable, @Advice.Enter ClickHouseScope scope) {
@Advice.Thrown @Nullable Throwable throwable,
@Advice.Enter @Nullable ClickHouseScope scope) {
CallDepth callDepth = CallDepth.forClass(Client.class);
if (callDepth.decrementAndGet() > 0 || scope == null) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import io.opentelemetry.instrumentation.api.util.VirtualField;
import io.opentelemetry.javaagent.instrumentation.clickhouse.common.ClickHouseDbRequest;
import io.opentelemetry.javaagent.instrumentation.clickhouse.common.ClickHouseInstrumenterFactory;
import javax.annotation.Nullable;

public class ClickHouseClientV2Singletons {

Expand All @@ -37,11 +38,12 @@ public static Instrumenter<ClickHouseDbRequest, Void> instrumenter() {
return instrumenter;
}

@Nullable
public static AddressAndPort getAddressAndPort(Client client) {
return ADDRESS_AND_PORT.get(client);
}

public static AddressAndPort setAddressAndPort(Client client, String endpoint) {
public static AddressAndPort setAddressAndPort(Client client, @Nullable String endpoint) {
AddressAndPort addressAndPort = new AddressAndPort();

if (endpoint != null) {
Expand Down
Loading
Loading