diff --git a/instrumentation/jedis-4.0.0/build.gradle b/instrumentation/jedis-4.0.0/build.gradle index 8b080a5d03..71dd01a388 100644 --- a/instrumentation/jedis-4.0.0/build.gradle +++ b/instrumentation/jedis-4.0.0/build.gradle @@ -13,10 +13,7 @@ dependencies { verifyInstrumentation { passes 'redis.clients:jedis:[4.0.0,)' fails 'redis.clients:jedis:[1.4.0,3.8.0]' -// fails 'redis.clients:jedis:[4.0.0,)' excludeRegex 'redis.clients:jedis:.*-(m|rc|RC|beta)[0-9]*' - // there's something weird about how the verifier treats this version -// exclude 'redis.clients:jedis:3.6.2' } site { diff --git a/instrumentation/jedis-4.0.0/src/main/java/redis/clients/jedis/Connection_Instrumentation.java b/instrumentation/jedis-4.0.0/src/main/java/redis/clients/jedis/Connection_Instrumentation.java index baeae7b80f..cd4135685e 100644 --- a/instrumentation/jedis-4.0.0/src/main/java/redis/clients/jedis/Connection_Instrumentation.java +++ b/instrumentation/jedis-4.0.0/src/main/java/redis/clients/jedis/Connection_Instrumentation.java @@ -28,22 +28,7 @@ public abstract class Connection_Instrumentation { @NewField private long db = 0; - @NewField - private String host; - - @NewField - private int port; - - @NewField - private HostAndPort hostAndPort; - - final HostAndPort getHostAndPort() { - this.hostAndPort = Weaver.callOriginal(); - this.host = this.hostAndPort.getHost(); - this.port = this.hostAndPort.getPort(); - return this.hostAndPort; - - } + abstract HostAndPort getHostAndPort(); public void disconnect() { db = 0; @@ -70,7 +55,7 @@ public void sendCommand(final CommandArguments args) { Weaver.callOriginal(); ProtocolCommand cmd = args.getCommand(); - reportMethodAsExternal(cmd, this.host, this.port); + reportMethodAsExternal(cmd); } @@ -86,7 +71,7 @@ private void updateDbIndex(ProtocolCommand cmd, String arg0) { } } - private void reportMethodAsExternal(ProtocolCommand command, String serverUsed, int serverPortUsed) { + private void reportMethodAsExternal(ProtocolCommand command) { String operation = "unknown"; try { @@ -98,7 +83,7 @@ private void reportMethodAsExternal(ProtocolCommand command, String serverUsed, .product(DatastoreVendor.Redis.name()) .collection(null) .operation(operation) - .instance(serverUsed, serverPortUsed) + .instance(getHostAndPort().getHost(), getHostAndPort().getPort()) .databaseName(String.valueOf(db)) .build()); } diff --git a/instrumentation/jedis-4.0.0/src/main/java/redis/clients/jedis/JedisPubSub_Instrumentation.java b/instrumentation/jedis-4.0.0/src/main/java/redis/clients/jedis/JedisPubSub_Instrumentation.java index b857843d6a..6902183950 100644 --- a/instrumentation/jedis-4.0.0/src/main/java/redis/clients/jedis/JedisPubSub_Instrumentation.java +++ b/instrumentation/jedis-4.0.0/src/main/java/redis/clients/jedis/JedisPubSub_Instrumentation.java @@ -12,7 +12,6 @@ import com.newrelic.api.agent.NewRelic; import com.newrelic.api.agent.Trace; import com.newrelic.api.agent.weaver.MatchType; -import com.newrelic.api.agent.weaver.NewField; import com.newrelic.api.agent.weaver.Weave; import com.newrelic.api.agent.weaver.Weaver; @@ -20,71 +19,56 @@ @Weave(type = MatchType.BaseClass, originalName = "redis.clients.jedis.JedisPubSub") public class JedisPubSub_Instrumentation { - @NewField - private String host; - - @NewField - private int port; - - @Trace - private void process() { - Weaver.callOriginal(); - } - - public void proceed(Connection client, String... channels) { - this.host = client.getHostAndPort().getHost(); - this.port = client.getHostAndPort().getPort(); - Weaver.callOriginal(); - } + private volatile Connection client; @Trace public void onMessage(String channel, String message) { Weaver.callOriginal(); - reportMethodAsExternal("message", host, port); + reportMethodAsExternal("message"); } @Trace public void onPMessage(String pattern, String channel, String message) { Weaver.callOriginal(); - reportMethodAsExternal("message", host, port); + reportMethodAsExternal("message"); } @Trace public void onSubscribe(String channel, int subscribedChannels) { Weaver.callOriginal(); - reportMethodAsExternal("subscribe", host, port); + reportMethodAsExternal("subscribe"); } @Trace public void onUnsubscribe(String channel, int subscribedChannels) { Weaver.callOriginal(); - reportMethodAsExternal("unsubscribe", host, port); + reportMethodAsExternal("unsubscribe"); } @Trace public void onPUnsubscribe(String pattern, int subscribedChannels) { Weaver.callOriginal(); - reportMethodAsExternal("unsubscribe", host, port); + reportMethodAsExternal("unsubscribe"); } @Trace public void onPSubscribe(String pattern, int subscribedChannels) { Weaver.callOriginal(); - reportMethodAsExternal("subscribe", host, port); + reportMethodAsExternal("subscribe"); } - private void reportMethodAsExternal(String commandName, String host, int port) { + private void reportMethodAsExternal(String commandName) { NewRelic.getAgent().getTracedMethod().reportAsExternal(DatastoreParameters .product(DatastoreVendor.Redis.name()) .collection(null) .operation(commandName) - .instance(host, port) + .instance(client.getHostAndPort().getHost(), client.getHostAndPort().getPort()) .build()); } }