Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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 @@ -63,6 +63,10 @@ public void end(
public static AdviceScope onEnter(@Advice.Argument(0) RedisCommand<?, ?, ?> command) {

Context parentContext = currentContext();
if (!instrumenter().shouldStart(parentContext, command)) {
return null;
}

Context context = instrumenter().start(parentContext, command);
// remember the context that called dispatch, it is used in LettuceAsyncCommandInstrumentation
context = context.with(LettuceSingletons.COMMAND_CONTEXT_KEY, parentContext);
Expand All @@ -75,7 +79,9 @@ public static void onExit(
@Advice.Thrown Throwable throwable,
@Advice.Return AsyncCommand<?, ?, ?> asyncCommand,
@Advice.Enter AdviceScope adviceScope) {
adviceScope.end(throwable, command, asyncCommand);
if (adviceScope != null) {
adviceScope.end(throwable, command, asyncCommand);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ public void end(Throwable throwable, RedisURI redisUri) {

@Advice.OnMethodEnter(suppress = Throwable.class)
public static AdviceScope onEnter(@Advice.Argument(1) RedisURI redisUri) {
Context context = connectInstrumenter().start(currentContext(), redisUri);
Context parentContext = currentContext();
if (!connectInstrumenter().shouldStart(parentContext, redisUri)) {
return null;
}

Context context = connectInstrumenter().start(parentContext, redisUri);
return new AdviceScope(context, context.makeCurrent());
}

Expand All @@ -63,7 +68,9 @@ public static void onExit(
@Advice.Argument(1) RedisURI redisUri,
@Advice.Thrown @Nullable Throwable throwable,
@Advice.Enter AdviceScope adviceScope) {
adviceScope.end(throwable, redisUri);
if (adviceScope != null) {
adviceScope.end(throwable, redisUri);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ public void end(
public static AdviceScope onEnter(@Advice.Argument(0) RedisCommand<?, ?, ?> command) {

Context parentContext = currentContext();
if (!instrumenter().shouldStart(parentContext, command)) {
return null;
}

Context context = instrumenter().start(parentContext, command);
// remember the context that called dispatch, it is used in LettuceAsyncCommandInstrumentation
context = context.with(LettuceSingletons.COMMAND_CONTEXT_KEY, parentContext);
Expand All @@ -88,7 +92,9 @@ public static void stopSpan(
@Advice.Return AsyncCommand<?, ?, ?> asyncCommand,
@Advice.Enter AdviceScope adviceScope) {

adviceScope.end(throwable, command, asyncCommand);
if (adviceScope != null) {
adviceScope.end(throwable, command, asyncCommand);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ public void end(

@Advice.OnMethodEnter(suppress = Throwable.class)
public static AdviceScope onEnter(@Advice.Argument(1) RedisURI redisUri) {
Context context = connectInstrumenter().start(currentContext(), redisUri);
Context parentContext = currentContext();
if (!connectInstrumenter().shouldStart(parentContext, redisUri)) {
return null;
}

Context context = connectInstrumenter().start(parentContext, redisUri);
return new AdviceScope(context, context.makeCurrent());
}

Expand All @@ -82,7 +87,9 @@ public static void stopSpan(
@Advice.Thrown @Nullable Throwable throwable,
@Advice.Return ConnectionFuture<?> connectionFuture,
@Advice.Enter AdviceScope adviceScope) {
adviceScope.end(throwable, redisUri, connectionFuture);
if (adviceScope != null) {
adviceScope.end(throwable, redisUri, connectionFuture);
}
}
}
}
Loading