Skip to content

Commit

Permalink
Merge pull request #387 from DataDog/ark/enable-lettuce
Browse files Browse the repository at this point in the history
Enable Lettuce instrumentation by default
  • Loading branch information
mar-kolya authored Jul 19, 2018
2 parents 37a54b5 + 269e330 commit c0dae09
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@
@AutoService(Instrumenter.class)
public class LettuceAsyncCommandsInstrumentation extends Instrumenter.Default {

public static final String PACKAGE =
LettuceAsyncCommandsInstrumentation.class.getPackage().getName();

public LettuceAsyncCommandsInstrumentation() {
super("lettuce", "lettuce-5-async");
}

@Override
protected boolean defaultEnabled() {
return false;
}

@Override
public ElementMatcher typeMatcher() {
return named("io.lettuce.core.AbstractRedisAsyncCommands");
Expand All @@ -34,9 +32,7 @@ public ElementMatcher<? super ClassLoader> classLoaderMatcher() {
@Override
public String[] helperClassNames() {
return new String[] {
LettuceAsyncCommandsInstrumentation.class.getPackage().getName() + ".LettuceAsyncBiFunction",
LettuceAsyncCommandsInstrumentation.class.getPackage().getName()
+ ".LettuceInstrumentationUtil"
PACKAGE + ".LettuceAsyncBiFunction", PACKAGE + ".LettuceInstrumentationUtil"
};
}

Expand All @@ -47,7 +43,8 @@ public Map<ElementMatcher, String> transformers() {
isMethod()
.and(named("dispatch"))
.and(takesArgument(0, named("io.lettuce.core.protocol.RedisCommand"))),
LettuceAsyncCommandsAdvice.class.getName());
// Cannot reference class directly here because this would lead to class load failure on Java7
PACKAGE + ".LettuceAsyncCommandsAdvice");
return transformers;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,19 @@
@AutoService(Instrumenter.class)
public final class LettuceClientInstrumentation extends Instrumenter.Default {

public static final String PACKAGE = LettuceClientInstrumentation.class.getPackage().getName();

private static final String[] HELPER_CLASS_NAMES =
new String[] {
LettuceReactiveCommandsInstrumentation.class.getPackage().getName()
+ ".LettuceInstrumentationUtil",
LettuceClientInstrumentation.class.getPackage().getName() + ".LettuceAsyncBiFunction"
PACKAGE + ".LettuceAsyncBiFunction"
};

public LettuceClientInstrumentation() {
super("lettuce");
}

@Override
protected boolean defaultEnabled() {
return false;
}

@Override
public ElementMatcher typeMatcher() {
return named("io.lettuce.core.RedisClient");
Expand All @@ -53,7 +50,8 @@ public Map<ElementMatcher, String> transformers() {
.and(nameStartsWith("connect"))
.and(nameEndsWith("Async"))
.and(takesArgument(1, named("io.lettuce.core.RedisURI"))),
ConnectionFutureAdvice.class.getName());
// Cannot reference class directly here because this would lead to class load failure on Java7
PACKAGE + ".ConnectionFutureAdvice");
return transformers;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,20 @@

import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.instrumentation.lettuce.rx.LettuceFluxCreationAdvice;
import datadog.trace.instrumentation.lettuce.rx.LettuceMonoCreationAdvice;
import java.util.HashMap;
import java.util.Map;
import net.bytebuddy.matcher.ElementMatcher;

@AutoService(Instrumenter.class)
public class LettuceReactiveCommandsInstrumentation extends Instrumenter.Default {

public static final String PACKAGE =
LettuceReactiveCommandsInstrumentation.class.getPackage().getName();

public LettuceReactiveCommandsInstrumentation() {
super("lettuce", "lettuce-5-rx");
}

@Override
protected boolean defaultEnabled() {
return false;
}

@Override
public ElementMatcher typeMatcher() {
return named("io.lettuce.core.AbstractRedisReactiveCommands");
Expand All @@ -36,18 +32,12 @@ public ElementMatcher<? super ClassLoader> classLoaderMatcher() {
@Override
public String[] helperClassNames() {
return new String[] {
LettuceReactiveCommandsInstrumentation.class.getPackage().getName()
+ ".LettuceInstrumentationUtil",
LettuceReactiveCommandsInstrumentation.class.getPackage().getName()
+ ".rx.LettuceMonoCreationAdvice",
LettuceReactiveCommandsInstrumentation.class.getPackage().getName()
+ ".rx.LettuceMonoDualConsumer",
LettuceReactiveCommandsInstrumentation.class.getPackage().getName()
+ ".rx.LettuceFluxCreationAdvice",
LettuceReactiveCommandsInstrumentation.class.getPackage().getName()
+ ".rx.LettuceFluxTerminationRunnable",
LettuceReactiveCommandsInstrumentation.class.getPackage().getName()
+ ".rx.LettuceFluxTerminationRunnable$FluxOnSubscribeConsumer"
PACKAGE + ".LettuceInstrumentationUtil",
PACKAGE + ".rx.LettuceMonoCreationAdvice",
PACKAGE + ".rx.LettuceMonoDualConsumer",
PACKAGE + ".rx.LettuceFluxCreationAdvice",
PACKAGE + ".rx.LettuceFluxTerminationRunnable",
PACKAGE + ".rx.LettuceFluxTerminationRunnable$FluxOnSubscribeConsumer"
};
}

Expand All @@ -59,14 +49,16 @@ public Map<ElementMatcher, String> transformers() {
.and(named("createMono"))
.and(takesArgument(0, named("java.util.function.Supplier")))
.and(returns(named("reactor.core.publisher.Mono"))),
LettuceMonoCreationAdvice.class.getName());
// Cannot reference class directly here because this would lead to class load failure on Java7
PACKAGE + ".rx.LettuceMonoCreationAdvice");
transformers.put(
isMethod()
.and(nameStartsWith("create"))
.and(nameEndsWith("Flux"))
.and(takesArgument(0, named("java.util.function.Supplier")))
.and(returns(named(("reactor.core.publisher.Flux")))),
LettuceFluxCreationAdvice.class.getName());
// Cannot reference class directly here because this would lead to class load failure on Java7
PACKAGE + ".rx.LettuceFluxCreationAdvice");

return transformers;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ import static datadog.trace.agent.test.ListWriterAssert.assertTraces
import static datadog.trace.instrumentation.lettuce.LettuceInstrumentationUtil.AGENT_CRASHING_COMMAND_PREFIX

class LettuceAsyncClientTest extends AgentTestRunner {

static {
System.setProperty("dd.integration.lettuce.enabled", "true")
}

public static final String HOST = "127.0.0.1"
public static final int PORT = TestUtils.randomOpenPort()
public static final int INCORRECT_PORT = TestUtils.randomOpenPort()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ import static datadog.trace.agent.test.ListWriterAssert.assertTraces
import static datadog.trace.instrumentation.lettuce.LettuceInstrumentationUtil.AGENT_CRASHING_COMMAND_PREFIX

class LettuceReactiveClientTest extends AgentTestRunner {

static {
System.setProperty("dd.integration.lettuce.enabled", "true")
}

public static final String HOST = "127.0.0.1"
public static final int PORT = TestUtils.randomOpenPort()
public static final int DB_INDEX = 0
Expand Down Expand Up @@ -60,7 +55,7 @@ class LettuceReactiveClientTest extends AgentTestRunner {
connection.close()
redisServer.stop()
}

def "set command with subscribe on a defined consumer"() {
setup:
def conds = new AsyncConditions()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ import static datadog.trace.agent.test.ListWriterAssert.assertTraces
import static datadog.trace.instrumentation.lettuce.LettuceInstrumentationUtil.AGENT_CRASHING_COMMAND_PREFIX

class LettuceSyncClientTest extends AgentTestRunner {

static {
System.setProperty("dd.integration.lettuce.enabled", "true")
}

public static final String HOST = "127.0.0.1"
public static final int PORT = TestUtils.randomOpenPort()
public static final int INCORRECT_PORT = TestUtils.randomOpenPort()
Expand Down

0 comments on commit c0dae09

Please sign in to comment.