fix issue 4879 (#4954)

This commit is contained in:
yangy 2020-06-20 21:21:22 +08:00 committed by GitHub
parent 520cee30f3
commit b1b144480d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 0 deletions

View File

@ -20,7 +20,9 @@ package org.apache.skywalking.apm.plugin.lettuce.v5;
import io.lettuce.core.protocol.AsyncCommand;
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;
@ -40,6 +42,8 @@ public class AsyncCommandMethodInterceptor implements InstanceMethodsAroundInter
String operationName = "Lettuce/" + asyncCommand.getType().name();
AbstractSpan span = ContextManager.createLocalSpan(operationName + "/onComplete");
span.setComponent(ComponentsDefine.LETTUCE);
Tags.DB_TYPE.set(span, "Redis");
SpanLayer.asCache(span);
if (allArguments[0] instanceof Consumer) {
allArguments[0] = new SWConsumer((Consumer) allArguments[0], ContextManager.capture(), operationName);
} else {

View File

@ -20,7 +20,9 @@ package org.apache.skywalking.apm.plugin.lettuce.v5;
import org.apache.skywalking.apm.agent.core.context.ContextManager;
import org.apache.skywalking.apm.agent.core.context.ContextSnapshot;
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.network.trace.component.ComponentsDefine;
import java.util.function.BiConsumer;
@ -41,6 +43,8 @@ public class SWBiConsumer<T, U> implements BiConsumer<T, U> {
public void accept(T t, U u) {
AbstractSpan span = ContextManager.createLocalSpan(operationName + "/accept");
span.setComponent(ComponentsDefine.LETTUCE);
Tags.DB_TYPE.set(span, "Redis");
SpanLayer.asCache(span);
try {
ContextManager.continued(snapshot);
biConsumer.accept(t, u);

View File

@ -20,7 +20,9 @@ package org.apache.skywalking.apm.plugin.lettuce.v5;
import org.apache.skywalking.apm.agent.core.context.ContextManager;
import org.apache.skywalking.apm.agent.core.context.ContextSnapshot;
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.network.trace.component.ComponentsDefine;
import java.util.function.Consumer;
@ -41,6 +43,8 @@ public class SWConsumer<T> implements Consumer<T> {
public void accept(T t) {
AbstractSpan span = ContextManager.createLocalSpan(operationName + "/accept");
span.setComponent(ComponentsDefine.LETTUCE);
Tags.DB_TYPE.set(span, "Redis");
SpanLayer.asCache(span);
try {
ContextManager.continued(snapshot);
consumer.accept(t);