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 @@ -21,6 +21,7 @@ dependencies {
testImplementation group: 'io.lettuce', name: 'lettuce-core', version: '5.0.0.RELEASE'
testImplementation project(':dd-java-agent:instrumentation:reactor-core-3.1')
testImplementation project(':dd-java-agent:instrumentation:reactive-streams-1.0')
testImplementation project(':dd-java-agent:instrumentation:netty:netty-promise-4.0')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 Badge Enable netty-promise in the Lettuce test JVM

Adding the module as a test dependency does not make these Lettuce tests exercise it: InstrumenterModule enables modules from isIntegrationEnabled(..., defaultEnabled()), and NettyPromiseInstrumentation.defaultEnabled() returns false, so its listener wrapping remains disabled unless the test injects dd.integration.netty-promise.enabled=true (as the netty-promise tests do). In the latest-dependency strict-write run this means the new dependency gives false coverage for the netty-promise interaction this change is trying to validate; enable that config in the Lettuce test setup or use a runtime path that turns the instrumentation on.

Useful? React with 👍 / 👎.



latestDepTestImplementation group: 'io.lettuce', name: 'lettuce-core', version: '+'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package datadog.trace.instrumentation.lettuce5;

import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
import static datadog.trace.instrumentation.lettuce5.LettuceClientDecorator.DECORATE;

import datadog.trace.bootstrap.InstrumentationContext;
import datadog.trace.bootstrap.instrumentation.api.AgentScope;
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import io.lettuce.core.ConnectionFuture;
import io.lettuce.core.RedisURI;
Expand All @@ -14,28 +12,29 @@

public class ConnectionFutureAdvice {
@Advice.OnMethodEnter(suppress = Throwable.class)
public static AgentScope onEnter(@Advice.Argument(1) final RedisURI redisUri) {
public static AgentSpan onEnter(@Advice.Argument(1) final RedisURI redisUri) {
final AgentSpan span =
startSpan(
LettuceClientDecorator.REDIS_CLIENT.toString(), LettuceClientDecorator.OPERATION_NAME);
DECORATE.afterStart(span);
span.setResourceName(DECORATE.resourceNameForConnection(redisUri));
DECORATE.onConnection(span, redisUri);
return activateSpan(span);
return span;
}

@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
public static void stopSpan(
@Advice.Enter final AgentScope scope,
@Advice.Enter final AgentSpan span,
@Advice.Thrown final Throwable throwable,
@Advice.Argument(1) final RedisURI redisUri,
@Advice.Return(readOnly = false)
ConnectionFuture<? extends StatefulConnection> connectionFuture) {
final AgentSpan span = scope.span();
if (span == null) {
return;
}
if (throwable != null) {
DECORATE.onError(span, throwable);
DECORATE.beforeFinish(span);
scope.close();
span.finish();
return;
}
Expand All @@ -44,7 +43,7 @@ public static void stopSpan(
new ConnectionContextBiConsumer(
redisUri, InstrumentationContext.get(StatefulConnection.class, RedisURI.class))
.andThen(new LettuceAsyncBiConsumer<>(span)));
scope.close();

// span finished by LettuceAsyncBiConsumer
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@ abstract class Lettuce5ClientTestBase extends VersionedNamingTestBase {
RedisAsyncCommands<String, ?> asyncCommands
RedisCommands<String, ?> syncCommands

@Override
boolean useStrictTraceWrites() {
// latest seems leaking continuations that terminates later hence the strict trace will discard our spans.
!isLatestDepTest
}


def setup() {
redisServer.start()
println "Using redis: $redisServer.redisURI"
Expand Down