Feature: Support for tracking for lettuce versions 6.5+ (#760)

This commit is contained in:
changhao.ni 2025-06-25 11:41:46 +08:00 committed by GitHub
parent 7f9287fcb1
commit b1f18f36ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
36 changed files with 877 additions and 39 deletions

View File

@ -72,6 +72,7 @@ jobs:
- kafka-scenario
- kotlin-coroutine-scenario
- lettuce-scenario
- lettuce-6.5.x-scenario
- mongodb-3.x-scenario
- mongodb-4.x-scenario
- netty-socketio-scenario

View File

@ -14,6 +14,7 @@ Release Notes.
* Fix retransform failure when enhancing both parent and child classes.
* Add support for `dameng(DM)` JDBC url format in `URLParser`.
* Fix RabbitMQ Consumer could not receive handleCancelOk callback.
* Support for tracking in lettuce versions 6.5.x and above.
All issues and pull requests are [here](https://github.com/apache/skywalking/milestone/236?closed=1)

View File

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
~
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.skywalking</groupId>
<artifactId>lettuce-plugins</artifactId>
<version>9.5.0-SNAPSHOT</version>
</parent>
<artifactId>apm-lettuce-5.x-6.4.x-plugin</artifactId>
<packaging>jar</packaging>
<name>lettuce-5.x-6.4.x-plugin</name>
<properties>
<lettuce-core.version>5.0.0.RELEASE</lettuce-core.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>apm-lettuce-common</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
<version>${lettuce-core.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,29 @@
/*
* 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.lettuce.v5;
import io.lettuce.core.protocol.ProtocolKeyword;
import org.apache.skywalking.apm.plugin.lettuce.common.RedisChannelWriterInterceptor;
public class RedisChannelWriterInterceptorV5 extends RedisChannelWriterInterceptor {
@Override
protected String getCommandName(final ProtocolKeyword protocol) {
return protocol.name();
}
}

View File

@ -18,27 +18,26 @@
package org.apache.skywalking.apm.plugin.lettuce.v5.define;
import java.util.Collections;
import java.util.List;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
import net.bytebuddy.matcher.ElementMatchers;
import org.apache.skywalking.apm.agent.core.plugin.WitnessMethod;
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.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
import java.util.List;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
import static org.apache.skywalking.apm.agent.core.plugin.match.HierarchyMatch.byHierarchyMatch;
/**
* The writeAndFlush method is used in versions lower than 5.0.2.RELEASE
*/
public class RedisChannelWriterInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
public class RedisChannelWriterInstrumentationV5 extends ClassInstanceMethodsEnhancePluginDefine {
private static final String ENHANCE_CLASS = "io.lettuce.core.RedisChannelWriter";
private static final String REDIS_CHANNEL_WRITER_INTERCEPTOR_CLASS = "org.apache.skywalking.apm.plugin.lettuce.v5.RedisChannelWriterInterceptor";
private static final String REDIS_CHANNEL_WRITER_INTERCEPTOR_CLASS = "org.apache.skywalking.apm.plugin.lettuce.v5.RedisChannelWriterInterceptorV5";
@Override
public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
@ -47,12 +46,12 @@ public class RedisChannelWriterInstrumentation extends ClassInstanceMethodsEnhan
@Override
public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
return new InstanceMethodsInterceptPoint[]{
return new InstanceMethodsInterceptPoint[] {
new InstanceMethodsInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getMethodsMatcher() {
return named("write").and(takesArgument(0, named("io.lettuce.core.protocol.RedisCommand")).or(
takesArgument(0, List.class)));
takesArgument(0, List.class)));
}
@Override
@ -65,11 +64,19 @@ public class RedisChannelWriterInstrumentation extends ClassInstanceMethodsEnhan
return false;
}
},
};
};
}
@Override
public ClassMatch enhanceClass() {
return byHierarchyMatch(ENHANCE_CLASS);
}
@Override
protected List<WitnessMethod> witnessMethods() {
return Collections.singletonList(new WitnessMethod(
"io.lettuce.core.protocol.ProtocolKeyword",
ElementMatchers.named("name")
));
}
}

View File

@ -14,6 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
lettuce-5.x=org.apache.skywalking.apm.plugin.lettuce.v5.define.DefaultEndpointInstrumentation
lettuce-5.x=org.apache.skywalking.apm.plugin.lettuce.v5.define.RedisChannelWriterInstrumentation
lettuce-5.x=org.apache.skywalking.apm.plugin.lettuce.v5.define.RedisCommandInstrumentation
lettuce-5.x-6.4.x=org.apache.skywalking.apm.plugin.lettuce.v5.define.RedisChannelWriterInstrumentationV5

View File

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
~
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.skywalking</groupId>
<artifactId>lettuce-plugins</artifactId>
<version>9.5.0-SNAPSHOT</version>
</parent>
<artifactId>apm-lettuce-6.5.x-plugin</artifactId>
<packaging>jar</packaging>
<name>lettuce-6.5.x-plugin</name>
<properties>
<lettuce-core.version>6.5.0.RELEASE</lettuce-core.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>apm-lettuce-common</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
<version>${lettuce-core.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,29 @@
/*
* 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.lettuce.v65;
import io.lettuce.core.protocol.ProtocolKeyword;
import org.apache.skywalking.apm.plugin.lettuce.common.RedisChannelWriterInterceptor;
public class RedisChannelWriterInterceptorV65 extends RedisChannelWriterInterceptor {
@Override
protected String getCommandName(final ProtocolKeyword protocol) {
return protocol.toString();
}
}

View File

@ -0,0 +1,82 @@
/*
* 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.lettuce.v65.define;
import java.util.Collections;
import java.util.List;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
import net.bytebuddy.matcher.ElementMatchers;
import org.apache.skywalking.apm.agent.core.plugin.WitnessMethod;
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.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
import static org.apache.skywalking.apm.agent.core.plugin.match.HierarchyMatch.byHierarchyMatch;
public class RedisChannelWriterInstrumentationV65 extends ClassInstanceMethodsEnhancePluginDefine {
private static final String ENHANCE_CLASS = "io.lettuce.core.RedisChannelWriter";
private static final String REDIS_CHANNEL_WRITER_INTERCEPTOR_CLASS = "org.apache.skywalking.apm.plugin.lettuce.v65.RedisChannelWriterInterceptorV65";
@Override
public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return new ConstructorInterceptPoint[0];
}
@Override
public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
return new InstanceMethodsInterceptPoint[] {
new InstanceMethodsInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getMethodsMatcher() {
return named("write").and(takesArgument(0, named("io.lettuce.core.protocol.RedisCommand")).or(
takesArgument(0, List.class)));
}
@Override
public String getMethodsInterceptor() {
return REDIS_CHANNEL_WRITER_INTERCEPTOR_CLASS;
}
@Override
public boolean isOverrideArgs() {
return false;
}
},
};
}
@Override
public ClassMatch enhanceClass() {
return byHierarchyMatch(ENHANCE_CLASS);
}
@Override
protected List<WitnessMethod> witnessMethods() {
return Collections.singletonList(new WitnessMethod(
"io.lettuce.core.protocol.ProtocolKeyword",
ElementMatchers.named("toString")
));
}
}

View File

@ -0,0 +1,17 @@
# 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.
lettuce-6.5.x=org.apache.skywalking.apm.plugin.lettuce.v65.define.RedisChannelWriterInstrumentationV65

View File

@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
@ -17,19 +17,19 @@
~
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.skywalking</groupId>
<artifactId>apm-sdk-plugin</artifactId>
<artifactId>lettuce-plugins</artifactId>
<version>9.5.0-SNAPSHOT</version>
</parent>
<artifactId>apm-lettuce-5.x-plugin</artifactId>
<artifactId>apm-lettuce-common</artifactId>
<packaging>jar</packaging>
<name>lettuce-5.x-plugin</name>
<url>http://maven.apache.org</url>
<properties>
<lettuce-core.version>5.1.3.RELEASE</lettuce-core.version>
</properties>
@ -42,4 +42,5 @@
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -16,7 +16,7 @@
*
*/
package org.apache.skywalking.apm.plugin.lettuce.v5;
package org.apache.skywalking.apm.plugin.lettuce.common;
import io.netty.channel.Channel;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;

View File

@ -16,7 +16,7 @@
*
*/
package org.apache.skywalking.apm.plugin.lettuce.v5;
package org.apache.skywalking.apm.plugin.lettuce.common;
import org.apache.skywalking.apm.agent.core.boot.PluginConfig;

View File

@ -16,11 +16,12 @@
*
*/
package org.apache.skywalking.apm.plugin.lettuce.v5;
package org.apache.skywalking.apm.plugin.lettuce.common;
import io.lettuce.core.codec.StringCodec;
import io.lettuce.core.protocol.CommandArgs;
import io.lettuce.core.protocol.DecoratedCommand;
import io.lettuce.core.protocol.ProtocolKeyword;
import io.lettuce.core.protocol.RedisCommand;
import org.apache.skywalking.apm.agent.core.conf.Constants;
import org.apache.skywalking.apm.agent.core.context.ContextManager;
@ -71,7 +72,7 @@ public class RedisChannelWriterInterceptor implements InstanceMethodsAroundInter
String command = Constants.EMPTY_STRING;
if (allArguments[0] instanceof RedisCommand) {
RedisCommand<?, ?, ?> redisCommand = (RedisCommand<?, ?, ?>) allArguments[0];
command = redisCommand.getType().name();
command = getCommandName(redisCommand.getType());
operationName = operationName + command;
if (LettucePluginConfig.Plugin.Lettuce.TRACE_REDIS_PARAMETERS) {
key = getArgsKey(redisCommand);
@ -95,7 +96,7 @@ public class RedisChannelWriterInterceptor implements InstanceMethodsAroundInter
}
private String getArgsKey(RedisCommand<?, ?, ?> redisCommand) {
if (AUTH.equalsIgnoreCase(redisCommand.getType().name())) {
if (AUTH.equalsIgnoreCase(getCommandName(redisCommand.getType()))) {
return PASSWORD_MASK;
}
CommandArgs<?, ?> args = redisCommand.getArgs();
@ -130,6 +131,10 @@ public class RedisChannelWriterInterceptor implements InstanceMethodsAroundInter
}
}
protected String getCommandName(ProtocolKeyword protocol) {
return "UNKNOWN";
}
private static RedisCommand<?, ?, ?> getSpanCarrierCommand(Object o) {
RedisCommand<?, ?, ?> command = null;
if (o instanceof RedisCommand) {

View File

@ -16,7 +16,7 @@
*
*/
package org.apache.skywalking.apm.plugin.lettuce.v5;
package org.apache.skywalking.apm.plugin.lettuce.common;
import org.apache.skywalking.apm.agent.core.context.tag.StringTag;
import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;

View File

@ -16,7 +16,7 @@
*
*/
package org.apache.skywalking.apm.plugin.lettuce.v5;
package org.apache.skywalking.apm.plugin.lettuce.common;
import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;

View File

@ -16,7 +16,7 @@
*
*/
package org.apache.skywalking.apm.plugin.lettuce.v5;
package org.apache.skywalking.apm.plugin.lettuce.common;
import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;

View File

@ -16,7 +16,7 @@
*
*/
package org.apache.skywalking.apm.plugin.lettuce.v5.define;
package org.apache.skywalking.apm.plugin.lettuce.common.define;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
@ -33,7 +33,7 @@ public class DefaultEndpointInstrumentation extends ClassInstanceMethodsEnhanceP
private static final String ENHANCE_CLASS = "io.lettuce.core.protocol.DefaultEndpoint";
private static final String DEFAULT_ENDPOINT_CHANNEL_ACTIVE_INTERCEPTOR = "org.apache.skywalking.apm.plugin.lettuce.v5.DefaultEndpointChannelActiveInterceptor";
private static final String DEFAULT_ENDPOINT_CHANNEL_ACTIVE_INTERCEPTOR = "org.apache.skywalking.apm.plugin.lettuce.common.DefaultEndpointChannelActiveInterceptor";
@Override
public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {

View File

@ -16,7 +16,7 @@
*
*/
package org.apache.skywalking.apm.plugin.lettuce.v5.define;
package org.apache.skywalking.apm.plugin.lettuce.common.define;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
@ -34,9 +34,9 @@ public class RedisCommandInstrumentation extends ClassInstanceMethodsEnhancePlug
private static final String ENHANCE_CLASS = "io.lettuce.core.protocol.RedisCommand";
private static final String REDIS_COMMAND_COMPLETE_METHOD_INTERCEPTOR = "org.apache.skywalking.apm.plugin.lettuce.v5.RedisCommandCompleteMethodInterceptor";
private static final String REDIS_COMMAND_COMPLETE_EXCEPTIONALLY_METHOD_INTERCEPTOR = "org.apache.skywalking.apm.plugin.lettuce.v5.RedisCommandCompleteExceptionallyMethodInterceptor";
public static final String REDIS_COMMAND_CANCEL_METHOD_INTERCEPTOR = "org.apache.skywalking.apm.plugin.lettuce.v5.RedisCommandCancelMethodInterceptor";
private static final String REDIS_COMMAND_COMPLETE_METHOD_INTERCEPTOR = "org.apache.skywalking.apm.plugin.lettuce.common.RedisCommandCompleteMethodInterceptor";
private static final String REDIS_COMMAND_COMPLETE_EXCEPTIONALLY_METHOD_INTERCEPTOR = "org.apache.skywalking.apm.plugin.lettuce.common.RedisCommandCompleteExceptionallyMethodInterceptor";
public static final String REDIS_COMMAND_CANCEL_METHOD_INTERCEPTOR = "org.apache.skywalking.apm.plugin.lettuce.common.RedisCommandCancelMethodInterceptor";
@Override
public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {

View File

@ -0,0 +1,18 @@
# 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.
lettuce-common=org.apache.skywalking.apm.plugin.lettuce.common.define.DefaultEndpointInstrumentation
lettuce-common=org.apache.skywalking.apm.plugin.lettuce.common.define.RedisCommandInstrumentation

View File

@ -16,7 +16,7 @@
*
*/
package org.apache.skywalking.apm.plugin.lettuce.v5;
package org.apache.skywalking.apm.plugin.lettuce.common;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
@ -132,7 +132,7 @@ public class RedisChannelWriterInterceptorTest {
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
assertNotNull(spans);
assertThat(spans.size(), is(1));
assertThat(spans.get(0).getOperationName(), is("Lettuce/SET"));
assertThat(spans.get(0).getOperationName(), is("Lettuce/UNKNOWN"));
assertThat(spans.get(0).isExit(), is(true));
assertThat(SpanHelper.getComponentId(spans.get(0)), is(57));
List<TagValuePair> tags = SpanHelper.getTags(spans.get(0));

View File

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
~
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.skywalking</groupId>
<artifactId>apm-sdk-plugin</artifactId>
<version>9.5.0-SNAPSHOT</version>
</parent>
<artifactId>lettuce-plugins</artifactId>
<packaging>pom</packaging>
<modules>
<module>lettuce-common</module>
<module>lettuce-5.x-6.4.x-plugin</module>
<module>lettuce-6.5.x-plugin</module>
</modules>
</project>

View File

@ -87,7 +87,7 @@
<module>netty-socketio-plugin</module>
<module>httpclient-3.x-plugin</module>
<module>play-2.x-plugin</module>
<module>lettuce-5.x-plugin</module>
<module>lettuce-plugins</module>
<module>avro-plugin</module>
<module>finagle-6.25.x-plugin</module>
<module>quasar-plugin</module>

View File

@ -57,7 +57,9 @@
- kafka-0.11.x/1.x/2.x
- kafka-3.7.x
- kotlin-coroutine
- lettuce-5.x
- lettuce-common
- lettuce-5.x-6.4.x
- lettuce-6.5.x
- light4j
- mariadb-2.x
- micrometer-1.10.x

View File

@ -89,7 +89,7 @@ metrics based on the tracing data.
* Redis
* [Jedis](https://github.com/xetorthio/jedis) 2.x-4.x
* [Redisson](https://github.com/redisson/redisson) Easy Java Redis client 3.5.0 -> 3.30.0
* [Lettuce](https://github.com/lettuce-io/lettuce-core) 5.x
* [Lettuce](https://github.com/lettuce-io/lettuce-core) 5.x -> 6.7.1
* [MongoDB Java Driver](https://github.com/mongodb/mongo-java-driver) 2.13-2.14, 3.4.0-3.12.7, 4.0.0-4.1.0
* Memcached Client
* [Spymemcached](https://github.com/couchbase/spymemcached) 2.x

View File

@ -0,0 +1,21 @@
#!/bin/bash
#
# 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.
home="$(cd "$(dirname $0)"; pwd)"
java -Dredis.host=${REDIS_SERVERS} -jar -Dskywalking.plugin.lettuce.trace_redis_parameters=true ${agent_opts} ${home}/../libs/lettuce-6.5.x-scenario.jar &

View File

@ -0,0 +1,101 @@
# 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.
segmentItems:
- serviceName: lettuce-6.5.x-scenario
segmentSize: nq 0
segments:
- segmentId: not null
spans:
- operationName: HEAD:/lettuce-6.5.x-scenario/case/healthCheck
parentSpanId: -1
spanId: 0
spanLayer: Http
startTime: not null
endTime: not null
componentId: 1
isError: false
spanType: Entry
peer: ''
skipAnalysis: false
tags:
- {key: url, value: 'http://localhost:8080/lettuce-6.5.x-scenario/case/healthCheck'}
- {key: http.method, value: HEAD}
- {key: http.status_code, value: '200'}
- segmentId: not null
spans:
- operationName: Lettuce/GET
parentSpanId: 0
spanId: 1
spanLayer: Cache
startTime: not null
endTime: not null
componentId: 57
isError: false
spanType: Exit
peer: not null
skipAnalysis: false
tags:
- {key: cache.type, value: Redis}
- {key: cache.key, value: key}
- {key: cache.cmd, value: GET}
- {key: cache.op, value: read}
- operationName: Lettuce/SET
parentSpanId: 0
spanId: 2
spanLayer: Cache
startTime: not null
endTime: not null
componentId: 57
isError: false
spanType: Exit
peer: not null
skipAnalysis: false
tags:
- { key: cache.type, value: Redis }
- { key: cache.key, value: key0 }
- { key: cache.cmd, value: SET }
- { key: cache.op, value: write }
- operationName: Lettuce/SET
parentSpanId: 0
spanId: 3
spanLayer: Cache
startTime: not null
endTime: not null
componentId: 57
isError: false
spanType: Exit
peer: not null
skipAnalysis: false
tags:
- { key: cache.type, value: Redis }
- { key: cache.key, value: key1 }
- { key: cache.cmd, value: SET }
- { key: cache.op, value: write }
- operationName: GET:/lettuce-6.5.x-scenario/case/lettuce-case
parentSpanId: -1
spanId: 0
spanLayer: Http
startTime: not null
endTime: not null
componentId: 1
isError: false
spanType: Entry
peer: ''
skipAnalysis: false
tags:
- {key: url, value: 'http://localhost:8080/lettuce-6.5.x-scenario/case/lettuce-case'}
- {key: http.method, value: GET}
- {key: http.status_code, value: '200'}

View File

@ -0,0 +1,28 @@
# 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.
type: jvm
entryService: http://localhost:8080/lettuce-6.5.x-scenario/case/lettuce-case
healthCheck: http://localhost:8080/lettuce-6.5.x-scenario/case/healthCheck
startScript: ./bin/startup.sh
environment:
- REDIS_SERVERS=redis-server:6379
depends_on:
- redis-server
dependencies:
redis-server:
image: redis:3.2.9-alpine
hostname: redis-server

View File

@ -0,0 +1,136 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
~
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.skywalking</groupId>
<artifactId>lettuce-6.5.x-scenario</artifactId>
<version>1.0.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<compiler.version>1.8</compiler.version>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<test.framework.version>6.5.0.RELEASE</test.framework.version>
<docker.image.version>${test.framework.version}</docker.image.version>
<log4j.version>2.6.2</log4j.version>
<spring.version>4.3.8.RELEASE</spring.version>
<spring.boot.version>2.1.6.RELEASE</spring.boot.version>
<okhttp.version>3.4.2</okhttp.version>
</properties>
<name>lettuce-6.5.x-scenario</name>
<dependencies>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>${okhttp.version}</version>
</dependency>
<dependency>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
<version>${test.framework.version}</version>
</dependency>
<!-- Spring Boot-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>${spring.boot.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jcl</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<version>${spring.boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring.boot.version}</version>
</dependency>
</dependencies>
<build>
<finalName>lettuce-6.5.x-scenario</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${compiler.version}</source>
<target>${compiler.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>assemble</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
<outputDirectory>./target/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
~
-->
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>./bin</directory>
<fileMode>0775</fileMode>
</fileSet>
</fileSets>
<files>
<file>
<source>${project.build.directory}/lettuce-6.5.x-scenario.jar</source>
<outputDirectory>./libs</outputDirectory>
<fileMode>0775</fileMode>
</file>
</files>
</assembly>

View File

@ -0,0 +1,30 @@
/*
* 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.testcase.lettuce;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

View File

@ -0,0 +1,72 @@
/*
* 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.testcase.lettuce.controller;
import io.lettuce.core.LettuceFutures;
import io.lettuce.core.RedisClient;
import io.lettuce.core.RedisFuture;
import io.lettuce.core.api.StatefulRedisConnection;
import io.lettuce.core.api.async.RedisAsyncCommands;
import io.lettuce.core.api.sync.RedisCommands;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping("/case")
@PropertySource("classpath:application.properties")
public class LettuceController {
@Value("${redis.servers:127.0.0.1:6379}")
private String address;
@RequestMapping("/lettuce-case")
@ResponseBody
public String lettuceCase() {
RedisClient redisClient = RedisClient.create("redis://" + address);
StatefulRedisConnection<String, String> connection0 = redisClient.connect();
RedisCommands<String, String> syncCommand = connection0.sync();
syncCommand.get("key");
StatefulRedisConnection<String, String> connection1 = redisClient.connect();
RedisAsyncCommands<String, String> asyncCommands = connection1.async();
asyncCommands.setAutoFlushCommands(false);
List<RedisFuture<?>> futures = new ArrayList<>();
futures.add(asyncCommands.set("key0", "value0"));
futures.add(asyncCommands.set("key1", "value1"));
asyncCommands.flushCommands();
LettuceFutures.awaitAll(5, TimeUnit.SECONDS, futures.toArray(new RedisFuture[futures.size()]));
connection0.close();
connection1.close();
redisClient.shutdown();
return "Success";
}
@RequestMapping("/healthCheck")
@ResponseBody
public String healthCheck() {
return "healthCheck";
}
}

View File

@ -0,0 +1,19 @@
#
# 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.
#
#
server.port=8080
server.servlet.context-path=/lettuce-6.5.x-scenario

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
~
-->
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_ERR">
<PatternLayout charset="UTF-8" pattern="[%d{yyyy-MM-dd HH:mm:ss:SSS}] [%p] - %l - %m%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="WARN">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>

View File

@ -0,0 +1,20 @@
# 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.
6.5.0.RELEASE
6.5.5.RELEASE
6.6.0.RELEASE
6.7.1.RELEASE

View File

@ -17,4 +17,5 @@
5.2.1.RELEASE
5.1.8.RELEASE
5.0.5.RELEASE
6.1.4.RELEASE
6.1.4.RELEASE
6.4.2.RELEASE