Skip to content

Commit b1f18f3

Browse files
authored
Feature: Support for tracking for lettuce versions 6.5+ (#760)
1 parent 7f9287f commit b1f18f3

File tree

36 files changed

+877
-39
lines changed

36 files changed

+877
-39
lines changed

.github/workflows/plugins-test.1.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ jobs:
7272
- kafka-scenario
7373
- kotlin-coroutine-scenario
7474
- lettuce-scenario
75+
- lettuce-6.5.x-scenario
7576
- mongodb-3.x-scenario
7677
- mongodb-4.x-scenario
7778
- netty-socketio-scenario

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Release Notes.
1414
* Fix retransform failure when enhancing both parent and child classes.
1515
* Add support for `dameng(DM)` JDBC url format in `URLParser`.
1616
* Fix RabbitMQ Consumer could not receive handleCancelOk callback.
17+
* Support for tracking in lettuce versions 6.5.x and above.
1718

1819
All issues and pull requests are [here](https://github.com/apache/skywalking/milestone/236?closed=1)
1920

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed to the Apache Software Foundation (ASF) under one or more
4+
~ contributor license agreements. See the NOTICE file distributed with
5+
~ this work for additional information regarding copyright ownership.
6+
~ The ASF licenses this file to You under the Apache License, Version 2.0
7+
~ (the "License"); you may not use this file except in compliance with
8+
~ the License. You may obtain a copy of the License at
9+
~
10+
~ http://www.apache.org/licenses/LICENSE-2.0
11+
~
12+
~ Unless required by applicable law or agreed to in writing, software
13+
~ distributed under the License is distributed on an "AS IS" BASIS,
14+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
~ See the License for the specific language governing permissions and
16+
~ limitations under the License.
17+
~
18+
-->
19+
20+
<project xmlns="http://maven.apache.org/POM/4.0.0"
21+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
23+
<modelVersion>4.0.0</modelVersion>
24+
<parent>
25+
<groupId>org.apache.skywalking</groupId>
26+
<artifactId>lettuce-plugins</artifactId>
27+
<version>9.5.0-SNAPSHOT</version>
28+
</parent>
29+
30+
<artifactId>apm-lettuce-5.x-6.4.x-plugin</artifactId>
31+
<packaging>jar</packaging>
32+
33+
<name>lettuce-5.x-6.4.x-plugin</name>
34+
35+
<properties>
36+
<lettuce-core.version>5.0.0.RELEASE</lettuce-core.version>
37+
</properties>
38+
39+
<dependencies>
40+
<dependency>
41+
<groupId>org.apache.skywalking</groupId>
42+
<artifactId>apm-lettuce-common</artifactId>
43+
<version>${project.version}</version>
44+
<scope>provided</scope>
45+
</dependency>
46+
47+
<dependency>
48+
<groupId>io.lettuce</groupId>
49+
<artifactId>lettuce-core</artifactId>
50+
<version>${lettuce-core.version}</version>
51+
<scope>provided</scope>
52+
</dependency>
53+
</dependencies>
54+
55+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
package org.apache.skywalking.apm.plugin.lettuce.v5;
20+
21+
import io.lettuce.core.protocol.ProtocolKeyword;
22+
import org.apache.skywalking.apm.plugin.lettuce.common.RedisChannelWriterInterceptor;
23+
24+
public class RedisChannelWriterInterceptorV5 extends RedisChannelWriterInterceptor {
25+
@Override
26+
protected String getCommandName(final ProtocolKeyword protocol) {
27+
return protocol.name();
28+
}
29+
}
Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,26 @@
1818

1919
package org.apache.skywalking.apm.plugin.lettuce.v5.define;
2020

21+
import java.util.Collections;
22+
import java.util.List;
2123
import net.bytebuddy.description.method.MethodDescription;
2224
import net.bytebuddy.matcher.ElementMatcher;
25+
import net.bytebuddy.matcher.ElementMatchers;
26+
import org.apache.skywalking.apm.agent.core.plugin.WitnessMethod;
2327
import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
2428
import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
2529
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
2630
import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
2731

28-
import java.util.List;
29-
3032
import static net.bytebuddy.matcher.ElementMatchers.named;
3133
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
3234
import static org.apache.skywalking.apm.agent.core.plugin.match.HierarchyMatch.byHierarchyMatch;
3335

34-
/**
35-
* The writeAndFlush method is used in versions lower than 5.0.2.RELEASE
36-
*/
37-
public class RedisChannelWriterInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
36+
public class RedisChannelWriterInstrumentationV5 extends ClassInstanceMethodsEnhancePluginDefine {
3837

3938
private static final String ENHANCE_CLASS = "io.lettuce.core.RedisChannelWriter";
4039

41-
private static final String REDIS_CHANNEL_WRITER_INTERCEPTOR_CLASS = "org.apache.skywalking.apm.plugin.lettuce.v5.RedisChannelWriterInterceptor";
40+
private static final String REDIS_CHANNEL_WRITER_INTERCEPTOR_CLASS = "org.apache.skywalking.apm.plugin.lettuce.v5.RedisChannelWriterInterceptorV5";
4241

4342
@Override
4443
public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
@@ -47,12 +46,12 @@ public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
4746

4847
@Override
4948
public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
50-
return new InstanceMethodsInterceptPoint[]{
49+
return new InstanceMethodsInterceptPoint[] {
5150
new InstanceMethodsInterceptPoint() {
5251
@Override
5352
public ElementMatcher<MethodDescription> getMethodsMatcher() {
5453
return named("write").and(takesArgument(0, named("io.lettuce.core.protocol.RedisCommand")).or(
55-
takesArgument(0, List.class)));
54+
takesArgument(0, List.class)));
5655
}
5756

5857
@Override
@@ -65,11 +64,19 @@ public boolean isOverrideArgs() {
6564
return false;
6665
}
6766
},
68-
};
67+
};
6968
}
7069

7170
@Override
7271
public ClassMatch enhanceClass() {
7372
return byHierarchyMatch(ENHANCE_CLASS);
7473
}
74+
75+
@Override
76+
protected List<WitnessMethod> witnessMethods() {
77+
return Collections.singletonList(new WitnessMethod(
78+
"io.lettuce.core.protocol.ProtocolKeyword",
79+
ElementMatchers.named("name")
80+
));
81+
}
7582
}

apm-sniffer/apm-sdk-plugin/lettuce-5.x-plugin/src/main/resources/skywalking-plugin.def renamed to apm-sniffer/apm-sdk-plugin/lettuce-plugins/lettuce-5.x-6.4.x-plugin/src/main/resources/skywalking-plugin.def

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,4 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
lettuce-5.x=org.apache.skywalking.apm.plugin.lettuce.v5.define.DefaultEndpointInstrumentation
18-
lettuce-5.x=org.apache.skywalking.apm.plugin.lettuce.v5.define.RedisChannelWriterInstrumentation
19-
lettuce-5.x=org.apache.skywalking.apm.plugin.lettuce.v5.define.RedisCommandInstrumentation
17+
lettuce-5.x-6.4.x=org.apache.skywalking.apm.plugin.lettuce.v5.define.RedisChannelWriterInstrumentationV5
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed to the Apache Software Foundation (ASF) under one or more
4+
~ contributor license agreements. See the NOTICE file distributed with
5+
~ this work for additional information regarding copyright ownership.
6+
~ The ASF licenses this file to You under the Apache License, Version 2.0
7+
~ (the "License"); you may not use this file except in compliance with
8+
~ the License. You may obtain a copy of the License at
9+
~
10+
~ http://www.apache.org/licenses/LICENSE-2.0
11+
~
12+
~ Unless required by applicable law or agreed to in writing, software
13+
~ distributed under the License is distributed on an "AS IS" BASIS,
14+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
~ See the License for the specific language governing permissions and
16+
~ limitations under the License.
17+
~
18+
-->
19+
20+
<project xmlns="http://maven.apache.org/POM/4.0.0"
21+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
23+
<modelVersion>4.0.0</modelVersion>
24+
<parent>
25+
<groupId>org.apache.skywalking</groupId>
26+
<artifactId>lettuce-plugins</artifactId>
27+
<version>9.5.0-SNAPSHOT</version>
28+
</parent>
29+
<artifactId>apm-lettuce-6.5.x-plugin</artifactId>
30+
31+
<packaging>jar</packaging>
32+
33+
<name>lettuce-6.5.x-plugin</name>
34+
35+
<properties>
36+
<lettuce-core.version>6.5.0.RELEASE</lettuce-core.version>
37+
</properties>
38+
39+
<dependencies>
40+
<dependency>
41+
<groupId>org.apache.skywalking</groupId>
42+
<artifactId>apm-lettuce-common</artifactId>
43+
<version>${project.version}</version>
44+
<scope>provided</scope>
45+
</dependency>
46+
47+
<dependency>
48+
<groupId>io.lettuce</groupId>
49+
<artifactId>lettuce-core</artifactId>
50+
<version>${lettuce-core.version}</version>
51+
<scope>provided</scope>
52+
</dependency>
53+
</dependencies>
54+
55+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
package org.apache.skywalking.apm.plugin.lettuce.v65;
20+
21+
import io.lettuce.core.protocol.ProtocolKeyword;
22+
import org.apache.skywalking.apm.plugin.lettuce.common.RedisChannelWriterInterceptor;
23+
24+
public class RedisChannelWriterInterceptorV65 extends RedisChannelWriterInterceptor {
25+
@Override
26+
protected String getCommandName(final ProtocolKeyword protocol) {
27+
return protocol.toString();
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
package org.apache.skywalking.apm.plugin.lettuce.v65.define;
20+
21+
import java.util.Collections;
22+
import java.util.List;
23+
import net.bytebuddy.description.method.MethodDescription;
24+
import net.bytebuddy.matcher.ElementMatcher;
25+
import net.bytebuddy.matcher.ElementMatchers;
26+
import org.apache.skywalking.apm.agent.core.plugin.WitnessMethod;
27+
import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
28+
import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
29+
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
30+
import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
31+
32+
import static net.bytebuddy.matcher.ElementMatchers.named;
33+
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
34+
import static org.apache.skywalking.apm.agent.core.plugin.match.HierarchyMatch.byHierarchyMatch;
35+
36+
public class RedisChannelWriterInstrumentationV65 extends ClassInstanceMethodsEnhancePluginDefine {
37+
38+
private static final String ENHANCE_CLASS = "io.lettuce.core.RedisChannelWriter";
39+
40+
private static final String REDIS_CHANNEL_WRITER_INTERCEPTOR_CLASS = "org.apache.skywalking.apm.plugin.lettuce.v65.RedisChannelWriterInterceptorV65";
41+
42+
@Override
43+
public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
44+
return new ConstructorInterceptPoint[0];
45+
}
46+
47+
@Override
48+
public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
49+
return new InstanceMethodsInterceptPoint[] {
50+
new InstanceMethodsInterceptPoint() {
51+
@Override
52+
public ElementMatcher<MethodDescription> getMethodsMatcher() {
53+
return named("write").and(takesArgument(0, named("io.lettuce.core.protocol.RedisCommand")).or(
54+
takesArgument(0, List.class)));
55+
}
56+
57+
@Override
58+
public String getMethodsInterceptor() {
59+
return REDIS_CHANNEL_WRITER_INTERCEPTOR_CLASS;
60+
}
61+
62+
@Override
63+
public boolean isOverrideArgs() {
64+
return false;
65+
}
66+
},
67+
};
68+
}
69+
70+
@Override
71+
public ClassMatch enhanceClass() {
72+
return byHierarchyMatch(ENHANCE_CLASS);
73+
}
74+
75+
@Override
76+
protected List<WitnessMethod> witnessMethods() {
77+
return Collections.singletonList(new WitnessMethod(
78+
"io.lettuce.core.protocol.ProtocolKeyword",
79+
ElementMatchers.named("toString")
80+
));
81+
}
82+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
lettuce-6.5.x=org.apache.skywalking.apm.plugin.lettuce.v65.define.RedisChannelWriterInstrumentationV65

0 commit comments

Comments
 (0)