refactor pipeline in jedis-plugin (#445)

This commit is contained in:
xzyJavaX 2023-02-03 20:56:03 +08:00 committed by GitHub
parent 4012dc4ff7
commit 492fb6e356
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 269 additions and 233 deletions

View File

@ -11,6 +11,7 @@ Release Notes.
* Move the baseline to JDK 17 for development, the runtime baseline is still Java 8 compatible.
* Remove Powermock entirely from the test cases.
* Fix H2 instrumentation point
* Refactor pipeline in jedis-plugin.
#### Documentation
* Update docs of Tracing APIs, reorganize the API docs into six parts

View File

@ -26,6 +26,8 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceM
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
import org.apache.skywalking.apm.util.StringUtil;
import redis.clients.jedis.Pipeline;
import redis.clients.jedis.Transaction;
import java.lang.reflect.Method;
import java.util.Optional;
@ -41,9 +43,13 @@ public class JedisMethodInterceptor implements InstanceMethodsAroundInterceptor
SpanLayer.asCache(span);
String methodName = method.getName();
Tags.CACHE_TYPE.set(span, "Redis");
Tags.CACHE_CMD.set(span, methodName);
getKey(allArguments).ifPresent(key -> Tags.CACHE_KEY.set(span, key));
parseOperation(methodName).ifPresent(op -> Tags.CACHE_OP.set(span, op));
if (objInst instanceof Pipeline || objInst instanceof Transaction) {
Tags.CACHE_CMD.set(span, "BATCH_EXECUTE");
} else {
Tags.CACHE_CMD.set(span, methodName);
getKey(allArguments).ifPresent(key -> Tags.CACHE_KEY.set(span, key));
parseOperation(methodName).ifPresent(op -> Tags.CACHE_OP.set(span, op));
}
}
private Optional<String> getKey(Object[] allArguments) {

View File

@ -30,6 +30,7 @@ public class PipelineInstrumentation extends AbstractWitnessInstrumentation {
private static final String ENHANCE_CLASS = "redis.clients.jedis.Pipeline";
private static final String PIPELINE_SET_CLIENT_METHOD_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.jedis.v3.PipelineSetClientMethodInterceptor";
private static final String JEDIS_METHOD_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.jedis.v3.JedisMethodInterceptor";
@Override
public ClassMatch enhanceClass() {
@ -56,6 +57,23 @@ public class PipelineInstrumentation extends AbstractWitnessInstrumentation {
return PIPELINE_SET_CLIENT_METHOD_INTERCEPT_CLASS;
}
@Override
public boolean isOverrideArgs() {
return false;
}
},
new InstanceMethodsInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getMethodsMatcher() {
return named("sync").or(named("syncAndReturnAll")).or(named("discard"));
}
@Override
public String getMethodsInterceptor() {
return JEDIS_METHOD_INTERCEPT_CLASS;
}
@Override
public boolean isOverrideArgs() {
return false;

View File

@ -23,6 +23,7 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterc
import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static org.apache.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType;
import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
@ -30,6 +31,7 @@ public class TransactionConstructorInstrumentation extends AbstractWitnessInstru
private static final String ENHANCE_CLASS = "redis.clients.jedis.Transaction";
private static final String TRANSACTION_CONSTRUCTION_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.jedis.v3.TransactionConstructorInterceptor";
private static final String JEDIS_METHOD_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.jedis.v3.JedisMethodInterceptor";
private static final String ARGUMENT_TYPE_NAME = "redis.clients.jedis.Client";
@Override
@ -56,6 +58,23 @@ public class TransactionConstructorInstrumentation extends AbstractWitnessInstru
@Override
public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
return new InstanceMethodsInterceptPoint[0];
return new InstanceMethodsInterceptPoint[]{
new InstanceMethodsInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getMethodsMatcher() {
return named("exec").or(named("execGetResponse")).or(named("discard"));
}
@Override
public String getMethodsInterceptor() {
return JEDIS_METHOD_INTERCEPT_CLASS;
}
@Override
public boolean isOverrideArgs() {
return false;
}
}
};
}
}

View File

@ -17,8 +17,6 @@
jedis-2.x-3.x=org.apache.skywalking.apm.plugin.jedis.v3.define.JedisClusterInstrumentation
jedis-2.x-3.x=org.apache.skywalking.apm.plugin.jedis.v3.define.JedisInstrumentation
jedis-2.x-3.x=org.apache.skywalking.apm.plugin.jedis.v3.define.PipelineInstrumentation
jedis-2.x-3.x=org.apache.skywalking.apm.plugin.jedis.v3.define.PipelineBaseInstrumentation
jedis-2.x-3.x=org.apache.skywalking.apm.plugin.jedis.v3.define.MultiKeyPipelineBaseInstrumentation
jedis-2.x-3.x=org.apache.skywalking.apm.plugin.jedis.v3.define.TransactionConstructorInstrumentation

View File

@ -17,16 +17,22 @@
package org.apache.skywalking.apm.plugin.jedis.v4;
import redis.clients.jedis.CommandArguments;
import redis.clients.jedis.args.Rawable;
import java.util.Iterator;
public class ConnectionSendCmdInterceptor extends AbstractConnectionInterceptor {
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
import redis.clients.jedis.Connection;
import redis.clients.jedis.Jedis;
public class JedisConstructorInterceptor implements InstanceConstructorInterceptor {
@Override
protected Iterator<Rawable> getCommands(Object[] allArguments) {
CommandArguments commandArguments = (CommandArguments) allArguments[0];
return commandArguments.iterator();
public void onConstruct(EnhancedInstance objInst, Object[] allArguments) throws Throwable {
Connection connection = null;
if (allArguments[0] instanceof Jedis) {
connection = ((Jedis) allArguments[0]).getConnection();
} else if (allArguments[0] instanceof Connection) {
connection = (Connection) allArguments[0];
}
if (connection instanceof EnhancedInstance) {
objInst.setSkyWalkingDynamicField(((EnhancedInstance) connection).getSkyWalkingDynamicField());
}
}
}
}

View File

@ -0,0 +1,57 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.skywalking.apm.plugin.jedis.v4;
import org.apache.skywalking.apm.agent.core.context.ContextManager;
import org.apache.skywalking.apm.agent.core.context.tag.Tags;
import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
import java.lang.reflect.Method;
public class JedisMethodInterceptor implements InstanceMethodsAroundInterceptor {
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
MethodInterceptResult result) throws Throwable {
String peer = String.valueOf(objInst.getSkyWalkingDynamicField());
AbstractSpan span = ContextManager.createExitSpan("Jedis/" + method.getName(), peer);
span.setComponent(ComponentsDefine.JEDIS);
SpanLayer.asCache(span);
Tags.CACHE_TYPE.set(span, "Redis");
Tags.CACHE_CMD.set(span, "BATCH_EXECUTE");
}
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
Object ret) throws Throwable {
ContextManager.stopSpan();
return ret;
}
@Override
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
Class<?>[] argumentsTypes, Throwable t) {
AbstractSpan span = ContextManager.activeSpan();
span.log(t);
}
}

View File

@ -33,7 +33,6 @@ public class ConnectionInstrumentation extends AbstractWitnessInstrumentation {
private static final String ENHANCE_CLASS = "redis.clients.jedis.Connection";
private static final String CONNECTION_CONSTRUCTOR_INTERCEPTOR = "org.apache.skywalking.apm.plugin.jedis.v4.ConnectionConstructorInterceptor";
private static final String CONNECTION_EXECUTE_INTERCEPTOR = "org.apache.skywalking.apm.plugin.jedis.v4.ConnectionExecuteInterceptor";
private static final String CONNECTION_SEND_INTERCEPTOR = "org.apache.skywalking.apm.plugin.jedis.v4.ConnectionSendCmdInterceptor";
@Override
protected ClassMatch enhanceClass() {
@ -72,22 +71,6 @@ public class ConnectionInstrumentation extends AbstractWitnessInstrumentation {
return CONNECTION_EXECUTE_INTERCEPTOR;
}
@Override
public boolean isOverrideArgs() {
return false;
}
},
new InstanceMethodsInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getMethodsMatcher() {
return named("sendCommand").and(takesArgumentWithType(0, "redis.clients.jedis.CommandArguments"));
}
@Override
public String getMethodsInterceptor() {
return CONNECTION_SEND_INTERCEPTOR;
}
@Override
public boolean isOverrideArgs() {
return false;

View File

@ -15,21 +15,23 @@
* limitations under the License.
*/
package org.apache.skywalking.apm.plugin.jedis.v3.define;
package org.apache.skywalking.apm.plugin.jedis.v4.define;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
import net.bytebuddy.matcher.ElementMatchers;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
import org.apache.skywalking.apm.plugin.jedis.v3.RedisMethodMatch;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
public class PipelineBaseInstrumentation extends AbstractWitnessInstrumentation {
public class PipelineInstrumentation extends AbstractWitnessInstrumentation {
private static final String ENHANCE_CLASS = "redis.clients.jedis.PipelineBase";
private static final String JEDIS_METHOD_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.jedis.v3.JedisMethodInterceptor";
private static final String ENHANCE_CLASS = "redis.clients.jedis.Pipeline";
private static final String JEDIS_CONSTRUCTION_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.jedis.v4.JedisConstructorInterceptor";
private static final String JEDIS_METHOD_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.jedis.v4.JedisMethodInterceptor";
@Override
public ClassMatch enhanceClass() {
@ -38,7 +40,20 @@ public class PipelineBaseInstrumentation extends AbstractWitnessInstrumentation
@Override
public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return new ConstructorInterceptPoint[0];
return new ConstructorInterceptPoint[]{
new ConstructorInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getConstructorMatcher() {
return ElementMatchers.takesArgument(0, named("redis.clients.jedis.Jedis"))
.or(ElementMatchers.takesArgument(0, named("redis.clients.jedis.Connection")));
}
@Override
public String getConstructorInterceptor() {
return JEDIS_CONSTRUCTION_INTERCEPT_CLASS;
}
}
};
}
@Override
@ -47,7 +62,7 @@ public class PipelineBaseInstrumentation extends AbstractWitnessInstrumentation
new InstanceMethodsInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getMethodsMatcher() {
return RedisMethodMatch.INSTANCE.getJedisMethodMatcher();
return named("sync").or(named("syncAndReturnAll"));
}
@Override

View File

@ -15,40 +15,54 @@
* limitations under the License.
*/
package org.apache.skywalking.apm.plugin.jedis.v3.define;
package org.apache.skywalking.apm.plugin.jedis.v4.define;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
import net.bytebuddy.matcher.ElementMatchers;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.DeclaredInstanceMethodsInterceptPoint;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
import org.apache.skywalking.apm.plugin.jedis.v3.RedisMethodMatch;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
public class MultiKeyPipelineBaseInstrumentation extends AbstractWitnessInstrumentation {
public class TransactionConstructorInstrumentation extends AbstractWitnessInstrumentation {
private static final String ENHANCE_CLASS = "redis.clients.jedis.MultiKeyPipelineBase";
private static final String JEDIS_METHOD_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.jedis.v3.JedisMethodInterceptor";
private static final String ENHANCE_CLASS = "redis.clients.jedis.Transaction";
private static final String JEDIS_CONSTRUCTION_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.jedis.v4.JedisConstructorInterceptor";
private static final String JEDIS_METHOD_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.jedis.v4.JedisMethodInterceptor";
@Override
public ClassMatch enhanceClass() {
protected ClassMatch enhanceClass() {
return byName(ENHANCE_CLASS);
}
@Override
public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return new ConstructorInterceptPoint[0];
return new ConstructorInterceptPoint[]{
new ConstructorInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getConstructorMatcher() {
return ElementMatchers.takesArgument(0, named("redis.clients.jedis.Jedis"))
.or(ElementMatchers.takesArgument(0, named("redis.clients.jedis.Connection")));
}
@Override
public String getConstructorInterceptor() {
return JEDIS_CONSTRUCTION_INTERCEPT_CLASS;
}
}
};
}
@Override
public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
return new InstanceMethodsInterceptPoint[] {
new DeclaredInstanceMethodsInterceptPoint() {
return new InstanceMethodsInterceptPoint[]{
new InstanceMethodsInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getMethodsMatcher() {
return RedisMethodMatch.INSTANCE.getJedisMethodMatcher();
return named("exec").or(named("discard"));
}
@Override

View File

@ -14,4 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
jedis-4.x=org.apache.skywalking.apm.plugin.jedis.v4.define.ConnectionInstrumentation
jedis-4.x=org.apache.skywalking.apm.plugin.jedis.v4.define.ConnectionInstrumentation
jedis-4.x=org.apache.skywalking.apm.plugin.jedis.v4.define.PipelineInstrumentation
jedis-4.x=org.apache.skywalking.apm.plugin.jedis.v4.define.TransactionConstructorInstrumentation

View File

@ -86,7 +86,7 @@ segmentItems:
- {key: cache.cmd, value: del}
- {key: cache.key, value: a}
- {key: cache.op, value: write}
- operationName: Jedis/hset
- operationName: Jedis/syncAndReturnAll
operationId: 0
parentSpanId: 0
spanId: 5
@ -100,10 +100,8 @@ segmentItems:
skipAnalysis: false
tags:
- {key: cache.type, value: Redis}
- {key: cache.cmd, value: hset}
- {key: cache.key, value: a}
- {key: cache.op, value: write}
- operationName: Jedis/hget
- {key: cache.cmd, value: BATCH_EXECUTE}
- operationName: Jedis/discard
operationId: 0
parentSpanId: 0
spanId: 6
@ -117,10 +115,8 @@ segmentItems:
skipAnalysis: false
tags:
- {key: cache.type, value: Redis}
- {key: cache.cmd, value: hget}
- {key: cache.key, value: a}
- {key: cache.op, value: read}
- operationName: Jedis/hdel
- {key: cache.cmd, value: BATCH_EXECUTE}
- operationName: Jedis/exec
operationId: 0
parentSpanId: 0
spanId: 7
@ -134,10 +130,8 @@ segmentItems:
skipAnalysis: false
tags:
- {key: cache.type, value: Redis}
- {key: cache.cmd, value: hdel}
- {key: cache.key, value: a}
- {key: cache.op, value: write}
- operationName: Jedis/set
- {key: cache.cmd, value: BATCH_EXECUTE}
- operationName: Jedis/discard
operationId: 0
parentSpanId: 0
spanId: 8
@ -151,25 +145,7 @@ segmentItems:
skipAnalysis: false
tags:
- {key: cache.type, value: Redis}
- {key: cache.cmd, value: set}
- {key: cache.key, value: key}
- {key: cache.op, value: write}
- operationName: Jedis/expire
operationId: 0
parentSpanId: 0
spanId: 9
spanLayer: Cache
startTime: gt 0
endTime: gt 0
componentId: 30
isError: false
spanType: Exit
peer: redis-server:6379
skipAnalysis: false
tags:
- {key: cache.type, value: Redis}
- {key: cache.cmd, value: expire}
- {key: cache.key, value: key}
- {key: cache.cmd, value: BATCH_EXECUTE}
- operationName: GET:/jedis-scenario/case/jedis-scenario
operationId: 0
parentSpanId: -1

View File

@ -46,10 +46,12 @@ public class CaseController {
try (RedisPipelineCommandExecutor command = new RedisPipelineCommandExecutor(redisHost, redisPort)) {
command.pipelineExecute();
command.pipelineDiscard();
}
try (RedisTransactionCommandExecutor command = new RedisTransactionCommandExecutor(redisHost, redisPort)) {
command.multiExecute();
command.multiDiscard();
}
return SUCCESS;

View File

@ -36,7 +36,22 @@ public class RedisPipelineCommandExecutor implements AutoCloseable {
pipeline.syncAndReturnAll();
}
public void pipelineDiscard() {
Pipeline pipeline = jedis.pipelined();
pipeline.multi();
pipeline.hset("a", "a", "a");
pipeline.hget("a", "a");
pipeline.hdel("a", "a");
pipeline.discard();
}
public void close() throws Exception {
jedis.close();
// In the lower version(2.4.2, 2.5.2) of the test, jedis will close twice.
// Here, catch exceptions to prevent the impact on the test results.
try {
jedis.close();
} catch (Exception e) {
// ignore
}
}
}

View File

@ -35,6 +35,13 @@ public class RedisTransactionCommandExecutor implements AutoCloseable {
pipeline.exec();
}
public void multiDiscard() {
Transaction pipeline = jedis.multi();
pipeline.set("key", "a");
pipeline.expire("key", 5);
pipeline.discard();
}
public void close() throws Exception {
jedis.close();
}

View File

@ -87,7 +87,7 @@ segmentItems:
- {key: cache.cmd, value: del}
- {key: cache.key, value: a}
- {key: cache.op, value: write}
- operationName: Jedis/hset
- operationName: Jedis/syncAndReturnAll
operationId: 0
parentSpanId: 0
spanId: 5
@ -101,10 +101,8 @@ segmentItems:
skipAnalysis: false
tags:
- {key: cache.type, value: Redis}
- {key: cache.cmd, value: hset}
- {key: cache.key, value: a}
- {key: cache.op, value: write}
- operationName: Jedis/hget
- {key: cache.cmd, value: BATCH_EXECUTE}
- operationName: Jedis/discard
operationId: 0
parentSpanId: 0
spanId: 6
@ -117,11 +115,9 @@ segmentItems:
peer: redis-server:6379
skipAnalysis: false
tags:
- {key: cache.type, value: Redis}
- {key: cache.cmd, value: hget}
- {key: cache.key, value: a}
- {key: cache.op, value: read}
- operationName: Jedis/hdel
- { key: cache.type, value: Redis }
- { key: cache.cmd, value: BATCH_EXECUTE }
- operationName: Jedis/exec
operationId: 0
parentSpanId: 0
spanId: 7
@ -135,10 +131,8 @@ segmentItems:
skipAnalysis: false
tags:
- {key: cache.type, value: Redis}
- {key: cache.cmd, value: hdel}
- {key: cache.key, value: a}
- {key: cache.op, value: write}
- operationName: Jedis/set
- {key: cache.cmd, value: BATCH_EXECUTE}
- operationName: Jedis/discard
operationId: 0
parentSpanId: 0
spanId: 8
@ -151,30 +145,12 @@ segmentItems:
peer: redis-server:6379
skipAnalysis: false
tags:
- {key: cache.type, value: Redis}
- {key: cache.cmd, value: set}
- {key: cache.key, value: key}
- {key: cache.op, value: write}
- operationName: Jedis/expire
operationId: 0
parentSpanId: 0
spanId: 9
spanLayer: Cache
startTime: gt 0
endTime: gt 0
componentId: 30
isError: false
spanType: Exit
peer: redis-server:6379
skipAnalysis: false
tags:
- {key: cache.type, value: Redis}
- {key: cache.cmd, value: expire}
- {key: cache.key, value: key}
- { key: cache.type, value: Redis }
- { key: cache.cmd, value: BATCH_EXECUTE }
- operationName: Jedis/xadd
operationId: 0
parentSpanId: 0
spanId: 10
spanId: 9
spanLayer: Cache
startTime: gt 0
endTime: gt 0
@ -191,7 +167,7 @@ segmentItems:
- operationName: Jedis/xread
operationId: 0
parentSpanId: 0
spanId: 11
spanId: 10
spanLayer: Cache
startTime: gt 0
endTime: gt 0
@ -207,7 +183,7 @@ segmentItems:
- operationName: Jedis/xdel
operationId: 0
parentSpanId: 0
spanId: 12
spanId: 11
spanLayer: Cache
startTime: gt 0
endTime: gt 0
@ -236,4 +212,4 @@ segmentItems:
tags:
- {key: url, value: 'http://localhost:8080/jedis-scenario/case/jedis-scenario'}
- {key: http.method, value: GET}
- {key: http.status_code, value: '200'}
- {key: http.status_code, value: '200'}

View File

@ -46,10 +46,12 @@ public class CaseController {
try (RedisPipelineCommandExecutor command = new RedisPipelineCommandExecutor(redisHost, redisPort)) {
command.pipelineExecute();
command.pipelineDiscard();
}
try (RedisTransactionCommandExecutor command = new RedisTransactionCommandExecutor(redisHost, redisPort)) {
command.multiExecute();
command.multiDiscard();
}
try (RedisStreamCommandExecutor c = new RedisStreamCommandExecutor(redisHost, redisPort)) {
c.exec();

View File

@ -36,6 +36,15 @@ public class RedisPipelineCommandExecutor implements AutoCloseable {
pipeline.syncAndReturnAll();
}
public void pipelineDiscard() {
Pipeline pipeline = jedis.pipelined();
pipeline.multi();
pipeline.hset("a", "a", "a");
pipeline.hget("a", "a");
pipeline.hdel("a", "a");
pipeline.discard();
}
public void close() throws Exception {
jedis.close();
}

View File

@ -35,6 +35,13 @@ public class RedisTransactionCommandExecutor implements AutoCloseable {
pipeline.exec();
}
public void multiDiscard() {
Transaction pipeline = jedis.multi();
pipeline.set("key", "a");
pipeline.expire("key", 5);
pipeline.discard();
}
public void close() throws Exception {
jedis.close();
}

View File

@ -20,26 +20,10 @@ segmentItems:
segments:
- segmentId: not null
spans:
- operationName: Jedis/echo
operationId: 0
parentSpanId: 0
spanId: 1
spanLayer: Cache
startTime: gt 0
endTime: gt 0
componentId: 30
isError: false
spanType: Exit
peer: redis-server:6379
skipAnalysis: false
tags:
- {key: cache.key, value: Test}
- {key: cache.cmd, value: echo}
- {key: cache.type, value: Redis}
- operationName: Jedis/set
operationId: 0
parentSpanId: 0
spanId: 2
spanId: 1
spanLayer: Cache
startTime: gt 0
endTime: gt 0
@ -56,7 +40,7 @@ segmentItems:
- operationName: Jedis/get
operationId: 0
parentSpanId: 0
spanId: 3
spanId: 2
spanLayer: Cache
startTime: gt 0
endTime: gt 0
@ -73,7 +57,7 @@ segmentItems:
- operationName: Jedis/del
operationId: 0
parentSpanId: 0
spanId: 4
spanId: 3
spanLayer: Cache
startTime: gt 0
endTime: gt 0
@ -87,7 +71,22 @@ segmentItems:
- {key: cache.cmd, value: del}
- {key: cache.type, value: Redis}
- {key: cache.op, value: write}
- operationName: Jedis/hset
- operationName: Jedis/syncAndReturnAll
operationId: 0
parentSpanId: 0
spanId: 4
spanLayer: Cache
startTime: gt 0
endTime: gt 0
componentId: 30
isError: false
spanType: Exit
peer: redis-server:6379
skipAnalysis: false
tags:
- {key: cache.type, value: Redis}
- {key: cache.cmd, value: BATCH_EXECUTE}
- operationName: Jedis/exec
operationId: 0
parentSpanId: 0
spanId: 5
@ -100,11 +99,9 @@ segmentItems:
peer: redis-server:6379
skipAnalysis: false
tags:
- {key: cache.key, value: a}
- {key: cache.cmd, value: hset}
- {key: cache.type, value: Redis}
- {key: cache.op, value: write}
- operationName: Jedis/hget
- {key: cache.cmd, value: BATCH_EXECUTE}
- operationName: Jedis/discard
operationId: 0
parentSpanId: 0
spanId: 6
@ -117,94 +114,12 @@ segmentItems:
peer: redis-server:6379
skipAnalysis: false
tags:
- {key: cache.key, value: a}
- {key: cache.cmd, value: hget}
- {key: cache.type, value: Redis}
- {key: cache.op, value: read}
- operationName: Jedis/hdel
operationId: 0
parentSpanId: 0
spanId: 7
spanLayer: Cache
startTime: gt 0
endTime: gt 0
componentId: 30
isError: false
spanType: Exit
peer: redis-server:6379
skipAnalysis: false
tags:
- {key: cache.key, value: a}
- {key: cache.cmd, value: hdel}
- {key: cache.type, value: Redis}
- {key: cache.op, value: write}
- operationName: Jedis/multi
operationId: 0
parentSpanId: 0
spanId: 8
spanLayer: Cache
startTime: gt 0
endTime: gt 0
componentId: 30
isError: false
spanType: Exit
peer: redis-server:6379
skipAnalysis: false
tags:
- {key: cache.cmd, value: multi}
- {key: cache.type, value: Redis}
- operationName: Jedis/set
operationId: 0
parentSpanId: 0
spanId: 9
spanLayer: Cache
startTime: gt 0
endTime: gt 0
componentId: 30
isError: false
spanType: Exit
peer: redis-server:6379
skipAnalysis: false
tags:
- {key: cache.key, value: key}
- {key: cache.cmd, value: set}
- {key: cache.type, value: Redis}
- {key: cache.op, value: write}
- operationName: Jedis/expire
operationId: 0
parentSpanId: 0
spanId: 10
spanLayer: Cache
startTime: gt 0
endTime: gt 0
componentId: 30
isError: false
spanType: Exit
peer: redis-server:6379
skipAnalysis: false
tags:
- {key: cache.key, value: key}
- {key: cache.cmd, value: expire}
- {key: cache.type, value: Redis}
- operationName: Jedis/exec
operationId: 0
parentSpanId: 0
spanId: 11
spanLayer: Cache
startTime: gt 0
endTime: gt 0
componentId: 30
isError: false
spanType: Exit
peer: redis-server:6379
skipAnalysis: false
tags:
- {key: cache.cmd, value: exec}
- {key: cache.type, value: Redis}
- {key: cache.cmd, value: BATCH_EXECUTE}
- operationName: Jedis/xadd
operationId: 0
parentSpanId: 0
spanId: 12
spanId: 7
spanLayer: Cache
startTime: gt 0
endTime: gt 0
@ -221,7 +136,7 @@ segmentItems:
- operationName: Jedis/xread
operationId: 0
parentSpanId: 0
spanId: 13
spanId: 8
spanLayer: Cache
startTime: gt 0
endTime: gt 0
@ -237,7 +152,7 @@ segmentItems:
- operationName: Jedis/xdel
operationId: 0
parentSpanId: 0
spanId: 14
spanId: 9
spanLayer: Cache
startTime: gt 0
endTime: gt 0

View File

@ -50,6 +50,7 @@ public class CaseController {
try (RedisTransactionCommandExecutor command = new RedisTransactionCommandExecutor(redisHost, redisPort)) {
command.multiExecute();
command.multiDiscard();
}
try (RedisStreamCommandExecutor executor = new RedisStreamCommandExecutor(redisHost, redisPort)) {
executor.exec();

View File

@ -35,6 +35,13 @@ public class RedisTransactionCommandExecutor implements AutoCloseable {
pipeline.exec();
}
public void multiDiscard() {
Transaction pipeline = jedis.multi();
pipeline.set("key", "a");
pipeline.expire("key", 5);
pipeline.discard();
}
public void close() throws Exception {
jedis.close();
}