Skip to content
Open
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 @@ -17,7 +17,7 @@ public static AgentScope enter() {
return activateSpan(noopSpan());
}

@Advice.OnMethodExit(suppress = Throwable.class)
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
public static void exit(@Advice.Enter final AgentScope scope) {
scope.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static Runnable capturePrevious(
return previousListener;
}

@Advice.OnMethodExit(suppress = Throwable.class)
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
public static void cancelSuperseded(
@Advice.Enter final Runnable previousListener,
@Advice.FieldValue("attemptFutureCompletionListener") final Runnable newListener) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ static void after(
}

static class NIOInputStreamRecycleAdvice {
@Advice.OnMethodExit(suppress = Throwable.class)
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
static void after(@Advice.This final NIOInputStream thiz) {
InstrumentationContext.get(NIOInputStream.class, StoredByteBody.class).put(thiz, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ static void after(
}

static class NIOReaderRecycleAdvice {
@Advice.OnMethodExit(suppress = Throwable.class)
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
static void after(@Advice.This final NIOReader thiz) {
InstrumentationContext.get(NIOReader.class, StoredCharBody.class).put(thiz, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ public static AgentScope before(@Advice.This ForkJoinTask<?> zis) {
return startTaskScope(InstrumentationContext.get(ForkJoinTask.class, State.class), zis);
}

@Advice.OnMethodExit
@Advice.OnMethodExit(onThrowable = Throwable.class)
public static void after(@Advice.Enter AgentScope scope) {
endTaskScope(scope);
}
}

public static class Cancel {
@Advice.OnMethodExit
@Advice.OnMethodExit(onThrowable = Throwable.class)
public static <T> void cancel(@Advice.This ForkJoinTask<T> task) {
State state = InstrumentationContext.get(ForkJoinTask.class, State.class).get(task);
if (null != state) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.kafka.clients.consumer.internals.ConsumerCoordinator;
import org.apache.kafka.common.errors.WakeupException;

/**
* This instrumentation saves additional information from the KafkaConsumer, such as consumer group
Expand Down Expand Up @@ -258,11 +259,12 @@ public static AgentScope onEnter(@Advice.This KafkaConsumer consumer) {
return null;
}

@Advice.OnMethodExit(suppress = Throwable.class)
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
public static void captureGroup(
@Advice.Enter final AgentScope scope,
@Advice.This KafkaConsumer consumer,
@Advice.Return ConsumerRecords records) {
@Advice.Return ConsumerRecords records,
@Advice.Thrown Throwable throwable) {
int recordsCount = 0;
if (records != null) {
KafkaConsumerInfo kafkaConsumerInfo =
Expand All @@ -281,6 +283,9 @@ public static void captureGroup(
}
AgentSpan span = scope.span();
span.setTag(KAFKA_RECORDS_COUNT, recordsCount);
if (throwable != null && !(throwable instanceof WakeupException)) {
span.addThrowable(throwable);
}
span.finish();
scope.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.apache.kafka.clients.Metadata;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.internals.ConsumerDelegate;
import org.apache.kafka.common.errors.WakeupException;

/**
* this method transfers the consumer group from the KafkaConsumer class key to the ConsumerRecords
Expand Down Expand Up @@ -45,11 +46,12 @@ public static AgentScope onEnter(@Advice.This ConsumerDelegate consumer) {
return null;
}

@Advice.OnMethodExit(suppress = Throwable.class)
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
public static void captureGroup(
@Advice.Enter final AgentScope scope,
@Advice.This ConsumerDelegate consumer,
@Advice.Return ConsumerRecords records) {
@Advice.Return ConsumerRecords records,
@Advice.Thrown Throwable throwable) {
int recordsCount = 0;
if (records != null) {
// new - we are getting the KafkaConsumerInfo from the ConsumerDelegate instead of
Expand All @@ -70,6 +72,9 @@ public static void captureGroup(
}
AgentSpan span = scope.span();
span.setTag(KAFKA_RECORDS_COUNT, recordsCount);
if (throwable != null && !(throwable instanceof WakeupException)) {
span.addThrowable(throwable);
}
span.finish();
scope.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static AgentScope before(@Advice.Argument(2) RedisCommand command) {
return null;
}

@Advice.OnMethodExit
@Advice.OnMethodExit(onThrowable = Throwable.class)
public static void after(@Advice.Enter AgentScope scope) {
endTaskScope(scope);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

public class RedisSubscriptionCommandCompleteAdvice {

@Advice.OnMethodExit(suppress = Throwable.class)
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
public static void afterComplete(
@Advice.Origin("#m") String method,
@Advice.This RedisCommand command,
Comment thread
mcculls marked this conversation as resolved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import net.bytebuddy.asm.Advice;

public class RedisSubscriptionCommandErrorAdvice {
@Advice.OnMethodExit(suppress = Throwable.class)
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
public static void afterError(
@Advice.This RedisCommand command, @Advice.Argument(value = 0) Throwable throwable) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/** Instrumentation for SubscriptionCommand in version 5.3.6 and later */
public class RedisSubscriptionCommandOnCompleteAdvice {

@Advice.OnMethodExit(suppress = Throwable.class)
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
public static void afterComplete(
@Advice.This RedisCommand command,
@Advice.FieldValue("subscription") Subscription subscription) {
Comment thread
mcculls marked this conversation as resolved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,14 @@ public static State beforeSubscribe(
return new State(parentScope, span);
}

@Advice.OnMethodExit(suppress = Throwable.class)
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
Comment thread
mcculls marked this conversation as resolved.
public static void afterSubscribe(
@Advice.FieldValue("command") RedisCommand command,
@Advice.FieldValue("subscriptionCommand") RedisCommand subscriptionCommand,
@Advice.Enter State state) {
if (!expectsResponse(command)) {
@Advice.Enter State state,
@Advice.Thrown Throwable throwable) {
if (!expectsResponse(command) || throwable != null) {
DECORATE.onError(state.span, throwable);
DECORATE.beforeFinish(state.span);
state.span.finish();
InstrumentationContext.get(RedisCommand.class, AgentSpan.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static AgentScope enter() {
return activateSpan(noopSpan());
}

@Advice.OnMethodExit(suppress = Throwable.class)
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
public static void exit(@Advice.Enter final AgentScope scope) {
scope.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,17 @@ public void methodAdvice(MethodTransformer transformer) {

public static class AsyncResponseAdvice {

@Advice.OnMethodExit(suppress = Throwable.class)
public static void stopSpan(@Advice.This final AsyncResponse asyncResponse) {
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
public static void stopSpan(
@Advice.This final AsyncResponse asyncResponse, @Advice.Thrown Throwable throwable) {

final ContextStore<AsyncResponse, AgentSpan> contextStore =
InstrumentationContext.get(AsyncResponse.class, AgentSpan.class);

final AgentSpan span = contextStore.get(asyncResponse);
if (span != null) {
contextStore.put(asyncResponse, null);
DECORATE.onError(span, throwable);
DECORATE.beforeFinish(span);
span.finish();
}
Expand All @@ -82,7 +84,7 @@ public static void stopSpan(@Advice.This final AsyncResponse asyncResponse) {

public static class AsyncResponseThrowableAdvice {

@Advice.OnMethodExit(suppress = Throwable.class)
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
public static void stopSpan(
@Advice.This final AsyncResponse asyncResponse,
@Advice.Argument(0) final Throwable throwable) {
Comment thread
mcculls marked this conversation as resolved.
Expand All @@ -102,16 +104,21 @@ public static void stopSpan(

public static class AsyncResponseCancelAdvice {

@Advice.OnMethodExit(suppress = Throwable.class)
public static void stopSpan(@Advice.This final AsyncResponse asyncResponse) {
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
public static void stopSpan(
@Advice.This final AsyncResponse asyncResponse, @Advice.Thrown Throwable throwable) {

final ContextStore<AsyncResponse, AgentSpan> contextStore =
InstrumentationContext.get(AsyncResponse.class, AgentSpan.class);

final AgentSpan span = contextStore.get(asyncResponse);
if (span != null) {
contextStore.put(asyncResponse, null);
span.setTag("canceled", true);
if (throwable != null) {
DECORATE.onError(span, throwable);
} else {
span.setTag("canceled", true);
}
DECORATE.beforeFinish(span);
span.finish();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,17 @@ public void methodAdvice(MethodTransformer transformer) {

public static class AsyncResponseAdvice {

@Advice.OnMethodExit(suppress = Throwable.class)
public static void stopSpan(@Advice.This final AsyncResponse asyncResponse) {
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
Comment thread
mcculls marked this conversation as resolved.
public static void stopSpan(
@Advice.This final AsyncResponse asyncResponse, @Advice.Thrown Throwable throwable) {

final ContextStore<AsyncResponse, AgentSpan> contextStore =
InstrumentationContext.get(AsyncResponse.class, AgentSpan.class);

final AgentSpan span = contextStore.get(asyncResponse);
if (span != null) {
contextStore.put(asyncResponse, null);
DECORATE.onError(span, throwable);
DECORATE.beforeFinish(span);
span.finish();
}
Expand All @@ -82,7 +84,7 @@ public static void stopSpan(@Advice.This final AsyncResponse asyncResponse) {

public static class AsyncResponseThrowableAdvice {

@Advice.OnMethodExit(suppress = Throwable.class)
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
public static void stopSpan(
@Advice.This final AsyncResponse asyncResponse,
@Advice.Argument(0) final Throwable throwable) {
Comment thread
mcculls marked this conversation as resolved.
Expand All @@ -102,16 +104,21 @@ public static void stopSpan(

public static class AsyncResponseCancelAdvice {

@Advice.OnMethodExit(suppress = Throwable.class)
public static void stopSpan(@Advice.This final AsyncResponse asyncResponse) {
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
public static void stopSpan(
@Advice.This final AsyncResponse asyncResponse, @Advice.Thrown Throwable throwable) {

final ContextStore<AsyncResponse, AgentSpan> contextStore =
InstrumentationContext.get(AsyncResponse.class, AgentSpan.class);

final AgentSpan span = contextStore.get(asyncResponse);
if (span != null) {
contextStore.put(asyncResponse, null);
span.setTag("canceled", true);
if (throwable != null) {
DECORATE.onError(span, throwable);
} else {
span.setTag("canceled", true);
}
DECORATE.beforeFinish(span);
span.finish();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static AgentScope enter(@Advice.FieldValue("saved") final ContextMap cont
return null;
}

@Advice.OnMethodExit(suppress = Throwable.class)
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
public static void exit(@Advice.Enter final AgentScope agentScope) {
if (agentScope != null) {
agentScope.close();
Expand Down