Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5307b46

Browse files
vertx-redis: avoid double span creation and double handler calls (DataDog#6334)
* vertx-redis: avoid double span creation * vertx-redis: avoid double span creation
1 parent 2a7762c commit 5307b46

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

‎dd-java-agent/instrumentation/vertx-redis-client-3.9/src/main/java/datadog/trace/instrumentation/vertx_redis_client/RedisSendAdvice.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeSpan;
55
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.captureSpan;
66
import static datadog.trace.instrumentation.vertx_redis_client.VertxRedisClientDecorator.DECORATE;
7+
import static datadog.trace.instrumentation.vertx_redis_client.VertxRedisClientDecorator.REDIS_COMMAND;
78

89
import datadog.trace.bootstrap.CallDepthThreadLocalMap;
910
import datadog.trace.bootstrap.ContextStore;
@@ -52,8 +53,14 @@ public static AgentScope beforeSend(
5253
return AgentTracer.NoopAgentScope.INSTANCE;
5354
}
5455

55-
AgentSpan parentSan = activeSpan();
56-
AgentScope.Continuation parentContinuation = null == parentSan ? null : captureSpan(parentSan);
56+
AgentSpan parentSpan = activeSpan();
57+
58+
if (parentSpan != null && REDIS_COMMAND.equals(parentSpan.getOperationName())) {
59+
return null;
60+
}
61+
62+
AgentScope.Continuation parentContinuation =
63+
null == parentSpan ? null : captureSpan(parentSpan);
5764
final AgentSpan clientSpan =
5865
DECORATE.startAndDecorateSpan(
5966
request.command(), InstrumentationContext.get(Command.class, UTF8BytesString.class));

‎dd-java-agent/instrumentation/vertx-redis-client-3.9/src/main/java/datadog/trace/instrumentation/vertx_redis_client/ResponseHandler.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class ResponseHandler implements Handler<AsyncResult<Response>> {
1313
public final AgentSpan clientSpan;
1414
private final AgentScope.Continuation continuation;
1515
private final Promise<Response> promise;
16+
private boolean handled = false;
1617

1718
public ResponseHandler(
1819
final Promise<Response> promise,
@@ -25,7 +26,8 @@ public ResponseHandler(
2526

2627
@Override
2728
public void handle(final AsyncResult<Response> event) {
28-
if (clientSpan != null) {
29+
if (!handled && clientSpan != null) {
30+
handled = true;
2931
AgentScope scope = null;
3032
try {
3133
// Close client scope and span

‎dd-java-agent/instrumentation/vertx-redis-client-3.9/src/main/java/datadog/trace/instrumentation/vertx_redis_client/ResponseHandlerWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public void handle(final AsyncResult<Response> event) {
3131
already set so the handler state must be tracked here to prevent double execution
3232
*/
3333
if (!handled) {
34+
handled = true;
3435
AgentScope scope = null;
3536
try {
3637
if (null != clientSpan) {
@@ -44,7 +45,6 @@ public void handle(final AsyncResult<Response> event) {
4445
if (null != scope) {
4546
scope.close();
4647
}
47-
handled = true;
4848
}
4949
}
5050
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /